diff options
-rw-r--r-- | skia/ext/bitmap_platform_device_win.cc | 7 | ||||
-rw-r--r-- | skia/ext/bitmap_platform_device_win.h | 4 | ||||
-rw-r--r-- | skia/ext/platform_canvas.h | 4 | ||||
-rw-r--r-- | skia/ext/platform_canvas_linux.cc | 6 | ||||
-rw-r--r-- | skia/ext/platform_canvas_mac.cc | 6 | ||||
-rw-r--r-- | skia/ext/platform_canvas_win.cc | 9 | ||||
-rw-r--r-- | skia/ext/platform_device_win.h | 7 | ||||
-rw-r--r-- | skia/ext/vector_canvas_unittest.cc | 3 | ||||
-rw-r--r-- | skia/ext/vector_platform_device_emf_win.cc | 9 | ||||
-rw-r--r-- | skia/ext/vector_platform_device_emf_win.h | 2 | ||||
-rw-r--r-- | ui/gfx/blit.cc | 26 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 3 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 12 | ||||
-rw-r--r-- | webkit/tools/test_shell/webwidget_host_win.cc | 5 |
15 files changed, 53 insertions, 53 deletions
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc index c812e84..75eb113 100644 --- a/skia/ext/bitmap_platform_device_win.cc +++ b/skia/ext/bitmap_platform_device_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -201,7 +201,7 @@ BitmapPlatformDevice& BitmapPlatformDevice::operator=( return *this; } -HDC BitmapPlatformDevice::getBitmapDC() { +HDC BitmapPlatformDevice::beginPlatformPaint() { return data_->GetBitmapDC(); } @@ -214,7 +214,7 @@ void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y, const RECT* src_rect) { bool created_dc = !data_->IsBitmapDCCreated(); - HDC source_dc = getBitmapDC(); + HDC source_dc = beginPlatformPaint(); RECT temp_rect; if (!src_rect) { @@ -261,6 +261,7 @@ void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y, } LoadTransformToDC(source_dc, data_->transform()); + endPlatformPaint(); if (created_dc) data_->ReleaseBitmapDC(); } diff --git a/skia/ext/bitmap_platform_device_win.h b/skia/ext/bitmap_platform_device_win.h index 87a2e1d0..6d5805f 100644 --- a/skia/ext/bitmap_platform_device_win.h +++ b/skia/ext/bitmap_platform_device_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -75,7 +75,7 @@ class BitmapPlatformDevice : public PlatformDevice { // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The // bitmap DC is lazy created. - virtual HDC getBitmapDC(); + virtual HDC beginPlatformPaint(); // Loads the given transform and clipping region into the HDC. This is // overridden from SkDevice. diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h index 49d0e21..528fd1a 100644 --- a/skia/ext/platform_canvas.h +++ b/skia/ext/platform_canvas.h @@ -69,8 +69,8 @@ class SK_API PlatformCanvas : public SkCanvas { // Call endPlatformPaint when you are done and want to use Skia operations // after calling the platform-specific beginPlatformPaint; this will // synchronize the bitmap to OS if necessary. - PlatformDevice::PlatformSurface beginPlatformPaint(); - void endPlatformPaint(); + PlatformDevice::PlatformSurface beginPlatformPaint() const; + void endPlatformPaint() const; // Returns the platform device pointer of the topmost rect with a non-empty // clip. In practice, this is usually either the top layer or nothing, since diff --git a/skia/ext/platform_canvas_linux.cc b/skia/ext/platform_canvas_linux.cc index 5d3594e..fc038f9 100644 --- a/skia/ext/platform_canvas_linux.cc +++ b/skia/ext/platform_canvas_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,11 +33,11 @@ bool PlatformCanvas::initialize(int width, int height, bool is_opaque, width, height, is_opaque, data)); } -cairo_t* PlatformCanvas::beginPlatformPaint() { +cairo_t* PlatformCanvas::beginPlatformPaint() const { return getTopPlatformDevice().beginPlatformPaint(); } -void PlatformCanvas::endPlatformPaint() { +void PlatformCanvas::endPlatformPaint() const { // We don't need to do anything on Linux here. } diff --git a/skia/ext/platform_canvas_mac.cc b/skia/ext/platform_canvas_mac.cc index 9373468..e79e087 100644 --- a/skia/ext/platform_canvas_mac.cc +++ b/skia/ext/platform_canvas_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -49,11 +49,11 @@ bool PlatformCanvas::initialize(CGContextRef context, context, width, height, is_opaque)); } -CGContextRef PlatformCanvas::beginPlatformPaint() { +CGContextRef PlatformCanvas::beginPlatformPaint() const { return getTopPlatformDevice().GetBitmapContext(); } -void PlatformCanvas::endPlatformPaint() { +void PlatformCanvas::endPlatformPaint() const { // Flushing will be done in onAccessBitmap. } diff --git a/skia/ext/platform_canvas_win.cc b/skia/ext/platform_canvas_win.cc index e761cee..8d1a65a4 100644 --- a/skia/ext/platform_canvas_win.cc +++ b/skia/ext/platform_canvas_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -106,13 +106,14 @@ bool PlatformCanvas::initialize(int width, width, height, is_opaque, shared_section)); } -HDC PlatformCanvas::beginPlatformPaint() { - return getTopPlatformDevice().getBitmapDC(); +HDC PlatformCanvas::beginPlatformPaint() const { + return getTopPlatformDevice().beginPlatformPaint(); } -void PlatformCanvas::endPlatformPaint() { +void PlatformCanvas::endPlatformPaint() const { // we don't clear the DC here since it will be likely to be used again // flushing will be done in onAccessBitmap + return getTopPlatformDevice().endPlatformPaint(); } } // namespace skia diff --git a/skia/ext/platform_device_win.h b/skia/ext/platform_device_win.h index 425f944..966b49f 100644 --- a/skia/ext/platform_device_win.h +++ b/skia/ext/platform_device_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -30,7 +30,10 @@ class SK_API PlatformDevice : public SkDevice { // The DC that corresponds to the bitmap, used for GDI operations drawing // into the bitmap. This is possibly heavyweight, so it should be existant // only during one pass of rendering. - virtual HDC getBitmapDC() = 0; + virtual HDC beginPlatformPaint() = 0; + + // Finish a previous call to beginPlatformPaint. + virtual void endPlatformPaint() { } // Draws to the given screen DC, if the bitmap DC doesn't exist, this will // temporarily create it. However, if you have created the bitmap DC, it will diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index 82deea2..ec8fb38 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -99,7 +99,7 @@ class Image { Image(const skia::PlatformCanvas& canvas) : ignore_alpha_(true) { // Use a different way to access the bitmap. The normal way would be to // query the SkBitmap. - HDC context = canvas.getTopPlatformDevice().getBitmapDC(); + HDC context = canvas.beginPlatformPaint(); HGDIOBJ bitmap = GetCurrentObject(context, OBJ_BITMAP); EXPECT_TRUE(bitmap != NULL); // Initialize the clip region to the entire bitmap. @@ -111,6 +111,7 @@ class Image { size_t size = row_length_ * height_; data_.resize(size); memcpy(&*data_.begin(), bitmap_data.bmBits, size); + canvas.endPlatformPaint(); } // Loads the image from a canvas. diff --git a/skia/ext/vector_platform_device_emf_win.cc b/skia/ext/vector_platform_device_emf_win.cc index d86ad3d..07d1083 100644 --- a/skia/ext/vector_platform_device_emf_win.cc +++ b/skia/ext/vector_platform_device_emf_win.cc @@ -194,13 +194,14 @@ void VectorPlatformDeviceEmf::drawRect(const SkDraw& draw, if (!ApplyPaint(paint)) { return; } - HDC dc = getBitmapDC(); + HDC dc = beginPlatformPaint(); if (!Rectangle(dc, SkScalarRound(rect.fLeft), SkScalarRound(rect.fTop), SkScalarRound(rect.fRight), SkScalarRound(rect.fBottom))) { SkASSERT(false); } + endPlatformPaint(); Cleanup(); } @@ -226,7 +227,7 @@ void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw, if (!ApplyPaint(paint)) { return; } - HDC dc = getBitmapDC(); + HDC dc = beginPlatformPaint(); PlatformDevice::LoadPathToDC(dc, path); switch (paint.getStyle()) { case SkPaint::kFill_Style: { @@ -248,6 +249,7 @@ void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw, SkASSERT(false); break; } + endPlatformPaint(); Cleanup(); } @@ -632,7 +634,6 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, bitmap_header.bV4BlueMask = 0x000000ff; bitmap_header.bV4AlphaMask = 0xff000000; - HDC dc = getBitmapDC(); SkAutoLockPixels lock(bitmap); SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); const uint32_t* pixels = static_cast<const uint32_t*>(bitmap.getPixels()); @@ -655,6 +656,7 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, } } + HDC dc = beginPlatformPaint(); BITMAPINFOHEADER hdr; FillBitmapInfoHeader(src_size_x, src_size_y, &hdr); if (is_translucent) { @@ -720,6 +722,7 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, SRCCOPY); SkASSERT(result); } + endPlatformPaint(); Cleanup(); } diff --git a/skia/ext/vector_platform_device_emf_win.h b/skia/ext/vector_platform_device_emf_win.h index 72fd90a..d86e1db 100644 --- a/skia/ext/vector_platform_device_emf_win.h +++ b/skia/ext/vector_platform_device_emf_win.h @@ -39,7 +39,7 @@ class VectorPlatformDeviceEmf : public PlatformDevice { return SkNEW(VectorPlatformDeviceEmfFactory); } - virtual HDC getBitmapDC() { + virtual HDC beginPlatformPaint() { return hdc_; } diff --git a/ui/gfx/blit.cc b/ui/gfx/blit.cc index 9f57e68..76411a3 100644 --- a/ui/gfx/blit.cc +++ b/ui/gfx/blit.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -91,24 +91,13 @@ void BlitContextToContext(NativeDrawingContext dst_context, #endif } -static NativeDrawingContext GetContextFromCanvas( - skia::PlatformCanvas *canvas) { - skia::PlatformDevice& device = canvas->getTopPlatformDevice(); -#if defined(OS_WIN) - return device.getBitmapDC(); -#elif defined(OS_MACOSX) - return device.GetBitmapContext(); -#else // Linux, BSD, others - return device.beginPlatformPaint(); -#endif -} - void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, const Rect& dst_rect, NativeDrawingContext src_context, const Point& src_origin) { - BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, + BlitContextToContext(dst_canvas->beginPlatformPaint(), dst_rect, src_context, src_origin); + dst_canvas->endPlatformPaint(); } void BlitCanvasToContext(NativeDrawingContext dst_context, @@ -116,15 +105,18 @@ void BlitCanvasToContext(NativeDrawingContext dst_context, skia::PlatformCanvas *src_canvas, const Point& src_origin) { BlitContextToContext(dst_context, dst_rect, - GetContextFromCanvas(src_canvas), src_origin); + src_canvas->beginPlatformPaint(), src_origin); + src_canvas->endPlatformPaint(); } void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, const Rect& dst_rect, skia::PlatformCanvas *src_canvas, const Point& src_origin) { - BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, - GetContextFromCanvas(src_canvas), src_origin); + BlitContextToContext(dst_canvas->beginPlatformPaint(), dst_rect, + src_canvas->beginPlatformPaint(), src_origin); + src_canvas->endPlatformPaint(); + dst_canvas->endPlatformPaint(); } #if defined(OS_WIN) diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 0d2d998..e9c2d2f 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -460,11 +460,12 @@ void NativeWidgetWin::OnPaint(HDC dc) { GetWindowRect(hwnd(), &wr); SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; POINT position = {wr.left, wr.top}; - HDC dib_dc = window_contents_->getTopPlatformDevice().getBitmapDC(); + HDC dib_dc = window_contents_->beginPlatformPaint(); POINT zero = {0, 0}; BLENDFUNCTION blend = {AC_SRC_OVER, 0, 125, AC_SRC_ALPHA}; UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); + window_contents_->endPlatformPaint(); } else { scoped_ptr<gfx::CanvasPaint> canvas( gfx::CanvasPaint::CreateCanvasPaint(hwnd())); diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index eb1c67b..7d54e35 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -1118,12 +1118,13 @@ void WidgetWin::RedrawLayeredWindowContents() { GetWindowRect(&wr); SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; POINT position = {wr.left, wr.top}; - HDC dib_dc = layered_window_contents_->getTopPlatformDevice().getBitmapDC(); + HDC dib_dc = layered_window_contents_->beginPlatformPaint(); POINT zero = {0, 0}; BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); layered_window_invalid_rect_.SetRect(0, 0, 0, 0); + layered_window_contents_->endPlatformPaint(); } void WidgetWin::ClientAreaSizeChanged() { diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index b8fd69b..ab3302a 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -1231,10 +1231,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, #elif defined(OS_WIN) // On Windows, we now need to render the PDF to the DC that backs the // supplied canvas. - skia::VectorPlatformDeviceEmf& device = - static_cast<skia::VectorPlatformDeviceEmf&>( - canvas->getTopPlatformDevice()); - HDC dc = device.getBitmapDC(); + HDC dc = canvas->beginPlatformPaint(); gfx::Size size_in_pixels; size_in_pixels.set_width( printing::ConvertUnit(current_print_settings_.printable_area.size.width, @@ -1256,6 +1253,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, current_print_settings_.dpi, current_print_settings_.dpi, 0, 0, size_in_pixels.width(), size_in_pixels.height(), true, false, true, true); + canvas->endPlatformPaint(); #endif // defined(OS_WIN) return ret; @@ -1322,10 +1320,7 @@ bool PluginInstance::DrawJPEGToPlatformDC( const SkBitmap& bitmap, const gfx::Rect& printable_area, WebKit::WebCanvas* canvas) { - skia::VectorPlatformDeviceEmf& device = - static_cast<skia::VectorPlatformDeviceEmf&>( - canvas->getTopPlatformDevice()); - HDC dc = device.getBitmapDC(); + HDC dc = canvas->beginPlatformPaint(); // TODO(sanjeevr): This is a temporary hack. If we output a JPEG // to the EMF, the EnumEnhMetaFile call fails in the browser // process. The failure also happens if we output nothing here. @@ -1364,6 +1359,7 @@ bool PluginInstance::DrawJPEGToPlatformDC( &compressed_image.front(), reinterpret_cast<const BITMAPINFO*>(&bmi), DIB_RGB_COLORS, SRCCOPY); + canvas->endPlatformPaint(); return true; } #endif // OS_WIN diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc index 8056b46..17d5ae1 100644 --- a/webkit/tools/test_shell/webwidget_host_win.cc +++ b/webkit/tools/test_shell/webwidget_host_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -251,12 +251,13 @@ void WebWidgetHost::Paint() { // Scroll the canvas if necessary scroll_rect_ = client_rect.Intersect(scroll_rect_); if (!scroll_rect_.IsEmpty()) { - HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC(); + HDC hdc = canvas_->beginPlatformPaint(); RECT damaged_rect, r = scroll_rect_.ToRECT(); ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect); PaintRect(gfx::Rect(damaged_rect)); + canvas_->endPlatformPaint(); } ResetScrollRect(); |