diff options
author | twiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 15:53:12 +0000 |
---|---|---|
committer | twiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 15:53:12 +0000 |
commit | e414727ea30e03a5d4582bdbba42d67327605273 (patch) | |
tree | 58746c063aea418e36d5a618c67bdf1bec9e7409 /content | |
parent | 33986d3ecde79d6a1bdf2b0edd17fc13bc2cc78b (diff) | |
download | chromium_src-e414727ea30e03a5d4582bdbba42d67327605273.zip chromium_src-e414727ea30e03a5d4582bdbba42d67327605273.tar.gz chromium_src-e414727ea30e03a5d4582bdbba42d67327605273.tar.bz2 |
This change implements a first pass in the effort to remove the dependency of PlatformDevice within Chrome. The Skia library now provides multiple back-ends for the SkDevice class, so PlatformDevice's inheritance of SkDevice, and the assumption of instances of PlatformDevice limits the use of these new back-ends.
A new set of helper functions is provided for the PlatformDevice entry points. Upon construction of a PlatformDevice, a pointer to the interface is cached in the parent SkDevice's SkMetaData. The new helper functions forward calls to the interface cached in the metadata.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/7019013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/backing_store_mac.mm | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/backing_store_skia.cc | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/backing_store_win.cc | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/backing_store_x.cc | 2 | ||||
-rw-r--r-- | content/plugin/webplugin_proxy.cc | 2 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 2 | ||||
-rw-r--r-- | content/renderer/webplugin_delegate_proxy.cc | 21 |
7 files changed, 20 insertions, 19 deletions
diff --git a/content/browser/renderer_host/backing_store_mac.mm b/content/browser/renderer_host/backing_store_mac.mm index 68da54e..bc0e0c0 100644 --- a/content/browser/renderer_host/backing_store_mac.mm +++ b/content/browser/renderer_host/backing_store_mac.mm @@ -123,14 +123,14 @@ bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect, if (!output->initialize(rect.width(), rect.height(), true)) return false; - CGContextRef temp_context = output->beginPlatformPaint(); + skia::ScopedPlatformPaint scoped_platform_paint(output); + CGContextRef temp_context = scoped_platform_paint.GetPlatformSurface(); CGContextSaveGState(temp_context); CGContextTranslateCTM(temp_context, 0.0, size().height()); CGContextScaleCTM(temp_context, 1.0, -1.0); CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), cg_layer()); CGContextRestoreGState(temp_context); - output->endPlatformPaint(); return true; } diff --git a/content/browser/renderer_host/backing_store_skia.cc b/content/browser/renderer_host/backing_store_skia.cc index f756504..8c79958 100644 --- a/content/browser/renderer_host/backing_store_skia.cc +++ b/content/browser/renderer_host/backing_store_skia.cc @@ -72,7 +72,7 @@ void BackingStoreSkia::PaintToBackingStore( SkRect dstrect = SkRect::MakeXYWH( SkIntToScalar(copy_rect.x()), SkIntToScalar(copy_rect.y()), SkIntToScalar(w), SkIntToScalar(h)); - SkBitmap b = p_canvas->getTopPlatformDevice().accessBitmap(false); + SkBitmap b = skia::GetTopDevice(*p_canvas)->accessBitmap(false); canvas_.get()->drawBitmapRect(b, &srcrect, dstrect); } } @@ -95,7 +95,7 @@ bool BackingStoreSkia::CopyFromBackingStore(const gfx::Rect& rect, if (!output->initialize(width, height, true)) return false; - SkBitmap bitmap = output->getTopPlatformDevice().accessBitmap(true); + SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); SkBitmap b; if (!canvas_->readPixels(skrect, &b)) diff --git a/content/browser/renderer_host/backing_store_win.cc b/content/browser/renderer_host/backing_store_win.cc index 0a1645d7..49545d5 100644 --- a/content/browser/renderer_host/backing_store_win.cc +++ b/content/browser/renderer_host/backing_store_win.cc @@ -158,10 +158,10 @@ bool BackingStoreWin::CopyFromBackingStore(const gfx::Rect& rect, if (!output->initialize(rect.width(), rect.height(), true)) return false; - HDC temp_dc = output->beginPlatformPaint(); + skia::ScopedPlatformPaint scoped_platform_paint(output); + HDC temp_dc = scoped_platform_paint.GetPlatformSurface(); BitBlt(temp_dc, 0, 0, rect.width(), rect.height(), hdc(), rect.x(), rect.y(), SRCCOPY); - output->endPlatformPaint(); return true; } diff --git a/content/browser/renderer_host/backing_store_x.cc b/content/browser/renderer_host/backing_store_x.cc index 8561eab..7767c75 100644 --- a/content/browser/renderer_host/backing_store_x.cc +++ b/content/browser/renderer_host/backing_store_x.cc @@ -375,7 +375,7 @@ bool BackingStoreX::CopyFromBackingStore(const gfx::Rect& rect, // it and copy each row out, only up to the pixels we're actually // using. This code assumes a visual mode where a pixel is // represented using a 32-bit unsigned int, with a byte per component. - SkBitmap bitmap = output->getTopPlatformDevice().accessBitmap(true); + SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); for (int y = 0; y < height; y++) { const uint32* src_row = reinterpret_cast<uint32*>( &image->data[image->bytes_per_line * y]); diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc index e046f01..014843f 100644 --- a/content/plugin/webplugin_proxy.cc +++ b/content/plugin/webplugin_proxy.cc @@ -371,7 +371,7 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) { // into (which is windowless_canvas_) so it can do blending. So we copy the // background bitmap into the windowless_canvas_. const SkBitmap& background_bitmap = - background_canvas_->getTopPlatformDevice().accessBitmap(false); + skia::GetTopDevice(*background_canvas_)->accessBitmap(false); windowless_canvas_->drawBitmap(background_bitmap, 0, 0); } else { // In non-transparent mode, the plugin doesn't care what's underneath, so we diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 98d6a4d..7e98d18 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -549,7 +549,7 @@ void RenderWidget::PaintRect(const gfx::Rect& rect, webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); // Flush to underlying bitmap. TODO(darin): is this needed? - canvas->getTopPlatformDevice().accessBitmap(false); + skia::GetTopDevice(*canvas)->accessBitmap(false); } PaintDebugBorder(rect, canvas); diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc index 91faa71..e6fa99f 100644 --- a/content/renderer/webplugin_delegate_proxy.cc +++ b/content/renderer/webplugin_delegate_proxy.cc @@ -728,7 +728,9 @@ void WebPluginDelegateProxy::Paint(WebKit::WebCanvas* canvas, // We're using the native OS APIs from here on out. #if WEBKIT_USING_SKIA - gfx::NativeDrawingContext context = skia::BeginPlatformPaint(canvas); + skia::ScopedPlatformPaint scoped_platform_paint(canvas); + gfx::NativeDrawingContext context = + scoped_platform_paint.GetPlatformSurface(); #elif WEBKIT_USING_CG gfx::NativeDrawingContext context = canvas; #endif @@ -764,10 +766,6 @@ void WebPluginDelegateProxy::Paint(WebKit::WebCanvas* canvas, invalidate_pending_ = false; Send(new PluginMsg_DidPaint(instance_id_)); } - -#if WEBKIT_USING_SKIA - skia::EndPlatformPaint(canvas); -#endif } bool WebPluginDelegateProxy::BackgroundChanged( @@ -850,8 +848,10 @@ bool WebPluginDelegateProxy::BackgroundChanged( int page_start_x = content_rect.x() - context_offset_x; int page_start_y = content_rect.y() - context_offset_y; - CGContextRef bg_context = - background_store_canvas_->getTopPlatformDevice().GetBitmapContext(); + skia::ScopedPlatformPaint scoped_platform_paint( + background_store_canvas_.get()); + CGContextRef bg_context = scoped_platform_paint.GetPlatformSurface(); + DCHECK_EQ(CGBitmapContextGetBitsPerPixel(context), CGBitmapContextGetBitsPerPixel(bg_context)); const unsigned char* bg_bytes = static_cast<const unsigned char*>( @@ -869,9 +869,10 @@ bool WebPluginDelegateProxy::BackgroundChanged( int page_start_x = static_cast<int>(page_x_double); int page_start_y = static_cast<int>(page_y_double); - skia::PlatformDevice& device = - background_store_canvas_->getTopPlatformDevice(); - cairo_surface_t* bg_surface = cairo_get_target(device.BeginPlatformPaint()); + skia::ScopedPlatformPaint scoped_platform_paint( + background_store_canvas_.get()); + cairo_surface_t* bg_surface =cairo_get_target( + scoped_platform_paint.GetPlatformSurface()); DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); cairo_surface_flush(bg_surface); |