| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/gfx/platform_canvas_mac.h" | 9 #include "base/gfx/platform_canvas_mac.h" |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 void WebWidgetHost::Paint() { | 150 void WebWidgetHost::Paint() { |
| 151 NSRect r = [view_ frame]; | 151 NSRect r = [view_ frame]; |
| 152 gfx::Rect client_rect(NSRectToCGRect(r)); | 152 gfx::Rect client_rect(NSRectToCGRect(r)); |
| 153 NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; | 153 NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; |
| 154 CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]); | 154 CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]); |
| 155 | 155 |
| 156 // Allocate a canvas if necessary | 156 // Allocate a canvas if necessary |
| 157 if (!canvas_.get()) { | 157 if (!canvas_.get()) { |
| 158 ResetScrollRect(); | 158 ResetScrollRect(); |
| 159 paint_rect_ = client_rect; | 159 paint_rect_ = client_rect; |
| 160 canvas_.reset(new gfx::PlatformCanvas( | 160 canvas_.reset(new skia::PlatformCanvas( |
| 161 paint_rect_.width(), paint_rect_.height(), true)); | 161 paint_rect_.width(), paint_rect_.height(), true)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // make sure webkit draws into our bitmap, not the window | 164 // make sure webkit draws into our bitmap, not the window |
| 165 CGContextRef bitmap_context = | 165 CGContextRef bitmap_context = |
| 166 canvas_->getTopPlatformDevice().GetBitmapContext(); | 166 canvas_->getTopPlatformDevice().GetBitmapContext(); |
| 167 [NSGraphicsContext setCurrentContext: | 167 [NSGraphicsContext setCurrentContext: |
| 168 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context | 168 [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context |
| 169 flipped:NO]]; | 169 flipped:NO]]; |
| 170 | 170 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 266 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
| 267 #ifndef NDEBUG | 267 #ifndef NDEBUG |
| 268 DCHECK(!painting_); | 268 DCHECK(!painting_); |
| 269 #endif | 269 #endif |
| 270 DCHECK(canvas_.get()); | 270 DCHECK(canvas_.get()); |
| 271 | 271 |
| 272 set_painting(true); | 272 set_painting(true); |
| 273 webwidget_->Paint(canvas_.get(), rect); | 273 webwidget_->Paint(canvas_.get(), rect); |
| 274 set_painting(false); | 274 set_painting(false); |
| 275 } | 275 } |
| OLD | NEW |