summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device.cc2
-rw-r--r--skia/ext/bitmap_platform_device_linux.h2
-rw-r--r--skia/ext/bitmap_platform_device_mac.cc12
-rw-r--r--skia/ext/bitmap_platform_device_mac.h16
-rw-r--r--skia/ext/bitmap_platform_device_win.cc12
-rw-r--r--skia/ext/bitmap_platform_device_win.h13
-rw-r--r--skia/ext/canvas_paint_linux.h2
-rw-r--r--skia/ext/canvas_paint_mac.h2
-rw-r--r--skia/ext/canvas_paint_win.h5
-rw-r--r--skia/ext/platform_canvas.cc38
-rw-r--r--skia/ext/platform_canvas.h76
-rw-r--r--skia/ext/platform_canvas_linux.cc12
-rw-r--r--skia/ext/platform_canvas_mac.cc10
-rw-r--r--skia/ext/platform_canvas_unittest.cc44
-rw-r--r--skia/ext/platform_canvas_win.cc8
-rw-r--r--skia/ext/platform_device.cc74
-rw-r--r--skia/ext/platform_device.h75
-rw-r--r--skia/ext/platform_device_linux.cc9
-rw-r--r--skia/ext/platform_device_linux.h9
-rw-r--r--skia/ext/platform_device_mac.cc26
-rw-r--r--skia/ext/platform_device_mac.h11
-rw-r--r--skia/ext/platform_device_win.cc24
-rw-r--r--skia/ext/platform_device_win.h11
-rw-r--r--skia/ext/skia_utils_mac.mm4
-rw-r--r--skia/ext/vector_canvas.cc5
-rw-r--r--skia/ext/vector_canvas.h6
-rw-r--r--skia/ext/vector_canvas_unittest.cc12
-rw-r--r--skia/ext/vector_platform_device_emf_win.cc4
-rw-r--r--skia/ext/vector_platform_device_emf_win.h2
-rw-r--r--skia/ext/vector_platform_device_skia.cc8
-rw-r--r--skia/ext/vector_platform_device_skia.h2
-rw-r--r--skia/skia.gyp3
32 files changed, 206 insertions, 333 deletions
diff --git a/skia/ext/bitmap_platform_device.cc b/skia/ext/bitmap_platform_device.cc
index 05037c6..bec8a63 100644
--- a/skia/ext/bitmap_platform_device.cc
+++ b/skia/ext/bitmap_platform_device.cc
@@ -40,7 +40,7 @@ bool Constrain(int available_size, int* position, int *size) {
namespace skia {
-void BitmapPlatformDevice::MakeOpaque(int x, int y, int width, int height) {
+void BitmapPlatformDevice::makeOpaque(int x, int y, int width, int height) {
const SkBitmap& bitmap = accessBitmap(true);
SkASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
diff --git a/skia/ext/bitmap_platform_device_linux.h b/skia/ext/bitmap_platform_device_linux.h
index 927bd43..37695f1 100644
--- a/skia/ext/bitmap_platform_device_linux.h
+++ b/skia/ext/bitmap_platform_device_linux.h
@@ -88,7 +88,7 @@ class BitmapPlatformDevice : public PlatformDevice {
static BitmapPlatformDevice* Create(int width, int height,
bool is_opaque, uint8_t* data);
- virtual void MakeOpaque(int x, int y, int width, int height);
+ virtual void makeOpaque(int x, int y, int width, int height);
// Overridden from SkDevice:
virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc
index 8276545..543fc38 100644
--- a/skia/ext/bitmap_platform_device_mac.cc
+++ b/skia/ext/bitmap_platform_device_mac.cc
@@ -226,8 +226,8 @@ void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
data_->SetMatrixClip(transform, region);
}
-void BitmapPlatformDevice::DrawToNativeContext(CGContextRef context, int x,
- int y, const CGRect* src_rect) {
+void BitmapPlatformDevice::DrawToContext(CGContextRef context, int x, int y,
+ const CGRect* src_rect) {
bool created_dc = false;
if (!data_->bitmap_context()) {
created_dc = true;
@@ -261,6 +261,14 @@ bool BitmapPlatformDevice::IsVectorial() {
return false;
}
+// Returns the color value at the specified location.
+SkColor BitmapPlatformDevice::getColorAt(int x, int y) {
+ const SkBitmap& bitmap = accessBitmap(true);
+ SkAutoLockPixels lock(bitmap);
+ uint32_t* data = bitmap.getAddr32(0, 0);
+ return static_cast<SkColor>(data[x + y * width()]);
+}
+
void BitmapPlatformDevice::onAccessBitmap(SkBitmap*) {
// Not needed in CoreGraphics
}
diff --git a/skia/ext/bitmap_platform_device_mac.h b/skia/ext/bitmap_platform_device_mac.h
index 565bbcf..f126adc 100644
--- a/skia/ext/bitmap_platform_device_mac.h
+++ b/skia/ext/bitmap_platform_device_mac.h
@@ -61,17 +61,19 @@ class BitmapPlatformDevice : public PlatformDevice {
// See warning for copy constructor above.
BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other);
- // PlatformDevice overrides
virtual CGContextRef GetBitmapContext();
- virtual void DrawToNativeContext(CGContextRef context, int x, int y,
- const CGRect* src_rect);
- virtual void MakeOpaque(int x, int y, int width, int height);
- virtual bool IsVectorial();
-
- // SkDevice overrides
virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
const SkClipStack&);
+ virtual void DrawToContext(CGContextRef context, int x, int y,
+ const CGRect* src_rect);
+ virtual void makeOpaque(int x, int y, int width, int height);
+ virtual bool IsVectorial();
+
+ // Returns the color value at the specified location. This does not
+ // consider any transforms that may be set on the device.
+ SkColor getColorAt(int x, int y);
+
protected:
// Reference counted data that can be shared between multiple devices. This
// allows copy constructors and operator= for devices to work properly. The
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc
index dcc395d..5678b9b 100644
--- a/skia/ext/bitmap_platform_device_win.cc
+++ b/skia/ext/bitmap_platform_device_win.cc
@@ -220,8 +220,8 @@ void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
data_->SetMatrixClip(transform, region);
}
-void BitmapPlatformDevice::DrawToNativeContext(HDC dc, int x, int y,
- const RECT* src_rect) {
+void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y,
+ const RECT* src_rect) {
bool created_dc = !data_->IsBitmapDCCreated();
HDC source_dc = BeginPlatformPaint();
@@ -275,6 +275,14 @@ void BitmapPlatformDevice::DrawToNativeContext(HDC dc, int x, int y,
data_->ReleaseBitmapDC();
}
+// Returns the color value at the specified location.
+SkColor BitmapPlatformDevice::getColorAt(int x, int y) {
+ const SkBitmap& bitmap = accessBitmap(false);
+ SkAutoLockPixels lock(bitmap);
+ uint32_t* data = bitmap.getAddr32(0, 0);
+ return static_cast<SkColor>(data[x + y * width()]);
+}
+
void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) {
// FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI
// operation has occurred on our DC.
diff --git a/skia/ext/bitmap_platform_device_win.h b/skia/ext/bitmap_platform_device_win.h
index 7197d16..7f901f5 100644
--- a/skia/ext/bitmap_platform_device_win.h
+++ b/skia/ext/bitmap_platform_device_win.h
@@ -69,21 +69,24 @@ class SK_API BitmapPlatformDevice : public PlatformDevice {
// See warning for copy constructor above.
BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other);
- // PlatformDevice overrides
// Retrieves the bitmap DC, which is the memory DC for our bitmap data. The
// bitmap DC is lazy created.
virtual PlatformSurface BeginPlatformPaint();
virtual void EndPlatformPaint();
- virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect);
- virtual void MakeOpaque(int x, int y, int width, int height);
- virtual bool IsVectorial() { return false; }
-
// Loads the given transform and clipping region into the HDC. This is
// overridden from SkDevice.
virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
const SkClipStack&);
+ virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect);
+ virtual void makeOpaque(int x, int y, int width, int height);
+ virtual bool IsVectorial() { return false; }
+
+ // Returns the color value at the specified location. This does not
+ // consider any transforms that may be set on the device.
+ SkColor getColorAt(int x, int y);
+
protected:
// Flushes the Windows device context so that the pixel data can be accessed
// directly by Skia. Overridden from SkDevice, this is called when Skia
diff --git a/skia/ext/canvas_paint_linux.h b/skia/ext/canvas_paint_linux.h
index 608350f..73d9617 100644
--- a/skia/ext/canvas_paint_linux.h
+++ b/skia/ext/canvas_paint_linux.h
@@ -92,7 +92,7 @@ class CanvasPaintT : public T {
// surface.
T::translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y));
- context_ = BeginPlatformPaint(GetTopDevice(*this));
+ context_ = T::getTopPlatformDevice().BeginPlatformPaint();
}
cairo_t* context_;
diff --git a/skia/ext/canvas_paint_mac.h b/skia/ext/canvas_paint_mac.h
index c4f45b2..6cef9ba 100644
--- a/skia/ext/canvas_paint_mac.h
+++ b/skia/ext/canvas_paint_mac.h
@@ -92,7 +92,7 @@ class CanvasPaintT : public T {
T::translate(-SkDoubleToScalar(rectangle_.origin.x),
-SkDoubleToScalar(rectangle_.origin.y));
- context_ = GetBitmapContext(GetTopDevice(*this));
+ context_ = T::getTopPlatformDevice().GetBitmapContext();
}
CGContext* context_;
diff --git a/skia/ext/canvas_paint_win.h b/skia/ext/canvas_paint_win.h
index 5fe22fc..478f285 100644
--- a/skia/ext/canvas_paint_win.h
+++ b/skia/ext/canvas_paint_win.h
@@ -62,8 +62,9 @@ class CanvasPaintT : public T {
if (!isEmpty()) {
restoreToCount(1);
// Commit the drawing to the screen
- skia::DrawToNativeContext(this, paint_dc_, ps_.rcPaint.left,
- ps_.rcPaint.top, NULL);
+ getTopPlatformDevice().drawToHDC(paint_dc_,
+ ps_.rcPaint.left, ps_.rcPaint.top,
+ NULL);
}
if (for_paint_)
EndPaint(hwnd_, &ps_);
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc
index c6fd17e..c48cce4 100644
--- a/skia/ext/platform_canvas.cc
+++ b/skia/ext/platform_canvas.cc
@@ -7,6 +7,14 @@
#include "skia/ext/bitmap_platform_device.h"
#include "third_party/skia/include/core/SkTypes.h"
+namespace {
+skia::PlatformDevice* GetTopPlatformDevice(const SkCanvas* canvas) {
+ // All of our devices should be our special PlatformDevice.
+ SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false);
+ return static_cast<skia::PlatformDevice*>(iter.device());
+}
+}
+
namespace skia {
PlatformCanvas::PlatformCanvas() {
@@ -21,6 +29,10 @@ SkDevice* PlatformCanvas::setBitmapDevice(const SkBitmap&) {
return NULL;
}
+PlatformDevice& PlatformCanvas::getTopPlatformDevice() const {
+ return *GetTopPlatformDevice(this);
+}
+
// static
size_t PlatformCanvas::StrideForWidth(unsigned width) {
return 4 * width;
@@ -39,32 +51,18 @@ SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque) {
return new PlatformCanvas(width, height, is_opaque);
}
-SkDevice* GetTopDevice(const SkCanvas& canvas) {
- SkCanvas::LayerIter iter(const_cast<SkCanvas*>(&canvas), false);
- return iter.device();
-}
-
bool SupportsPlatformPaint(const SkCanvas* canvas) {
- // TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these
- // calls from WebKit.
- return IsNativeFontRenderingAllowed(GetTopDevice(*canvas));
+ // TODO(alokp): Rename PlatformDevice::IsNativeFontRenderingAllowed after
+ // removing these calls from WebKit.
+ return GetTopPlatformDevice(canvas)->IsNativeFontRenderingAllowed();
}
-PlatformSurface BeginPlatformPaint(SkCanvas* canvas) {
- return BeginPlatformPaint(GetTopDevice(*canvas));
+PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas) {
+ return GetTopPlatformDevice(canvas)->BeginPlatformPaint();
}
void EndPlatformPaint(SkCanvas* canvas) {
- EndPlatformPaint(GetTopDevice(*canvas));
-}
-
-void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, int x,
- int y, const PlatformRect* src_rect) {
- DrawToNativeContext(GetTopDevice(*canvas), context, x, y, src_rect);
-}
-
-void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) {
- MakeOpaque(GetTopDevice(*canvas), x, y, width, height);
+ GetTopPlatformDevice(canvas)->EndPlatformPaint();
}
} // namespace skia
diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h
index 58049e6..24f613a 100644
--- a/skia/ext/platform_canvas.h
+++ b/skia/ext/platform_canvas.h
@@ -63,6 +63,30 @@ class SK_API PlatformCanvas : public SkCanvas {
// Shared --------------------------------------------------------------------
+ // These calls should surround calls to platform drawing routines, the
+ // surface returned here can be used with the native platform routines
+ //
+ // 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() 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
+ // we usually set the clip to new layers when we make them.
+ //
+ // If there is no layer that is not all clipped out, this will return a
+ // dummy device so callers do not have to check. If you are concerned about
+ // performance, check the clip before doing any painting.
+ //
+ // This is different than SkCanvas' getDevice, because that returns the
+ // bottommost device.
+ //
+ // Danger: the resulting device should not be saved. It will be invalidated
+ // by the next call to save() or restore().
+ PlatformDevice& getTopPlatformDevice() const;
+
// Return the stride (length of a line in bytes) for the given width. Because
// we use 32-bits per pixel, this will be roughly 4*width. However, for
// alignment reasons we may wish to increase that.
@@ -85,26 +109,11 @@ class SK_API PlatformCanvas : public SkCanvas {
// CoreGraphics.
virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap);
- // Disallow copy and assign
+ // Disallow copy and assign.
PlatformCanvas(const PlatformCanvas&);
PlatformCanvas& operator=(const PlatformCanvas&);
};
-// Returns the SkDevice pointer of the topmost rect with a non-empty
-// clip. In practice, this is usually either the top layer or nothing, since
-// we usually set the clip to new layers when we make them.
-//
-// If there is no layer that is not all clipped out, this will return a
-// dummy device so callers do not have to check. If you are concerned about
-// performance, check the clip before doing any painting.
-//
-// This is different than SkCanvas' getDevice, because that returns the
-// bottommost device.
-//
-// Danger: the resulting device should not be saved. It will be invalidated
-// by the next call to save() or restore().
-SkDevice* GetTopDevice(const SkCanvas& canvas);
-
// Creates a canvas with raster bitmap backing.
// Set is_opaque if you are going to erase the bitmap and not use
// transparency: this will enable some optimizations.
@@ -115,45 +124,18 @@ SK_API SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque);
// return NULL PlatformSurface.
SK_API bool SupportsPlatformPaint(const SkCanvas* canvas);
-// Draws into the a native platform surface, |context|. Forwards to
-// DrawToNativeContext on a PlatformDevice instance bound to the top device.
-// If no PlatformDevice instance is bound, is a no-operation.
-SK_API void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context,
- int x, int y, const PlatformRect* src_rect);
-
-// Sets the opacity of each pixel in the specified region to be opaque.
-SK_API void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height);
-
// These calls should surround calls to platform drawing routines, the
// surface returned here can be used with the native platform routines.
//
// 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.
-SK_API PlatformSurface BeginPlatformPaint(SkCanvas* canvas);
+//
+// Note: These functions will eventually replace
+// PlatformCanvas::beginPlatformPaint and PlatformCanvas::endPlatformPaint.
+SK_API PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas);
SK_API void EndPlatformPaint(SkCanvas* canvas);
-// Helper class for pairing calls to BeginPlatformPaint and EndPlatformPaint.
-// Upon construction invokes BeginPlatformPaint, and upon destruction invokes
-// EndPlatformPaint.
-class ScopedPlatformPaint {
- public:
- explicit ScopedPlatformPaint(SkCanvas* canvas) : canvas_(canvas) {
- platform_surface_ = BeginPlatformPaint(canvas);
- }
- ~ScopedPlatformPaint() { EndPlatformPaint(canvas_); }
-
- // Returns the PlatformSurface to use for native platform drawing calls.
- PlatformSurface GetPlatformSurface() { return platform_surface_; }
- private:
- SkCanvas* canvas_;
- PlatformSurface platform_surface_;
-
- // Disallow copy and assign
- ScopedPlatformPaint(const ScopedPlatformPaint&);
- ScopedPlatformPaint& operator=(const ScopedPlatformPaint&);
-};
-
} // namespace skia
#endif // SKIA_EXT_PLATFORM_CANVAS_H_
diff --git a/skia/ext/platform_canvas_linux.cc b/skia/ext/platform_canvas_linux.cc
index ea0f0c8..c059544 100644
--- a/skia/ext/platform_canvas_linux.cc
+++ b/skia/ext/platform_canvas_linux.cc
@@ -6,8 +6,8 @@
#include <cairo/cairo.h>
-#include "skia/ext/bitmap_platform_device.h"
-#include "skia/ext/platform_device.h"
+#include "skia/ext/platform_device_linux.h"
+#include "skia/ext/bitmap_platform_device_linux.h"
#include "third_party/skia/include/core/SkTypes.h"
namespace skia {
@@ -33,4 +33,12 @@ bool PlatformCanvas::initialize(int width, int height, bool is_opaque,
width, height, is_opaque, data));
}
+cairo_t* PlatformCanvas::beginPlatformPaint() const {
+ return getTopPlatformDevice().BeginPlatformPaint();
+}
+
+void PlatformCanvas::endPlatformPaint() const {
+ getTopPlatformDevice().EndPlatformPaint();
+}
+
} // namespace skia
diff --git a/skia/ext/platform_canvas_mac.cc b/skia/ext/platform_canvas_mac.cc
index fba49f2..bf6843f 100644
--- a/skia/ext/platform_canvas_mac.cc
+++ b/skia/ext/platform_canvas_mac.cc
@@ -4,7 +4,7 @@
#include "skia/ext/platform_canvas.h"
-#include "skia/ext/bitmap_platform_device.h"
+#include "skia/ext/bitmap_platform_device_mac.h"
#include "third_party/skia/include/core/SkTypes.h"
namespace skia {
@@ -49,4 +49,12 @@ bool PlatformCanvas::initialize(CGContextRef context,
context, width, height, is_opaque));
}
+CGContextRef PlatformCanvas::beginPlatformPaint() const {
+ return getTopPlatformDevice().BeginPlatformPaint();
+}
+
+void PlatformCanvas::endPlatformPaint() const {
+ getTopPlatformDevice().EndPlatformPaint();
+}
+
} // namespace skia
diff --git a/skia/ext/platform_canvas_unittest.cc b/skia/ext/platform_canvas_unittest.cc
index 40cdc70..6e43be2 100644
--- a/skia/ext/platform_canvas_unittest.cc
+++ b/skia/ext/platform_canvas_unittest.cc
@@ -31,8 +31,8 @@ namespace {
bool VerifyRect(const PlatformCanvas& canvas,
uint32_t canvas_color, uint32_t rect_color,
int x, int y, int w, int h) {
- SkDevice* device = skia::GetTopDevice(canvas);
- const SkBitmap& bitmap = device->accessBitmap(false);
+ PlatformDevice& device = canvas.getTopPlatformDevice();
+ const SkBitmap& bitmap = device.accessBitmap(false);
SkAutoLockPixels lock(bitmap);
// For masking out the alpha values.
@@ -70,8 +70,8 @@ bool IsOfColor(const SkBitmap& bitmap, int x, int y, uint32_t color) {
bool VerifyRoundedRect(const PlatformCanvas& canvas,
uint32_t canvas_color, uint32_t rect_color,
int x, int y, int w, int h) {
- SkDevice* device = skia::GetTopDevice(canvas);
- const SkBitmap& bitmap = device->accessBitmap(false);
+ PlatformDevice& device = canvas.getTopPlatformDevice();
+ const SkBitmap& bitmap = device.accessBitmap(false);
SkAutoLockPixels lock(bitmap);
// Check corner points first. They should be of canvas_color.
@@ -103,8 +103,7 @@ bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) {
#if defined(OS_WIN)
void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
- skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
- HDC dc = scoped_platform_paint.GetPlatformSurface();
+ HDC dc = canvas.beginPlatformPaint();
RECT inner_rc;
inner_rc.left = x;
@@ -112,18 +111,21 @@ void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
inner_rc.right = x + w;
inner_rc.bottom = y + h;
FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
+
+ canvas.endPlatformPaint();
}
#elif defined(OS_MACOSX)
void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
- skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
- CGContextRef context = scoped_platform_paint.GetPlatformSurface();
-
+ CGContextRef context = canvas.beginPlatformPaint();
+
CGRect inner_rc = CGRectMake(x, y, w, h);
// RGBA opaque black
CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0);
CGContextSetFillColorWithColor(context, black);
CGColorRelease(black);
CGContextFillRect(context, inner_rc);
+
+ canvas.endPlatformPaint();
}
#else
void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
@@ -242,7 +244,7 @@ TEST(PlatformCanvas, FillLayer) {
LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
DrawNativeRect(canvas, 0, 0, 100, 100);
#if defined(OS_WIN)
- MakeOpaque(&canvas, 0, 0, 100, 100);
+ canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100);
#endif
}
EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH));
@@ -253,7 +255,8 @@ TEST(PlatformCanvas, FillLayer) {
LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
#if defined(OS_WIN)
- MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY,
+ kInnerW, kInnerH);
#endif
}
EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH));
@@ -266,7 +269,8 @@ TEST(PlatformCanvas, FillLayer) {
AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
DrawNativeRect(canvas, 0, 0, 100, 100);
#if defined(OS_WIN)
- MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ canvas.getTopPlatformDevice().makeOpaque(
+ kInnerX, kInnerY, kInnerW, kInnerH);
#endif
canvas.restore();
}
@@ -280,7 +284,7 @@ TEST(PlatformCanvas, FillLayer) {
LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
DrawNativeRect(canvas, 0, 0, 100, 100);
#if defined(OS_WIN)
- MakeOpaque(&canvas, 0, 0, 100, 100);
+ canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100);
#endif
}
canvas.restore();
@@ -301,7 +305,7 @@ TEST(PlatformCanvas, TranslateLayer) {
LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
DrawNativeRect(canvas, 0, 0, 100, 100);
#if defined(OS_WIN)
- MakeOpaque(&canvas, 0, 0, 100, 100);
+ canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100);
#endif
}
canvas.restore();
@@ -316,7 +320,8 @@ TEST(PlatformCanvas, TranslateLayer) {
LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
#if defined(OS_WIN)
- MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY,
+ kInnerW, kInnerH);
#endif
}
canvas.restore();
@@ -331,7 +336,8 @@ TEST(PlatformCanvas, TranslateLayer) {
canvas.translate(1, 1);
DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
#if defined(OS_WIN)
- MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY,
+ kInnerW, kInnerH);
#endif
}
canvas.restore();
@@ -349,7 +355,8 @@ TEST(PlatformCanvas, TranslateLayer) {
AddClip(canvas, kInnerX + 1, kInnerY + 1, kInnerW - 1, kInnerH - 1);
DrawNativeRect(canvas, 0, 0, 100, 100);
#if defined(OS_WIN)
- MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ canvas.getTopPlatformDevice().makeOpaque(kLayerX, kLayerY,
+ kLayerW, kLayerH);
#endif
}
canvas.restore();
@@ -377,7 +384,8 @@ TEST(PlatformCanvas, TranslateLayer) {
DrawNativeRect(canvas, 0, 0, 100, 100);
#if defined(OS_WIN)
- MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ canvas.getTopPlatformDevice().makeOpaque(kLayerX, kLayerY,
+ kLayerW, kLayerH);
#endif
}
canvas.restore();
diff --git a/skia/ext/platform_canvas_win.cc b/skia/ext/platform_canvas_win.cc
index 116ba66..a6381ed 100644
--- a/skia/ext/platform_canvas_win.cc
+++ b/skia/ext/platform_canvas_win.cc
@@ -106,4 +106,12 @@ bool PlatformCanvas::initialize(int width,
width, height, is_opaque, shared_section));
}
+HDC PlatformCanvas::beginPlatformPaint() const {
+ return getTopPlatformDevice().BeginPlatformPaint();
+}
+
+void PlatformCanvas::endPlatformPaint() const {
+ return getTopPlatformDevice().EndPlatformPaint();
+}
+
} // namespace skia
diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc
deleted file mode 100644
index eff5d4f..0000000
--- a/skia/ext/platform_device.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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.
-
-#include "skia/ext/platform_device.h"
-
-#include "third_party/skia/include/core/SkMetaData.h"
-
-namespace skia {
-
-namespace {
-const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour";
-}
-
-void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) {
- SkMetaData& meta_data = device->getMetaData();
- meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour);
-}
-
-PlatformDevice* GetPlatformDevice(SkDevice* device) {
- SkMetaData& meta_data = device->getMetaData();
- PlatformDevice* device_behaviour = NULL;
- if (meta_data.findPtr(kDevicePlatformBehaviour,
- reinterpret_cast<void**>(&device_behaviour)))
- return device_behaviour;
-
- return NULL;
-}
-
-PlatformSurface BeginPlatformPaint(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->BeginPlatformPaint();
-
- return 0;
-}
-
-void EndPlatformPaint(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->EndPlatformPaint();
-}
-
-bool IsVectorial(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->IsVectorial();
-
- return device->getDeviceCapabilities() & SkDevice::kVector_Capability;
-}
-
-bool IsNativeFontRenderingAllowed(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->IsNativeFontRenderingAllowed();
-
- return false;
-}
-
-void DrawToNativeContext(SkDevice* device, PlatformSurface context,
- int x, int y, const PlatformRect* src_rect) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- platform_device->DrawToNativeContext(context, x, y, src_rect);
-}
-
-void MakeOpaque(SkDevice* device, int x, int y, int width, int height) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- platform_device->MakeOpaque(x, y, width, height);
-}
-
-} // namespace skia
-
diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h
index 4f876d9..971c0a7 100644
--- a/skia/ext/platform_device.h
+++ b/skia/ext/platform_device.h
@@ -10,81 +10,6 @@
// header file for your platform.
#if defined(WIN32)
-#include <windows.h>
-#endif
-
-#include "third_party/skia/include/core/SkPreConfig.h"
-#include "third_party/skia/include/core/SkColor.h"
-
-
-class SkDevice;
-struct SkIRect;
-
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-typedef struct _cairo cairo_t;
-typedef struct _cairo_rectangle cairo_rectangle_t;
-#elif defined(__APPLE__)
-typedef struct CGContext* CGContextRef;
-typedef struct CGRect CGRect;
-#endif
-
-namespace skia {
-
-class PlatformDevice;
-
-#if defined(WIN32)
-typedef HDC PlatformSurface;
-typedef RECT PlatformRect;
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-typedef cairo_t* PlatformSurface;
-typedef cairo_rectangle_t PlatformRect;
-#elif defined(__APPLE__)
-typedef CGContextRef PlatformSurface;
-typedef CGRect PlatformRect;
-#endif
-
-// The following routines provide accessor points for the functionality
-// exported by the various PlatformDevice ports. The PlatformDevice, and
-// BitmapPlatformDevice classes inherit directly from SkDevice, which is no
-// longer a supported usage-pattern for skia. In preparation of the removal of
-// these classes, all calls to PlatformDevice::* should be routed through these
-// helper functions.
-
-// Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent
-// calls to the functions exported below will forward the request to the
-// corresponding method on the bound PlatformDevice instance. If no
-// PlatformDevice has been bound to the SkDevice passed, then the routines are
-// NOPS.
-SK_API void SetPlatformDevice(SkDevice* device,
- PlatformDevice* platform_device);
-SK_API PlatformDevice* GetPlatformDevice(SkDevice* device);
-
-// Returns if the preferred rendering engine is vectorial or bitmap based.
-// Forwards to PlatformDevice::IsVectorial, if a PlatformDevice is bound,
-// otherwise falls-back to the SkDevice::getDeviceCapabilities routine.
-SK_API bool IsVectorial(SkDevice* device);
-
-// Returns if the native font rendering engine is allowed to render text to
-// this device.
-SK_API bool IsNativeFontRenderingAllowed(SkDevice* device);
-
-// Returns the PlatformSurface used for native rendering into the device.
-SK_API PlatformSurface BeginPlatformPaint(SkDevice* device);
-
-// Finish a previous call to BeginPlatformPaint.
-SK_API void EndPlatformPaint(SkDevice* device);
-
-// Draws to the given PlatformSurface, |context|. Forwards to the
-// PlatformDevice bound to |device|. Otherwise is a NOP.
-SK_API void DrawToNativeContext(SkDevice* device, PlatformSurface context,
- int x, int y, const PlatformRect* src_rect);
-
-// Sets the opacity of each pixel in the specified region to be opaque.
-SK_API void MakeOpaque(SkDevice* device, int x, int y, int width, int height);
-
-} // namespace skia
-
-#if defined(WIN32)
#include "skia/ext/platform_device_win.h"
#elif defined(__APPLE__)
#include "skia/ext/platform_device_mac.h"
diff --git a/skia/ext/platform_device_linux.cc b/skia/ext/platform_device_linux.cc
index 675d19f..b943120 100644
--- a/skia/ext/platform_device_linux.cc
+++ b/skia/ext/platform_device_linux.cc
@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "skia/ext/platform_device.h"
+#include "skia/ext/platform_device_linux.h"
namespace skia {
PlatformDevice::PlatformDevice(const SkBitmap& bitmap)
: SkDevice(NULL, bitmap, /*isForLayer=*/false) {
- SetPlatformDevice(this, this);
}
bool PlatformDevice::IsNativeFontRenderingAllowed() {
@@ -19,10 +18,4 @@ void PlatformDevice::EndPlatformPaint() {
// We don't need to do anything on Linux here.
}
-void PlatformDevice::DrawToNativeContext(PlatformSurface surface, int x, int y,
- const PlatformRect* src_rect) {
- // Should never be called on Linux.
- SkASSERT(false);
-}
-
} // namespace skia
diff --git a/skia/ext/platform_device_linux.h b/skia/ext/platform_device_linux.h
index d10d795..718560c 100644
--- a/skia/ext/platform_device_linux.h
+++ b/skia/ext/platform_device_linux.h
@@ -6,9 +6,10 @@
#define SKIA_EXT_PLATFORM_DEVICE_LINUX_H_
#pragma once
-#include "skia/ext/platform_device.h"
#include "third_party/skia/include/core/SkDevice.h"
+typedef struct _cairo cairo_t;
+
namespace skia {
// Blindly copying the mac hierarchy.
@@ -25,12 +26,6 @@ class PlatformDevice : public SkDevice {
virtual PlatformSurface BeginPlatformPaint() = 0;
virtual void EndPlatformPaint();
- virtual void DrawToNativeContext(PlatformSurface surface, int x, int y,
- const PlatformRect* src_rect );
-
- // Sets the opacity of each pixel in the specified region to be opaque.
- virtual void MakeOpaque(int x, int y, int width, int height) { }
-
protected:
// Forwards |bitmap| to SkDevice's constructor.
explicit PlatformDevice(const SkBitmap& bitmap);
diff --git a/skia/ext/platform_device_mac.cc b/skia/ext/platform_device_mac.cc
index da66dbe..73e814e 100644
--- a/skia/ext/platform_device_mac.cc
+++ b/skia/ext/platform_device_mac.cc
@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "skia/ext/platform_device.h"
-#include "skia/ext/bitmap_platform_device.h"
+#include "skia/ext/bitmap_platform_device_mac.h"
#import <ApplicationServices/ApplicationServices.h>
#include "skia/ext/skia_utils_mac.h"
@@ -14,17 +13,28 @@
namespace skia {
-CGContextRef GetBitmapContext(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->GetBitmapContext();
+namespace {
- return NULL;
+// Constrains position and size to fit within available_size.
+bool constrain(int available_size, int* position, int *size) {
+ if (*position < 0) {
+ *size += *position;
+ *position = 0;
+ }
+ if (*size > 0 && *position < available_size) {
+ int overflow = (*position + *size) - available_size;
+ if (overflow > 0) {
+ *size -= overflow;
+ }
+ return true;
+ }
+ return false;
}
+} // namespace
+
PlatformDevice::PlatformDevice(const SkBitmap& bitmap)
: SkDevice(NULL, bitmap, /*isForLayer=*/false) {
- SetPlatformDevice(this, this);
}
bool PlatformDevice::IsNativeFontRenderingAllowed() {
diff --git a/skia/ext/platform_device_mac.h b/skia/ext/platform_device_mac.h
index 0aa8d9d..b65d791 100644
--- a/skia/ext/platform_device_mac.h
+++ b/skia/ext/platform_device_mac.h
@@ -17,10 +17,6 @@ class SkRegion;
namespace skia {
-// Returns the CGContext that backing the SkDevice. Forwards to the bound
-// PlatformDevice. Returns NULL if no PlatformDevice is bound.
-CGContextRef GetBitmapContext(SkDevice* device);
-
// A device is basically a wrapper around SkBitmap that provides a surface for
// SkCanvas to draw into. Our device provides a surface CoreGraphics can also
// write to. It also provides functionality to play well with CG drawing
@@ -41,11 +37,8 @@ class PlatformDevice : public SkDevice {
// context, it will be more efficient if you don't free it until after this
// call so it doesn't have to be created twice. If src_rect is null, then
// the entirety of the source device will be copied.
- virtual void DrawToNativeContext(CGContextRef context, int x, int y,
- const CGRect* src_rect) = 0;
-
- // Sets the opacity of each pixel in the specified region to be opaque.
- virtual void MakeOpaque(int x, int y, int width, int height) { }
+ virtual void DrawToContext(CGContextRef context, int x, int y,
+ const CGRect* src_rect) = 0;
// Returns if the preferred rendering engine is vectorial or bitmap based.
virtual bool IsVectorial() = 0;
diff --git a/skia/ext/platform_device_win.cc b/skia/ext/platform_device_win.cc
index 7fbb746..dd79ab3 100644
--- a/skia/ext/platform_device_win.cc
+++ b/skia/ext/platform_device_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "skia/ext/platform_device.h"
+#include "skia/ext/platform_device_win.h"
#include "skia/ext/skia_utils_win.h"
#include "third_party/skia/include/core/SkMatrix.h"
@@ -12,7 +12,17 @@
namespace skia {
-void InitializeDC(HDC context) {
+PlatformDevice::PlatformDevice(const SkBitmap& bitmap)
+ : SkDevice(NULL, bitmap, /*isForLayer=*/false) {
+}
+
+void PlatformDevice::EndPlatformPaint() {
+ // We don't clear the DC here since it will be likely to be used again.
+ // Flushing will be done in onAccessBitmap.
+}
+
+// static
+void PlatformDevice::InitializeDC(HDC context) {
// Enables world transformation.
// If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the
// counterclockwise direction in logical space. This is equivalent to the
@@ -51,16 +61,6 @@ void InitializeDC(HDC context) {
SkASSERT(res != 0);
}
-PlatformDevice::PlatformDevice(const SkBitmap& bitmap)
- : SkDevice(NULL, bitmap, /*isForLayer=*/false) {
- SetPlatformDevice(this, this);
-}
-
-void PlatformDevice::EndPlatformPaint() {
- // We don't clear the DC here since it will be likely to be used again.
- // Flushing will be done in onAccessBitmap.
-}
-
// static
void PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) {
switch (path.getFillType()) {
diff --git a/skia/ext/platform_device_win.h b/skia/ext/platform_device_win.h
index 2452fc2..5523ef9 100644
--- a/skia/ext/platform_device_win.h
+++ b/skia/ext/platform_device_win.h
@@ -18,9 +18,6 @@ class SkRegion;
namespace skia {
-// Initializes the default settings and colors in a device context.
-SK_API void InitializeDC(HDC context);
-
// A device is basically a wrapper around SkBitmap that provides a surface for
// SkCanvas to draw into. Our device provides a surface Windows can also write
// to. It also provides functionality to play well with GDI drawing functions.
@@ -43,11 +40,10 @@ class SK_API PlatformDevice : public SkDevice {
// be more efficient if you don't free it until after this call so it doesn't
// have to be created twice. If src_rect is null, then the entirety of the
// source device will be copied.
- virtual void DrawToNativeContext(HDC dc, int x, int y,
- const RECT* src_rect) = 0;
+ virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect) = 0;
// Sets the opacity of each pixel in the specified region to be opaque.
- virtual void MakeOpaque(int x, int y, int width, int height) { }
+ virtual void makeOpaque(int x, int y, int width, int height) { }
// Returns if the preferred rendering engine is vectorial or bitmap based.
virtual bool IsVectorial() = 0;
@@ -55,6 +51,9 @@ class SK_API PlatformDevice : public SkDevice {
// Returns if GDI is allowed to render text to this device.
virtual bool IsNativeFontRenderingAllowed() { return true; }
+ // Initializes the default settings and colors in a device context.
+ static void InitializeDC(HDC context);
+
// Loads a SkPath into the GDI context. The path can there after be used for
// clipping or as a stroke.
static void LoadPathToDC(HDC context, const SkPath& path);
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index 3c955bb..ecb30ca 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -193,10 +193,10 @@ SkBitmap CGImageToSkBitmap(CGImageRef image) {
int width = CGImageGetWidth(image);
int height = CGImageGetHeight(image);
- scoped_ptr<SkDevice> device(
+ scoped_ptr<skia::BitmapPlatformDevice> device(
skia::BitmapPlatformDevice::Create(NULL, width, height, false));
- CGContextRef context = skia::GetBitmapContext(device.get());
+ CGContextRef context = device->GetBitmapContext();
// We need to invert the y-axis of the canvas so that Core Graphics drawing
// happens right-side up. Skia has an upper-left origin and CG has a lower-
diff --git a/skia/ext/vector_canvas.cc b/skia/ext/vector_canvas.cc
index dbf303f..524ebbc 100644
--- a/skia/ext/vector_canvas.cc
+++ b/skia/ext/vector_canvas.cc
@@ -3,11 +3,10 @@
// found in the LICENSE file.
#include "skia/ext/vector_canvas.h"
-#include "third_party/skia/include/core/SkDevice.h"
namespace skia {
-VectorCanvas::VectorCanvas(SkDevice* device)
+VectorCanvas::VectorCanvas(PlatformDevice* device)
: PlatformCanvas(device->getDeviceFactory()) {
setDevice(device)->unref(); // Created with refcount 1, and setDevice refs.
}
@@ -31,7 +30,7 @@ SkDrawFilter* VectorCanvas::setDrawFilter(SkDrawFilter* filter) {
}
bool VectorCanvas::IsTopDeviceVectorial() const {
- return IsVectorial(GetTopDevice(*this));
+ return getTopPlatformDevice().IsVectorial();
}
} // namespace skia
diff --git a/skia/ext/vector_canvas.h b/skia/ext/vector_canvas.h
index aac0400..4b4419d 100644
--- a/skia/ext/vector_canvas.h
+++ b/skia/ext/vector_canvas.h
@@ -8,10 +8,10 @@
#include "skia/ext/platform_canvas.h"
-class SkDevice;
-
namespace skia {
+class PlatformDevice;
+
// This class is a specialization of the regular PlatformCanvas. It is designed
// to work with a VectorDevice to manage platform-specific drawing. It allows
// using both Skia operations and platform-specific operations. It *doesn't*
@@ -19,7 +19,7 @@ namespace skia {
class SK_API VectorCanvas : public PlatformCanvas {
public:
// Ownership of |device| is transfered to VectorCanvas.
- explicit VectorCanvas(SkDevice* device);
+ explicit VectorCanvas(PlatformDevice* device);
virtual ~VectorCanvas();
virtual SkBounder* setBounder(SkBounder* bounder);
diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc
index 627c1d9..ec8fb38 100644
--- a/skia/ext/vector_canvas_unittest.cc
+++ b/skia/ext/vector_canvas_unittest.cc
@@ -96,11 +96,10 @@ class Image {
}
// Loads the image from a canvas.
- Image(skia::PlatformCanvas& canvas) : ignore_alpha_(true) {
+ 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.
- skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
- HDC context = scoped_platform_paint.GetPlatformSurface();
+ HDC context = canvas.beginPlatformPaint();
HGDIOBJ bitmap = GetCurrentObject(context, OBJ_BITMAP);
EXPECT_TRUE(bitmap != NULL);
// Initialize the clip region to the entire bitmap.
@@ -112,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.
@@ -267,7 +267,7 @@ class ImageTest : public testing::Test {
// kGenerating value. Returns 0 on success or any positive value between ]0,
// 100] on failure. The return value is the percentage of difference between
// the image in the file and the image in the canvas.
- double ProcessCanvas(skia::PlatformCanvas& canvas,
+ double ProcessCanvas(const skia::PlatformCanvas& canvas,
FilePath::StringType filename) const {
filename = filename + FILE_PATH_LITERAL(".png");
switch (action_) {
@@ -286,7 +286,7 @@ class ImageTest : public testing::Test {
// Compares the bitmap currently loaded in the context with the file. Returns
// the percentage of pixel difference between both images, between 0 and 100.
- double CompareImage(skia::PlatformCanvas& canvas,
+ double CompareImage(const skia::PlatformCanvas& canvas,
const FilePath::StringType& filename) const {
Image image1(canvas);
Image image2(test_file(filename));
@@ -295,7 +295,7 @@ class ImageTest : public testing::Test {
}
// Saves the bitmap currently loaded in the context into the file.
- void SaveImage(skia::PlatformCanvas& canvas,
+ void SaveImage(const skia::PlatformCanvas& canvas,
const FilePath::StringType& filename) const {
Image(canvas).SaveToFile(test_file(filename));
}
diff --git a/skia/ext/vector_platform_device_emf_win.cc b/skia/ext/vector_platform_device_emf_win.cc
index 8b181bf..d13ee4d 100644
--- a/skia/ext/vector_platform_device_emf_win.cc
+++ b/skia/ext/vector_platform_device_emf_win.cc
@@ -435,8 +435,8 @@ void VectorPlatformDeviceEmf::setMatrixClip(const SkMatrix& transform,
LoadClipRegion();
}
-void VectorPlatformDeviceEmf::DrawToNativeContext(HDC dc, int x, int y,
- const RECT* src_rect) {
+void VectorPlatformDeviceEmf::drawToHDC(HDC dc, int x, int y,
+ const RECT* src_rect) {
SkASSERT(false);
}
diff --git a/skia/ext/vector_platform_device_emf_win.h b/skia/ext/vector_platform_device_emf_win.h
index 1a27041..4662475 100644
--- a/skia/ext/vector_platform_device_emf_win.h
+++ b/skia/ext/vector_platform_device_emf_win.h
@@ -73,7 +73,7 @@ class VectorPlatformDeviceEmf : public PlatformDevice {
virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
const SkClipStack&);
- virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect);
+ virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect);
virtual bool IsVectorial() { return true; }
void LoadClipRegion();
diff --git a/skia/ext/vector_platform_device_skia.cc b/skia/ext/vector_platform_device_skia.cc
index ab99873..9421b0b 100644
--- a/skia/ext/vector_platform_device_skia.cc
+++ b/skia/ext/vector_platform_device_skia.cc
@@ -209,10 +209,10 @@ void VectorPlatformDeviceSkia::drawDevice(const SkDraw& draw,
}
#if defined(OS_WIN)
-void VectorPlatformDeviceSkia::DrawToNativeContext(HDC dc,
- int x,
- int y,
- const RECT* src_rect) {
+void VectorPlatformDeviceSkia::drawToHDC(HDC dc,
+ int x,
+ int y,
+ const RECT* src_rect) {
SkASSERT(false);
}
#endif
diff --git a/skia/ext/vector_platform_device_skia.h b/skia/ext/vector_platform_device_skia.h
index 4a126e5..53c711d 100644
--- a/skia/ext/vector_platform_device_skia.h
+++ b/skia/ext/vector_platform_device_skia.h
@@ -84,7 +84,7 @@ class VectorPlatformDeviceSkia : public PlatformDevice {
const SkPaint&);
#if defined(OS_WIN)
- virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect);
+ virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect);
#endif
protected:
diff --git a/skia/skia.gyp b/skia/skia.gyp
index 1d0531b..a93d075 100644
--- a/skia/skia.gyp
+++ b/skia/skia.gyp
@@ -661,12 +661,11 @@
'ext/image_operations.cc',
'ext/image_operations.h',
'ext/SkThread_chrome.cc',
- 'ext/platform_canvas.cc',
'ext/platform_canvas.h',
+ 'ext/platform_canvas.cc',
'ext/platform_canvas_linux.cc',
'ext/platform_canvas_mac.cc',
'ext/platform_canvas_win.cc',
- 'ext/platform_device.cc',
'ext/platform_device.h',
'ext/platform_device_linux.cc',
'ext/platform_device_linux.h',