Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: webkit/tools/test_shell/webwidget_host_win.cc

Issue 9416017: Optionally clear PlatformCanvas instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/tools/test_shell/webwidget_host.h" 5 #include "webkit/tools/test_shell/webwidget_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "skia/ext/platform_canvas.h" 8 #include "skia/ext/platform_canvas.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 case WM_SETFOCUS: 127 case WM_SETFOCUS:
128 host->SetFocus(true); 128 host->SetFocus(true);
129 break; 129 break;
130 130
131 case WM_KILLFOCUS: 131 case WM_KILLFOCUS:
132 host->SetFocus(false); 132 host->SetFocus(false);
133 break; 133 break;
134 } 134 }
135 } 135 }
136 136
137 return DefWindowProc(hwnd, message, wparam, lparam);; 137 return DefWindowProc(hwnd, message, wparam, lparam);
138 } 138 }
139 139
140 void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { 140 void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
141 DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; 141 DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
142 142
143 // If this invalidate overlaps with a pending scroll, then we have to 143 // If this invalidate overlaps with a pending scroll, then we have to
144 // downgrade to invalidating the scroll rect. 144 // downgrade to invalidating the scroll rect.
145 if (damaged_rect.Intersects(scroll_rect_)) { 145 if (damaged_rect.Intersects(scroll_rect_)) {
146 paint_rect_ = paint_rect_.Union(scroll_rect_); 146 paint_rect_ = paint_rect_.Union(scroll_rect_);
147 ResetScrollRect(); 147 ResetScrollRect();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 RECT r; 234 RECT r;
235 GetClientRect(view_, &r); 235 GetClientRect(view_, &r);
236 gfx::Rect client_rect(r); 236 gfx::Rect client_rect(r);
237 237
238 // Allocate a canvas if necessary 238 // Allocate a canvas if necessary
239 if (!canvas_.get()) { 239 if (!canvas_.get()) {
240 ResetScrollRect(); 240 ResetScrollRect();
241 paint_rect_ = client_rect; 241 paint_rect_ = client_rect;
242 canvas_.reset(new skia::PlatformCanvas( 242 canvas_.reset(new skia::PlatformCanvas(
243 paint_rect_.width(), paint_rect_.height(), true)); 243 paint_rect_.width(), paint_rect_.height(), true));
244 canvas_->clear(SkColorSetARGB(0, 0, 0, 0));
244 } 245 }
245 246
246 webwidget_->animate(0.0); 247 webwidget_->animate(0.0);
247 248
248 // This may result in more invalidation 249 // This may result in more invalidation
249 webwidget_->layout(); 250 webwidget_->layout();
250 251
251 // Scroll the canvas if necessary 252 // Scroll the canvas if necessary
252 scroll_rect_ = client_rect.Intersect(scroll_rect_); 253 scroll_rect_ = client_rect.Intersect(scroll_rect_);
253 if (!scroll_rect_.IsEmpty()) { 254 if (!scroll_rect_.IsEmpty()) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { 374 void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
374 #ifndef NDEBUG 375 #ifndef NDEBUG
375 DCHECK(!painting_); 376 DCHECK(!painting_);
376 #endif 377 #endif
377 DCHECK(canvas_.get()); 378 DCHECK(canvas_.get());
378 379
379 set_painting(true); 380 set_painting(true);
380 webwidget_->paint(canvas_.get(), rect); 381 webwidget_->paint(canvas_.get(), rect);
381 set_painting(false); 382 set_painting(false);
382 } 383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698