OLD | NEW |
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 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 canvas_->getTopPlatformDevice().GetBitmapContext(); | 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 |
187 webwidget_->animate(); | 187 webwidget_->animate(); |
188 | 188 |
189 // This may result in more invalidation | 189 // This may result in more invalidation |
190 webwidget_->layout(); | 190 webwidget_->layout(); |
191 | 191 |
192 // Scroll the canvas if necessary | 192 // Scroll the canvas if necessary |
(...skipping 21 matching lines...) Expand all Loading... |
214 | 214 |
215 // set the context back to our window | 215 // set the context back to our window |
216 [NSGraphicsContext setCurrentContext: view_context]; | 216 [NSGraphicsContext setCurrentContext: view_context]; |
217 | 217 |
218 // Paint to the screen | 218 // Paint to the screen |
219 if ([view_ lockFocusIfCanDraw]) { | 219 if ([view_ lockFocusIfCanDraw]) { |
220 int bitmap_height = CGBitmapContextGetHeight(bitmap_context); | 220 int bitmap_height = CGBitmapContextGetHeight(bitmap_context); |
221 int bitmap_width = CGBitmapContextGetWidth(bitmap_context); | 221 int bitmap_width = CGBitmapContextGetWidth(bitmap_context); |
222 CGRect bitmap_rect = { { 0, 0 }, | 222 CGRect bitmap_rect = { { 0, 0 }, |
223 { bitmap_width, bitmap_height } }; | 223 { bitmap_width, bitmap_height } }; |
224 canvas_->getTopPlatformDevice().DrawToContext( | 224 skia::DrawToNativeContext(canvas_.get(), context, 0, |
225 context, 0, client_rect.height() - bitmap_height, &bitmap_rect); | 225 client_rect.height() - bitmap_height, &bitmap_rect); |
226 | 226 |
227 [view_ unlockFocus]; | 227 [view_ unlockFocus]; |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 WebScreenInfo WebWidgetHost::GetScreenInfo() { | 231 WebScreenInfo WebWidgetHost::GetScreenInfo() { |
232 return WebScreenInfoFactory::screenInfo(view_); | 232 return WebScreenInfoFactory::screenInfo(view_); |
233 } | 233 } |
234 | 234 |
235 void WebWidgetHost::Resize(const gfx::Rect& rect) { | 235 void WebWidgetHost::Resize(const gfx::Rect& rect) { |
(...skipping 41 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 |