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

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: Address style issues. Created 8 years, 10 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void WebWidgetHost::Paint() { 167 void WebWidgetHost::Paint() {
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(),
178 skia::PlatformDevice::FLAGS_OPAQUE |
179 skia::PlatformDevice::FLAGS_INITIALIZED));
Jeff Timanus 2012/02/23 22:14:10 This clear can be performed explicitly on mac.
178 } 180 }
179 181
180 // make sure webkit draws into our bitmap, not the window 182 // make sure webkit draws into our bitmap, not the window
181 CGContextRef bitmap_context = 183 CGContextRef bitmap_context =
182 skia::GetBitmapContext(skia::GetTopDevice(*canvas_)); 184 skia::GetBitmapContext(skia::GetTopDevice(*canvas_));
183 [NSGraphicsContext setCurrentContext: 185 [NSGraphicsContext setCurrentContext:
184 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context 186 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context
185 flipped:YES]]; 187 flipped:YES]];
186 188
187 webwidget_->animate(0.0); 189 webwidget_->animate(0.0);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { 279 void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
278 #ifndef NDEBUG 280 #ifndef NDEBUG
279 DCHECK(!painting_); 281 DCHECK(!painting_);
280 #endif 282 #endif
281 DCHECK(canvas_.get()); 283 DCHECK(canvas_.get());
282 284
283 set_painting(true); 285 set_painting(true);
284 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); 286 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect);
285 set_painting(false); 287 set_painting(false);
286 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698