OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
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(skia::CreatePlatformCanvas( |
177 paint_rect_.width(), paint_rect_.height(), true)); | 177 paint_rect_.width(), paint_rect_.height(), true)); |
178 } | 178 } |
179 | 179 |
180 // make sure webkit draws into our bitmap, not the window | 180 // make sure webkit draws into our bitmap, not the window |
181 CGContextRef bitmap_context = | 181 CGContextRef bitmap_context = |
182 skia::GetBitmapContext(skia::GetTopDevice(*canvas_)); | 182 skia::GetBitmapContext(skia::GetTopDevice(*canvas_)); |
183 [NSGraphicsContext setCurrentContext: | 183 [NSGraphicsContext setCurrentContext: |
184 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context | 184 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context |
185 flipped:YES]]; | 185 flipped:YES]]; |
186 | 186 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
278 #ifndef NDEBUG | 278 #ifndef NDEBUG |
279 DCHECK(!painting_); | 279 DCHECK(!painting_); |
280 #endif | 280 #endif |
281 DCHECK(canvas_.get()); | 281 DCHECK(canvas_.get()); |
282 | 282 |
283 set_painting(true); | 283 set_painting(true); |
284 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); | 284 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); |
285 set_painting(false); | 285 set_painting(false); |
286 } | 286 } |
OLD | NEW |