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

Side by Side Diff: webkit/tools/test_shell/mac/webwidget_host.mm

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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "webkit/tools/test_shell/webwidget_host.h" 7 #include "webkit/tools/test_shell/webwidget_host.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "skia/ext/platform_canvas.h" 10 #include "skia/ext/platform_canvas.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 gfx::Rect client_rect(NSRectToCGRect([view_ frame])); 168 gfx::Rect client_rect(NSRectToCGRect([view_ frame]));
169 NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; 169 NSGraphicsContext* view_context = [NSGraphicsContext currentContext];
170 CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]); 170 CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]);
171 171
172 // Allocate a canvas if necessary 172 // Allocate a canvas if necessary
173 if (!canvas_.get()) { 173 if (!canvas_.get()) {
174 ResetScrollRect(); 174 ResetScrollRect();
175 paint_rect_ = client_rect; 175 paint_rect_ = client_rect;
176 canvas_.reset(new skia::PlatformCanvas( 176 canvas_.reset(new skia::PlatformCanvas(
177 paint_rect_.width(), paint_rect_.height(), true)); 177 paint_rect_.width(), paint_rect_.height(), true));
178 canvas_->clear(SkColorSetARGB(0, 0, 0, 0));
vandebo (ex-Chrome) 2012/03/14 23:38:29 Is this one necessary?
Jeff Timanus 2012/03/15 19:01:28 I added a clear here because it wasn't clear to me
178 } 179 }
179 180
180 // make sure webkit draws into our bitmap, not the window 181 // make sure webkit draws into our bitmap, not the window
181 CGContextRef bitmap_context = 182 CGContextRef bitmap_context =
182 skia::GetBitmapContext(skia::GetTopDevice(*canvas_)); 183 skia::GetBitmapContext(skia::GetTopDevice(*canvas_));
183 [NSGraphicsContext setCurrentContext: 184 [NSGraphicsContext setCurrentContext:
184 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context 185 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context
185 flipped:YES]]; 186 flipped:YES]];
186 187
187 webwidget_->animate(0.0); 188 webwidget_->animate(0.0);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { 278 void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
278 #ifndef NDEBUG 279 #ifndef NDEBUG
279 DCHECK(!painting_); 280 DCHECK(!painting_);
280 #endif 281 #endif
281 DCHECK(canvas_.get()); 282 DCHECK(canvas_.get());
282 283
283 set_painting(true); 284 set_painting(true);
284 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); 285 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect);
285 set_painting(false); 286 set_painting(false);
286 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698