diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 17:17:08 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 17:17:08 +0000 |
commit | 49d198eaf7bd7b118fb46b97cc790fdc7b380eee (patch) | |
tree | fb0012720373f1e286e06f8cd0595d44c3452d30 /skia | |
parent | 83da5db25bfd45670eca38f0eb9d6a780090447b (diff) | |
download | chromium_src-49d198eaf7bd7b118fb46b97cc790fdc7b380eee.zip chromium_src-49d198eaf7bd7b118fb46b97cc790fdc7b380eee.tar.gz chromium_src-49d198eaf7bd7b118fb46b97cc790fdc7b380eee.tar.bz2 |
rename getBitmapDC to beginPlatformPaint and add calls to endPlatformPaint
This takes a step toward unifying the platform device interface between Windows and Linux and helps to make VectorPlatformDeviceSkia have less ifdefs.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6677142
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80474 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-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 |
10 files changed, 33 insertions, 24 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_; } |