summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/gfx/bitmap_platform_device_win.h2
-rw-r--r--base/gfx/platform_canvas_win.h2
-rw-r--r--base/gfx/platform_device_win.h2
-rw-r--r--base/gfx/vector_device.h2
-rwxr-xr-xchrome/chrome.sln1
-rw-r--r--skia/SConscript6
-rw-r--r--skia/ext/bitmap_platform_device_win.cc (renamed from webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.cpp)2
-rw-r--r--skia/ext/bitmap_platform_device_win.h (renamed from webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.h)6
-rw-r--r--skia/ext/platform_canvas_unittest.cc296
-rw-r--r--skia/ext/platform_canvas_win.cc (renamed from webkit/port/platform/graphics/skia/public/PlatformCanvasWin.cpp)5
-rw-r--r--skia/ext/platform_canvas_win.h (renamed from webkit/port/platform/graphics/skia/public/PlatformCanvasWin.h)8
-rw-r--r--skia/ext/platform_device.h27
-rw-r--r--skia/ext/platform_device_win.cc (renamed from webkit/port/platform/graphics/skia/public/PlatformDeviceWin.cpp)2
-rw-r--r--skia/ext/platform_device_win.h (renamed from webkit/port/platform/graphics/skia/public/PlatformDeviceWin.h)6
-rw-r--r--skia/ext/vector_canvas.cc (renamed from webkit/port/platform/graphics/skia/public/VectorCanvas.cpp)0
-rw-r--r--skia/ext/vector_canvas.h (renamed from webkit/port/platform/graphics/skia/public/VectorCanvas.h)0
-rw-r--r--skia/ext/vector_canvas_unittest.cc (renamed from webkit/port/platform/graphics/skia/public/VectorCanvas_unittest.cpp)2
-rw-r--r--skia/ext/vector_device.cc612
-rw-r--r--skia/ext/vector_device.h119
-rw-r--r--skia/skia.vcproj56
-rw-r--r--webkit/SConscript.port6
-rw-r--r--webkit/build/port/port.vcproj60
-rw-r--r--webkit/port/platform/graphics/skia/public/BitmapPlatformDevice.h2
-rw-r--r--webkit/port/platform/graphics/skia/public/PlatformCanvas.h2
-rw-r--r--webkit/port/platform/graphics/skia/public/PlatformDevice.h2
-rw-r--r--webkit/tools/test_shell/test_shell_tests.vcproj4
26 files changed, 1140 insertions, 92 deletions
diff --git a/base/gfx/bitmap_platform_device_win.h b/base/gfx/bitmap_platform_device_win.h
index 566e302..5adfa34 100644
--- a/base/gfx/bitmap_platform_device_win.h
+++ b/base/gfx/bitmap_platform_device_win.h
@@ -7,7 +7,7 @@
// TODO(brettw) this file should be removed and the includes changed to this
// new location.
-#include "webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.h"
+#include "skia/ext/bitmap_platform_device_win.h"
#endif // BASE_GFX_BITMAP_PLATFORM_DEVICE_WIN_H_
diff --git a/base/gfx/platform_canvas_win.h b/base/gfx/platform_canvas_win.h
index 8bd285b..3af1c0d 100644
--- a/base/gfx/platform_canvas_win.h
+++ b/base/gfx/platform_canvas_win.h
@@ -7,7 +7,7 @@
// TODO(brettw) this file should be removed and the includes changed to this
// new location.
-#include "webkit/port/platform/graphics/skia/public/PlatformCanvasWin.h"
+#include "skia/ext/platform_canvas_win.h"
#endif // BASE_GFX_PLATFORM_CANVAS_WIN_H_
diff --git a/base/gfx/platform_device_win.h b/base/gfx/platform_device_win.h
index e39dfe1..3851e60 100644
--- a/base/gfx/platform_device_win.h
+++ b/base/gfx/platform_device_win.h
@@ -7,7 +7,7 @@
// TODO(brettw) this file should be removed and the includes changed to this
// new location.
-#include "webkit/port/platform/graphics/skia/public/PlatformDeviceWin.h"
+#include "skia/ext/platform_device_win.h"
#endif // BASE_GFX_PLATFORM_DEVICE_WIN_H__
diff --git a/base/gfx/vector_device.h b/base/gfx/vector_device.h
index 55fe22e..8ba1724 100644
--- a/base/gfx/vector_device.h
+++ b/base/gfx/vector_device.h
@@ -4,4 +4,4 @@
// TODO(brettw) this file should be removed and the includes changed to this
// new location.
-#include "webkit/port/platform/graphics/skia/public/VectorDevice.h"
+#include "skia/ext/vector_device.h"
diff --git a/chrome/chrome.sln b/chrome/chrome.sln
index 9e06cda..9250e84 100755
--- a/chrome/chrome.sln
+++ b/chrome/chrome.sln
@@ -573,7 +573,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ui_tests", "test\ui\ui_test
{1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165}
{2A70CBF0-847E-4E3A-B926-542A656DC7FE} = {2A70CBF0-847E-4E3A-B926-542A656DC7FE}
{326E9795-E760-410A-B69A-3F79DB3F5243} = {326E9795-E760-410A-B69A-3F79DB3F5243}
- {5597AD47-3494-4750-A235-4F9C2F864700} = {5597AD47-3494-4750-A235-4F9C2F864700}
{5BF908A7-68FB-4A4B-99E3-8C749F1FE4EA} = {5BF908A7-68FB-4A4B-99E3-8C749F1FE4EA}
{7100F41F-868D-4E99-80A2-AF8E6574749D} = {7100F41F-868D-4E99-80A2-AF8E6574749D}
{7B219FAA-E360-43C8-B341-804A94EEFFAC} = {7B219FAA-E360-43C8-B341-804A94EEFFAC}
diff --git a/skia/SConscript b/skia/SConscript
index 95fa1b1..ad1f194 100644
--- a/skia/SConscript
+++ b/skia/SConscript
@@ -173,6 +173,12 @@ if env['PLATFORM'] == 'darwin':
input_files.append('ext/platform_device_mac.cc')
if env['PLATFORM'] == 'win32':
+ input_files.append('ext/bitmap_platform_device_win.cc')
+ input_files.append('ext/platform_canvas_win.cc')
+ input_files.append('ext/platform_device_win.cc')
+ input_files.append('ext/vector_canvas.cc')
+ input_files.append('ext/vector_device.cc')
+
input_files.append('ports/SkThread_win.cpp')
env_p = env.Clone(
diff --git a/webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.cpp b/skia/ext/bitmap_platform_device_win.cc
index ceed2c8..63efc8f 100644
--- a/webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.cpp
+++ b/skia/ext/bitmap_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 "BitmapPlatformDeviceWin.h"
+#include "skia/ext/bitmap_platform_device_win.h"
#include "base/gfx/gdi_util.h"
#include "base/logging.h"
diff --git a/webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.h b/skia/ext/bitmap_platform_device_win.h
index 24008d4..49b72a4 100644
--- a/webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceWin.h
+++ b/skia/ext/bitmap_platform_device_win.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BitmapPlatformDeviceWin_h
-#define BitmapPlatformDeviceWin_h
+#ifndef SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_
+#define SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_
#include "base/gfx/platform_device_win.h"
#include "base/ref_counted.h"
@@ -107,5 +107,5 @@ class BitmapPlatformDeviceWin : public PlatformDeviceWin {
} // namespace gfx
-#endif // BASE_GFX_BITMAP_PLATFORM_DEVICE_WIN_H_
+#endif // SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_
diff --git a/skia/ext/platform_canvas_unittest.cc b/skia/ext/platform_canvas_unittest.cc
new file mode 100644
index 0000000..8e227ad
--- /dev/null
+++ b/skia/ext/platform_canvas_unittest.cc
@@ -0,0 +1,296 @@
+// Copyright (c) 2006-2008 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.
+
+// TODO(awalker): clean up the const/non-const reference handling in this test
+
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
+#include "base/gfx/platform_canvas.h"
+#include "base/gfx/platform_device.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "SkColor.h"
+
+namespace gfx {
+
+namespace {
+
+// Return true if the canvas is filled to canvas_color,
+// and contains a single rectangle filled to rect_color.
+bool VerifyRect(const PlatformCanvas& canvas,
+ uint32_t canvas_color, uint32_t rect_color,
+ int x, int y, int w, int h) {
+ PlatformDevice& device = canvas.getTopPlatformDevice();
+ const SkBitmap& bitmap = device.accessBitmap(false);
+ SkAutoLockPixels lock(bitmap);
+
+ for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) {
+ for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) {
+ if (cur_x >= x && cur_x < x + w &&
+ cur_y >= y && cur_y < y + h) {
+ // Inside the square should be rect_color
+ if (*bitmap.getAddr32(cur_x, cur_y) != rect_color)
+ return false;
+ } else {
+ // Outside the square should be canvas_color
+ if (*bitmap.getAddr32(cur_x, cur_y) != canvas_color)
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+// Checks whether there is a white canvas with a black square at the given
+// location in pixels (not in the canvas coordinate system).
+// TODO(ericroman): rename Square to Rect
+bool VerifyBlackSquare(const PlatformCanvas& canvas, int x, int y, int w, int h) {
+ return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h);
+}
+
+// Check that every pixel in the canvas is a single color.
+bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) {
+ return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0);
+}
+
+#if defined(OS_WIN)
+void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
+ HDC dc = canvas.beginPlatformPaint();
+
+ RECT inner_rc;
+ inner_rc.left = x;
+ inner_rc.top = y;
+ 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) {
+ 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) {
+ NOTIMPLEMENTED();
+}
+#endif
+
+// Clips the contents of the canvas to the given rectangle. This will be
+// intersected with any existing clip.
+void AddClip(PlatformCanvas& canvas, int x, int y, int w, int h) {
+ SkRect rect;
+ rect.set(SkIntToScalar(x), SkIntToScalar(y),
+ SkIntToScalar(x + w), SkIntToScalar(y + h));
+ canvas.clipRect(rect);
+}
+
+class LayerSaver {
+ public:
+ LayerSaver(PlatformCanvas& canvas, int x, int y, int w, int h)
+ : canvas_(canvas),
+ x_(x),
+ y_(y),
+ w_(w),
+ h_(h) {
+ SkRect bounds;
+ bounds.set(SkIntToScalar(x_), SkIntToScalar(y_),
+ SkIntToScalar(right()), SkIntToScalar(bottom()));
+ canvas_.saveLayer(&bounds, NULL);
+ }
+
+ ~LayerSaver() {
+ canvas_.getTopPlatformDevice().fixupAlphaBeforeCompositing();
+ canvas_.restore();
+ }
+
+ int x() const { return x_; }
+ int y() const { return y_; }
+ int w() const { return w_; }
+ int h() const { return h_; }
+
+ // Returns the EXCLUSIVE far bounds of the layer.
+ int right() const { return x_ + w_; }
+ int bottom() const { return y_ + h_; }
+
+ private:
+ PlatformCanvas& canvas_;
+ int x_, y_, w_, h_;
+};
+
+// Size used for making layers in many of the below tests.
+const int kLayerX = 2;
+const int kLayerY = 3;
+const int kLayerW = 9;
+const int kLayerH = 7;
+
+// Size used by some tests to draw a rectangle inside the layer.
+const int kInnerX = 4;
+const int kInnerY = 5;
+const int kInnerW = 2;
+const int kInnerH = 3;
+
+}
+
+// This just checks that our checking code is working properly, it just uses
+// regular skia primitives.
+TEST(PlatformCanvas, SkLayer) {
+ // Create the canvas initialized to opaque white.
+ PlatformCanvas canvas(16, 16, true);
+ canvas.drawColor(SK_ColorWHITE);
+
+ // Make a layer and fill it completely to make sure that the bounds are
+ // correct.
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ canvas.drawColor(SK_ColorBLACK);
+ }
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX, kLayerY, kLayerW, kLayerH));
+}
+
+// Test native clipping.
+TEST(PlatformCanvas, ClipRegion) {
+ // Initialize a white canvas
+ PlatformCanvas canvas(16, 16, true);
+ canvas.drawColor(SK_ColorWHITE);
+ EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE));
+
+ // Test that initially the canvas has no clip region, by filling it
+ // with a black rectangle.
+ // Note: Don't use LayerSaver, since internally it sets a clip region.
+ DrawNativeRect(canvas, 0, 0, 16, 16);
+ canvas.getTopPlatformDevice().fixupAlphaBeforeCompositing();
+ EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK));
+
+ // Test that intersecting disjoint clip rectangles sets an empty clip region
+ canvas.drawColor(SK_ColorWHITE);
+ EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE));
+ {
+ LayerSaver layer(canvas, 0, 0, 16, 16);
+ AddClip(canvas, 2, 3, 4, 5);
+ AddClip(canvas, 4, 9, 10, 10);
+ DrawNativeRect(canvas, 0, 0, 16, 16);
+ }
+ EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE));
+}
+
+// Test the layers get filled properly by native rendering.
+TEST(PlatformCanvas, FillLayer) {
+ // Create the canvas initialized to opaque white.
+ PlatformCanvas canvas(16, 16, true);
+
+ // Make a layer and fill it completely to make sure that the bounds are
+ // correct.
+ canvas.drawColor(SK_ColorWHITE);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ DrawNativeRect(canvas, 0, 0, 100, 100);
+ }
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX, kLayerY, kLayerW, kLayerH));
+
+ // Make a layer and fill it partially to make sure the translation is correct.
+ canvas.drawColor(SK_ColorWHITE);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ }
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH));
+
+ // Add a clip on the layer and fill to make sure clip is correct.
+ canvas.drawColor(SK_ColorWHITE);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ canvas.save();
+ AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ DrawNativeRect(canvas, 0, 0, 100, 100);
+ canvas.restore();
+ }
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH));
+
+ // Add a clip and then make the layer to make sure the clip is correct.
+ canvas.drawColor(SK_ColorWHITE);
+ canvas.save();
+ AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ DrawNativeRect(canvas, 0, 0, 100, 100);
+ }
+ canvas.restore();
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH));
+}
+
+// Test that translation + make layer works properly.
+TEST(PlatformCanvas, TranslateLayer) {
+ // Create the canvas initialized to opaque white.
+ PlatformCanvas canvas(16, 16, true);
+
+ // Make a layer and fill it completely to make sure that the bounds are
+ // correct.
+ canvas.drawColor(SK_ColorWHITE);
+ canvas.save();
+ canvas.translate(1, 1);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ DrawNativeRect(canvas, 0, 0, 100, 100);
+ }
+ canvas.restore();
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX + 1, kLayerY + 1,
+ kLayerW, kLayerH));
+
+ // Translate then make the layer.
+ canvas.drawColor(SK_ColorWHITE);
+ canvas.save();
+ canvas.translate(1, 1);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ }
+ canvas.restore();
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 1, kInnerY + 1,
+ kInnerW, kInnerH));
+
+ // Make the layer then translate.
+ canvas.drawColor(SK_ColorWHITE);
+ canvas.save();
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ canvas.translate(1, 1);
+ DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ }
+ canvas.restore();
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 1, kInnerY + 1,
+ kInnerW, kInnerH));
+
+ // Translate both before and after, and have a clip.
+ canvas.drawColor(SK_ColorWHITE);
+ canvas.save();
+ canvas.translate(1, 1);
+ {
+ LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
+ canvas.translate(1, 1);
+ AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH);
+ DrawNativeRect(canvas, 0, 0, 100, 100);
+ }
+ canvas.restore();
+ EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 2, kInnerY + 2,
+ kInnerW, kInnerH));
+}
+
+} // namespace
+
diff --git a/webkit/port/platform/graphics/skia/public/PlatformCanvasWin.cpp b/skia/ext/platform_canvas_win.cc
index 6c0fe08..e3dffeb7 100644
--- a/webkit/port/platform/graphics/skia/public/PlatformCanvasWin.cpp
+++ b/skia/ext/platform_canvas_win.cc
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "PlatformCanvasWin.h"
-
-#include "BitmapPlatformDeviceWin.h"
+#include "skia/ext/platform_canvas_win.h"
#include "base/logging.h"
#include "base/process_util.h"
+#include "skia/ext/bitmap_platform_device_win.h"
namespace gfx {
diff --git a/webkit/port/platform/graphics/skia/public/PlatformCanvasWin.h b/skia/ext/platform_canvas_win.h
index fa84693..c3f42a3 100644
--- a/webkit/port/platform/graphics/skia/public/PlatformCanvasWin.h
+++ b/skia/ext/platform_canvas_win.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PlatformCanvasWin_h
-#define PlatformCanvasWin_h
+#ifndef SKIA_EXT_PLATFORM_CANVAS_WIN_H_
+#define SKIA_EXT_PLATFORM_CANVAS_WIN_H_
#include <windows.h>
-#include "PlatformDeviceWin.h"
#include "base/basictypes.h"
+#include "skia/ext/platform_device_win.h"
#include "SkCanvas.h"
@@ -198,5 +198,5 @@ typedef CanvasPaintT<PlatformCanvasWin> PlatformCanvasWinPaint;
} // namespace gfx
-#endif // PlatformCanvasWin_h
+#endif // SKIA_EXT_PLATFORM_CANVAS_WIN_H_
diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h
new file mode 100644
index 0000000..3072e08
--- /dev/null
+++ b/skia/ext/platform_device.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2006-2008 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.
+
+// Declare a platform-neutral name for this platform's device class
+// that can be used by upper-level classes that just need to pass a reference
+// around.
+
+#if defined(WIN32)
+#include "PlatformDeviceWin.h"
+#elif defined(__APPLE__)
+#include "PlatformDeviceMac.h"
+#elif defined(__linux__)
+#include "PlatformDeviceLinux.h"
+#endif
+
+namespace gfx {
+
+#if defined(WIN32)
+typedef PlatformDeviceWin PlatformDevice;
+#elif defined(__APPLE__)
+typedef PlatformDeviceMac PlatformDevice;
+#elif defined(__linux__)
+typedef PlatformDeviceLinux PlatformDevice;
+#endif
+
+} // namespace gfx
diff --git a/webkit/port/platform/graphics/skia/public/PlatformDeviceWin.cpp b/skia/ext/platform_device_win.cc
index 65dcffc..15201c0 100644
--- a/webkit/port/platform/graphics/skia/public/PlatformDeviceWin.cpp
+++ 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 "PlatformDeviceWin.h"
+#include "skia/ext/platform_device_win.h"
#include "base/logging.h"
#include "base/gfx/skia_utils.h"
diff --git a/webkit/port/platform/graphics/skia/public/PlatformDeviceWin.h b/skia/ext/platform_device_win.h
index 48b7197..e01a2c5 100644
--- a/webkit/port/platform/graphics/skia/public/PlatformDeviceWin.h
+++ b/skia/ext/platform_device_win.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PlatformDeviceWin_h
-#define PlatformDeviceWin_h
+#ifndef SKIA_EXT_PLATFORM_DEVICE_WIN_H_
+#define SKIA_EXT_PLATFORM_DEVICE_WIN_H_
#include <windows.h>
@@ -94,5 +94,5 @@ class PlatformDeviceWin : public SkDevice {
} // namespace gfx
-#endif // PlatformDeviceWin_h
+#endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_
diff --git a/webkit/port/platform/graphics/skia/public/VectorCanvas.cpp b/skia/ext/vector_canvas.cc
index 440ee64..440ee64 100644
--- a/webkit/port/platform/graphics/skia/public/VectorCanvas.cpp
+++ b/skia/ext/vector_canvas.cc
diff --git a/webkit/port/platform/graphics/skia/public/VectorCanvas.h b/skia/ext/vector_canvas.h
index 8538366..8538366 100644
--- a/webkit/port/platform/graphics/skia/public/VectorCanvas.h
+++ b/skia/ext/vector_canvas.h
diff --git a/webkit/port/platform/graphics/skia/public/VectorCanvas_unittest.cpp b/skia/ext/vector_canvas_unittest.cc
index 28adff7..b50c230 100644
--- a/webkit/port/platform/graphics/skia/public/VectorCanvas_unittest.cpp
+++ b/skia/ext/vector_canvas_unittest.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 "VectorCanvas.h"
+#include "skia/ext/vector_canvas.h"
#include <vector>
diff --git a/skia/ext/vector_device.cc b/skia/ext/vector_device.cc
new file mode 100644
index 0000000..a587e0c
--- /dev/null
+++ b/skia/ext/vector_device.cc
@@ -0,0 +1,612 @@
+// Copyright (c) 2006-2008 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/vector_device.h"
+
+#include "base/gfx/gdi_util.h"
+#include "base/gfx/skia_utils.h"
+#include "base/logging.h"
+#include "base/scoped_handle.h"
+
+#include "SkUtils.h"
+
+namespace gfx {
+
+VectorDevice* VectorDevice::create(HDC dc, int width, int height) {
+ InitializeDC(dc);
+
+ // Link the SkBitmap to the current selected bitmap in the device context.
+ SkBitmap bitmap;
+ HGDIOBJ selected_bitmap = GetCurrentObject(dc, OBJ_BITMAP);
+ bool succeeded = false;
+ if (selected_bitmap != NULL) {
+ BITMAP bitmap_data;
+ if (GetObject(selected_bitmap, sizeof(BITMAP), &bitmap_data) ==
+ sizeof(BITMAP)) {
+ // The context has a bitmap attached. Attach our SkBitmap to it.
+ // Warning: If the bitmap gets unselected from the HDC, VectorDevice has
+ // no way to detect this, so the HBITMAP could be released while SkBitmap
+ // still has a reference to it. Be cautious.
+ if (width == bitmap_data.bmWidth &&
+ height == bitmap_data.bmHeight) {
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ bitmap_data.bmWidth,
+ bitmap_data.bmHeight,
+ bitmap_data.bmWidthBytes);
+ bitmap.setPixels(bitmap_data.bmBits);
+ succeeded = true;
+ }
+ }
+ }
+
+ if (!succeeded)
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+
+ return new VectorDevice(dc, bitmap);
+}
+
+VectorDevice::VectorDevice(HDC dc, const SkBitmap& bitmap)
+ : PlatformDeviceWin(bitmap),
+ hdc_(dc),
+ previous_brush_(NULL),
+ previous_pen_(NULL) {
+ transform_.reset();
+}
+
+VectorDevice::~VectorDevice() {
+ DCHECK(previous_brush_ == NULL);
+ DCHECK(previous_pen_ == NULL);
+}
+
+
+void VectorDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
+ // TODO(maruel): Bypass the current transformation matrix.
+ SkRect rect;
+ rect.fLeft = 0;
+ rect.fTop = 0;
+ rect.fRight = SkIntToScalar(width() + 1);
+ rect.fBottom = SkIntToScalar(height() + 1);
+ drawRect(draw, rect, paint);
+}
+
+void VectorDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
+ size_t count, const SkPoint pts[],
+ const SkPaint& paint) {
+ if (!count)
+ return;
+
+ if (mode == SkCanvas::kPoints_PointMode) {
+ NOTREACHED();
+ return;
+ }
+
+ SkPaint tmp_paint(paint);
+ tmp_paint.setStyle(SkPaint::kStroke_Style);
+
+ // Draw a path instead.
+ SkPath path;
+ switch (mode) {
+ case SkCanvas::kLines_PointMode:
+ if (count % 2) {
+ NOTREACHED();
+ return;
+ }
+ for (size_t i = 0; i < count / 2; ++i) {
+ path.moveTo(pts[2 * i]);
+ path.lineTo(pts[2 * i + 1]);
+ }
+ break;
+ case SkCanvas::kPolygon_PointMode:
+ path.moveTo(pts[0]);
+ for (size_t i = 1; i < count; ++i) {
+ path.lineTo(pts[i]);
+ }
+ break;
+ default:
+ NOTREACHED();
+ return;
+ }
+ // Draw the calculated path.
+ drawPath(draw, path, tmp_paint);
+}
+
+void VectorDevice::drawRect(const SkDraw& draw, const SkRect& rect,
+ const SkPaint& paint) {
+ if (paint.getPathEffect()) {
+ // Draw a path instead.
+ SkPath path_orginal;
+ path_orginal.addRect(rect);
+
+ // Apply the path effect to the rect.
+ SkPath path_modified;
+ paint.getFillPath(path_orginal, &path_modified);
+
+ // Removes the path effect from the temporary SkPaint object.
+ SkPaint paint_no_effet(paint);
+ paint_no_effet.setPathEffect(NULL)->safeUnref();
+
+ // Draw the calculated path.
+ drawPath(draw, path_modified, paint_no_effet);
+ return;
+ }
+
+ if (!ApplyPaint(paint)) {
+ return;
+ }
+ HDC dc = getBitmapDC();
+ if (!Rectangle(dc, SkScalarRound(rect.fLeft),
+ SkScalarRound(rect.fTop),
+ SkScalarRound(rect.fRight),
+ SkScalarRound(rect.fBottom))) {
+ NOTREACHED();
+ }
+ Cleanup();
+}
+
+void VectorDevice::drawPath(const SkDraw& draw, const SkPath& path,
+ const SkPaint& paint) {
+ if (paint.getPathEffect()) {
+ // Apply the path effect forehand.
+ SkPath path_modified;
+ paint.getFillPath(path, &path_modified);
+
+ // Removes the path effect from the temporary SkPaint object.
+ SkPaint paint_no_effet(paint);
+ paint_no_effet.setPathEffect(NULL)->safeUnref();
+
+ // Draw the calculated path.
+ drawPath(draw, path_modified, paint_no_effet);
+ return;
+ }
+
+ if (!ApplyPaint(paint)) {
+ return;
+ }
+ HDC dc = getBitmapDC();
+ PlatformDeviceWin::LoadPathToDC(dc, path);
+ switch (paint.getStyle()) {
+ case SkPaint::kFill_Style: {
+ BOOL res = StrokeAndFillPath(dc);
+ DCHECK(res != 0);
+ break;
+ }
+ case SkPaint::kStroke_Style: {
+ BOOL res = StrokePath(dc);
+ DCHECK(res != 0);
+ break;
+ }
+ case SkPaint::kStrokeAndFill_Style: {
+ BOOL res = StrokeAndFillPath(dc);
+ DCHECK(res != 0);
+ break;
+ }
+ default:
+ NOTREACHED();
+ break;
+ }
+ Cleanup();
+}
+
+void VectorDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
+ const SkMatrix& matrix, const SkPaint& paint) {
+ // Load the temporary matrix. This is what will translate, rotate and resize
+ // the bitmap.
+ SkMatrix actual_transform(transform_);
+ actual_transform.preConcat(matrix);
+ LoadTransformToDC(hdc_, actual_transform);
+
+ InternalDrawBitmap(bitmap, 0, 0, paint);
+
+ // Restore the original matrix.
+ LoadTransformToDC(hdc_, transform_);
+}
+
+void VectorDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
+ int x, int y, const SkPaint& paint) {
+ SkMatrix identity;
+ identity.reset();
+ LoadTransformToDC(hdc_, identity);
+
+ InternalDrawBitmap(bitmap, x, y, paint);
+
+ // Restore the original matrix.
+ LoadTransformToDC(hdc_, transform_);
+}
+
+void VectorDevice::drawText(const SkDraw& draw, const void* text, size_t byteLength,
+ SkScalar x, SkScalar y, const SkPaint& paint) {
+ // This function isn't used in the code. Verify this assumption.
+ NOTREACHED();
+}
+
+void VectorDevice::drawPosText(const SkDraw& draw, const void* text, size_t len,
+ const SkScalar pos[], SkScalar constY,
+ int scalarsPerPos, const SkPaint& paint) {
+ // This function isn't used in the code. Verify this assumption.
+ NOTREACHED();
+}
+
+void VectorDevice::drawTextOnPath(const SkDraw& draw, const void* text,
+ size_t len,
+ const SkPath& path, const SkMatrix* matrix,
+ const SkPaint& paint) {
+ // This function isn't used in the code. Verify this assumption.
+ NOTREACHED();
+}
+
+void VectorDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
+ int vertexCount,
+ const SkPoint vertices[], const SkPoint texs[],
+ const SkColor colors[], SkXfermode* xmode,
+ const uint16_t indices[], int indexCount,
+ const SkPaint& paint) {
+ // This function isn't used in the code. Verify this assumption.
+ NOTREACHED();
+}
+
+void VectorDevice::drawDevice(const SkDraw& draw, SkDevice* device, int x,
+ int y, const SkPaint& paint) {
+ // TODO(maruel): http://b/1183870 Playback the EMF buffer at printer's dpi if
+ // it is a vectorial device.
+ drawSprite(draw, device->accessBitmap(false), x, y, paint);
+}
+
+bool VectorDevice::ApplyPaint(const SkPaint& paint) {
+ // Note: The goal here is to transfert the SkPaint's state to the HDC's state.
+ // This function does not execute the SkPaint drawing commands. These should
+ // be executed in drawPaint().
+
+ SkPaint::Style style = paint.getStyle();
+ if (!paint.getAlpha())
+ style = SkPaint::kStyleCount;
+
+ switch (style) {
+ case SkPaint::kFill_Style:
+ if (!CreateBrush(true, paint) ||
+ !CreatePen(false, paint))
+ return false;
+ break;
+ case SkPaint::kStroke_Style:
+ if (!CreateBrush(false, paint) ||
+ !CreatePen(true, paint))
+ return false;
+ break;
+ case SkPaint::kStrokeAndFill_Style:
+ if (!CreateBrush(true, paint) ||
+ !CreatePen(true, paint))
+ return false;
+ break;
+ default:
+ if (!CreateBrush(false, paint) ||
+ !CreatePen(false, paint))
+ return false;
+ break;
+ }
+
+ /*
+ getFlags();
+ isAntiAlias();
+ isDither()
+ isLinearText()
+ isSubpixelText()
+ isUnderlineText()
+ isStrikeThruText()
+ isFakeBoldText()
+ isDevKernText()
+ isFilterBitmap()
+
+ // Skia's text is not used. This should be fixed.
+ getTextAlign()
+ getTextScaleX()
+ getTextSkewX()
+ getTextEncoding()
+ getFontMetrics()
+ getFontSpacing()
+ */
+
+ // BUG 1094907: Implement shaders. Shaders currently in use:
+ // SkShader::CreateBitmapShader
+ // SkGradientShader::CreateRadial
+ // SkGradientShader::CreateLinear
+ // DCHECK(!paint.getShader());
+
+ // http://b/1106647 Implement loopers and mask filter. Looper currently in
+ // use:
+ // SkBlurDrawLooper is used for shadows.
+ // DCHECK(!paint.getLooper());
+ // DCHECK(!paint.getMaskFilter());
+
+ // http://b/1165900 Implement xfermode.
+ // DCHECK(!paint.getXfermode());
+
+ // The path effect should be processed before arriving here.
+ DCHECK(!paint.getPathEffect());
+
+ // These aren't used in the code. Verify this assumption.
+ DCHECK(!paint.getColorFilter());
+ DCHECK(!paint.getRasterizer());
+ // Reuse code to load Win32 Fonts.
+ DCHECK(!paint.getTypeface());
+ return true;
+}
+
+void VectorDevice::setMatrixClip(const SkMatrix& transform,
+ const SkRegion& region) {
+ transform_ = transform;
+ LoadTransformToDC(hdc_, transform_);
+ clip_region_ = region;
+ if (!clip_region_.isEmpty())
+ LoadClipRegion();
+}
+
+void VectorDevice::drawToHDC(HDC dc, int x, int y, const RECT* src_rect) {
+ NOTREACHED();
+}
+
+void VectorDevice::LoadClipRegion() {
+ SkMatrix t;
+ t.reset();
+ LoadClippingRegionToDC(hdc_, clip_region_, t);
+}
+
+bool VectorDevice::CreateBrush(bool use_brush, COLORREF color) {
+ DCHECK(previous_brush_ == NULL);
+ // We can't use SetDCBrushColor() or DC_BRUSH when drawing to a EMF buffer.
+ // SetDCBrushColor() calls are not recorded at all and DC_BRUSH will use
+ // WHITE_BRUSH instead.
+
+ if (!use_brush) {
+ // Set the transparency.
+ if (0 == SetBkMode(hdc_, TRANSPARENT)) {
+ NOTREACHED();
+ return false;
+ }
+
+ // Select the NULL brush.
+ previous_brush_ = SelectObject(GetStockObject(NULL_BRUSH));
+ return previous_brush_ != NULL;
+ }
+
+ // Set the opacity.
+ if (0 == SetBkMode(hdc_, OPAQUE)) {
+ NOTREACHED();
+ return false;
+ }
+
+ // Create and select the brush.
+ previous_brush_ = SelectObject(CreateSolidBrush(color));
+ return previous_brush_ != NULL;
+}
+
+bool VectorDevice::CreatePen(bool use_pen, COLORREF color, int stroke_width,
+ float stroke_miter, DWORD pen_style) {
+ DCHECK(previous_pen_ == NULL);
+ // We can't use SetDCPenColor() or DC_PEN when drawing to a EMF buffer.
+ // SetDCPenColor() calls are not recorded at all and DC_PEN will use BLACK_PEN
+ // instead.
+
+ // No pen case
+ if (!use_pen) {
+ previous_pen_ = SelectObject(GetStockObject(NULL_PEN));
+ return previous_pen_ != NULL;
+ }
+
+ // Use the stock pen if the stroke width is 0.
+ if (stroke_width == 0) {
+ // Create a pen with the right color.
+ previous_pen_ = SelectObject(::CreatePen(PS_SOLID, 0, color));
+ return previous_pen_ != NULL;
+ }
+
+ // Load a custom pen.
+ LOGBRUSH brush;
+ brush.lbStyle = BS_SOLID;
+ brush.lbColor = color;
+ brush.lbHatch = 0;
+ HPEN pen = ExtCreatePen(pen_style, stroke_width, &brush, 0, NULL);
+ DCHECK(pen != NULL);
+ previous_pen_ = SelectObject(pen);
+ if (previous_pen_ == NULL)
+ return false;
+
+ if (!SetMiterLimit(hdc_, stroke_miter, NULL)) {
+ NOTREACHED();
+ return false;
+ }
+ return true;
+}
+
+void VectorDevice::Cleanup() {
+ if (previous_brush_) {
+ HGDIOBJ result = SelectObject(previous_brush_);
+ previous_brush_ = NULL;
+ if (result) {
+ BOOL res = DeleteObject(result);
+ DCHECK(res != 0);
+ }
+ }
+ if (previous_pen_) {
+ HGDIOBJ result = SelectObject(previous_pen_);
+ previous_pen_ = NULL;
+ if (result) {
+ BOOL res = DeleteObject(result);
+ DCHECK(res != 0);
+ }
+ }
+ // Remove any loaded path from the context.
+ AbortPath(hdc_);
+}
+
+HGDIOBJ VectorDevice::SelectObject(HGDIOBJ object) {
+ HGDIOBJ result = ::SelectObject(hdc_, object);
+ DCHECK(result != HGDI_ERROR);
+ if (result == HGDI_ERROR)
+ return NULL;
+ return result;
+}
+
+bool VectorDevice::CreateBrush(bool use_brush, const SkPaint& paint) {
+ // Make sure that for transparent color, no brush is used.
+ if (paint.getAlpha() == 0) {
+ // Test if it ever happen.
+ NOTREACHED();
+ use_brush = false;
+ }
+
+ return CreateBrush(use_brush, SkColorToCOLORREF(paint.getColor()));
+}
+
+bool VectorDevice::CreatePen(bool use_pen, const SkPaint& paint) {
+ // Make sure that for transparent color, no pen is used.
+ if (paint.getAlpha() == 0) {
+ // Test if it ever happen.
+ NOTREACHED();
+ use_pen = false;
+ }
+
+ DWORD pen_style = PS_GEOMETRIC | PS_SOLID;
+ switch (paint.getStrokeJoin()) {
+ case SkPaint::kMiter_Join:
+ // Connects path segments with a sharp join.
+ pen_style |= PS_JOIN_MITER;
+ break;
+ case SkPaint::kRound_Join:
+ // Connects path segments with a round join.
+ pen_style |= PS_JOIN_ROUND;
+ break;
+ case SkPaint::kBevel_Join:
+ // Connects path segments with a flat bevel join.
+ pen_style |= PS_JOIN_BEVEL;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ switch (paint.getStrokeCap()) {
+ case SkPaint::kButt_Cap:
+ // Begin/end contours with no extension.
+ pen_style |= PS_ENDCAP_FLAT;
+ break;
+ case SkPaint::kRound_Cap:
+ // Begin/end contours with a semi-circle extension.
+ pen_style |= PS_ENDCAP_ROUND;
+ break;
+ case SkPaint::kSquare_Cap:
+ // Begin/end contours with a half square extension.
+ pen_style |= PS_ENDCAP_SQUARE;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+
+ return CreatePen(use_pen,
+ SkColorToCOLORREF(paint.getColor()),
+ SkScalarRound(paint.getStrokeWidth()),
+ paint.getStrokeMiter(),
+ pen_style);
+}
+
+void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y,
+ const SkPaint& paint) {
+ uint8 alpha = paint.getAlpha();
+ if (alpha == 0)
+ return;
+
+ bool is_translucent;
+ if (alpha != 255) {
+ // ApplyPaint expect an opaque color.
+ SkPaint tmp_paint(paint);
+ tmp_paint.setAlpha(255);
+ if (!ApplyPaint(tmp_paint))
+ return;
+ is_translucent = true;
+ } else {
+ if (!ApplyPaint(paint))
+ return;
+ is_translucent = false;
+ }
+ int src_size_x = bitmap.width();
+ int src_size_y = bitmap.height();
+ if (!src_size_x || !src_size_y)
+ return;
+
+ // Create a BMP v4 header that we can serialize.
+ BITMAPV4HEADER bitmap_header;
+ gfx::CreateBitmapV4Header(src_size_x, src_size_y, &bitmap_header);
+ HDC dc = getBitmapDC();
+ SkAutoLockPixels lock(bitmap);
+ DCHECK_EQ(bitmap.getConfig(), SkBitmap::kARGB_8888_Config);
+ const uint32_t* pixels = static_cast<const uint32_t*>(bitmap.getPixels());
+ if (pixels == NULL) {
+ NOTREACHED();
+ return;
+ }
+
+ if (!is_translucent) {
+ int row_length = bitmap.rowBytesAsPixels();
+ // There is no quick way to determine if an image is opaque.
+ for (int y2 = 0; y2 < src_size_y; ++y2) {
+ for (int x2 = 0; x2 < src_size_x; ++x2) {
+ if (SkColorGetA(pixels[(y2 * row_length) + x2]) != 255) {
+ is_translucent = true;
+ y2 = src_size_y;
+ break;
+ }
+ }
+ }
+ }
+
+ BITMAPINFOHEADER hdr;
+ gfx::CreateBitmapHeader(src_size_x, src_size_y, &hdr);
+ if (is_translucent) {
+ // The image must be loaded as a bitmap inside a device context.
+ ScopedHDC bitmap_dc(::CreateCompatibleDC(dc));
+ void* bits = NULL;
+ ScopedBitmap hbitmap(::CreateDIBSection(
+ bitmap_dc, reinterpret_cast<const BITMAPINFO*>(&hdr),
+ DIB_RGB_COLORS, &bits, NULL, 0));
+ memcpy(bits, pixels, bitmap.getSize());
+ DCHECK(hbitmap);
+ HGDIOBJ old_bitmap = ::SelectObject(bitmap_dc, hbitmap);
+ DeleteObject(old_bitmap);
+
+ // After some analysis of IE7's behavior, this is the thing to do. I was
+ // sure IE7 was doing so kind of bitmasking due to the way translucent image
+ // where renderered but after some windbg tracing, it is being done by the
+ // printer driver after all (mostly HP printers). IE7 always use AlphaBlend
+ // for bitmasked images. The trick seems to switch the stretching mode in
+ // what the driver expects.
+ DWORD previous_mode = GetStretchBltMode(dc);
+ BOOL result = SetStretchBltMode(dc, COLORONCOLOR);
+ DCHECK(result);
+ // Note that this function expect premultiplied colors (!)
+ BLENDFUNCTION blend_function = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
+ result = GdiAlphaBlend(dc,
+ x, y, // Destination origin.
+ src_size_x, src_size_y, // Destination size.
+ bitmap_dc,
+ 0, 0, // Source origin.
+ src_size_x, src_size_y, // Source size.
+ blend_function);
+ DCHECK(result);
+ result = SetStretchBltMode(dc, previous_mode);
+ DCHECK(result);
+ } else {
+ BOOL result = StretchDIBits(dc,
+ x, y, // Destination origin.
+ src_size_x, src_size_y,
+ 0, 0, // Source origin.
+ src_size_x, src_size_y, // Source size.
+ pixels,
+ reinterpret_cast<const BITMAPINFO*>(&hdr),
+ DIB_RGB_COLORS,
+ SRCCOPY);
+ DCHECK(result);
+ }
+ Cleanup();
+}
+
+} // namespace gfx
+
diff --git a/skia/ext/vector_device.h b/skia/ext/vector_device.h
new file mode 100644
index 0000000..8579689
--- /dev/null
+++ b/skia/ext/vector_device.h
@@ -0,0 +1,119 @@
+// Copyright (c) 2006-2008 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.
+
+#ifndef VectorDevice_h
+#define VectorDevice_h
+
+#include "base/basictypes.h"
+#include "base/gfx/platform_device_win.h"
+#include "SkMatrix.h"
+#include "SkRegion.h"
+
+namespace gfx {
+
+// A device is basically a wrapper around SkBitmap that provides a surface for
+// SkCanvas to draw into. This specific device is not not backed by a surface
+// and is thus unreadable. This is because the backend is completely vectorial.
+// This device is a simple wrapper over a Windows device context (HDC) handle.
+class VectorDevice : public PlatformDeviceWin {
+ public:
+ // Factory function. The DC is kept as the output context.
+ static VectorDevice* create(HDC dc, int width, int height);
+
+ VectorDevice(HDC dc, const SkBitmap& bitmap);
+ virtual ~VectorDevice();
+
+ virtual HDC getBitmapDC() {
+ return hdc_;
+ }
+
+ virtual void drawPaint(const SkDraw& draw, const SkPaint& paint);
+ virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
+ size_t count, const SkPoint[], const SkPaint& paint);
+ virtual void drawRect(const SkDraw& draw, const SkRect& r,
+ const SkPaint& paint);
+ virtual void drawPath(const SkDraw& draw, const SkPath& path,
+ const SkPaint& paint);
+ virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
+ const SkMatrix& matrix, const SkPaint& paint);
+ virtual void drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
+ int x, int y, const SkPaint& paint);
+ virtual void drawText(const SkDraw& draw, const void* text, size_t len,
+ SkScalar x, SkScalar y, const SkPaint& paint);
+ virtual void drawPosText(const SkDraw& draw, const void* text, size_t len,
+ const SkScalar pos[], SkScalar constY,
+ int scalarsPerPos, const SkPaint& paint);
+ virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len,
+ const SkPath& path, const SkMatrix* matrix,
+ const SkPaint& paint);
+ virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode,
+ int vertexCount,
+ const SkPoint verts[], const SkPoint texs[],
+ const SkColor colors[], SkXfermode* xmode,
+ const uint16_t indices[], int indexCount,
+ const SkPaint& paint);
+ virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y,
+ const SkPaint&);
+
+
+ virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region);
+ virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect);
+ virtual bool IsVectorial() { return true; }
+
+ void LoadClipRegion();
+
+ private:
+ // Applies the SkPaint's painting properties in the current GDI context, if
+ // possible. If GDI can't support all paint's properties, returns false. It
+ // doesn't execute the "commands" in SkPaint.
+ bool ApplyPaint(const SkPaint& paint);
+
+ // Selects a new object in the device context. It can be a pen, a brush, a
+ // clipping region, a bitmap or a font. Returns the old selected object.
+ HGDIOBJ SelectObject(HGDIOBJ object);
+
+ // Creates a brush according to SkPaint's properties.
+ bool CreateBrush(bool use_brush, const SkPaint& paint);
+
+ // Creates a pen according to SkPaint's properties.
+ bool CreatePen(bool use_pen, const SkPaint& paint);
+
+ // Restores back the previous objects (pen, brush, etc) after a paint command.
+ void Cleanup();
+
+ // Creates a brush according to SkPaint's properties.
+ bool CreateBrush(bool use_brush, COLORREF color);
+
+ // Creates a pen according to SkPaint's properties.
+ bool CreatePen(bool use_pen, COLORREF color, int stroke_width,
+ float stroke_miter, DWORD pen_style);
+
+ // Draws a bitmap in the the device, using the currently loaded matrix.
+ void InternalDrawBitmap(const SkBitmap& bitmap, int x, int y,
+ const SkPaint& paint);
+
+ // The Windows Device Context handle. It is the backend used with GDI drawing.
+ // This backend is write-only and vectorial.
+ HDC hdc_;
+
+ // Translation assigned to the DC: we need to keep track of this separately
+ // so it can be updated even if the DC isn't created yet.
+ SkMatrix transform_;
+
+ // The current clipping
+ SkRegion clip_region_;
+
+ // Previously selected brush before the current drawing.
+ HGDIOBJ previous_brush_;
+
+ // Previously selected pen before the current drawing.
+ HGDIOBJ previous_pen_;
+
+ DISALLOW_COPY_AND_ASSIGN(VectorDevice);
+};
+
+} // namespace gfx
+
+#endif // VectorDevice_h
+
diff --git a/skia/skia.vcproj b/skia/skia.vcproj
index 7d12574..5e06d73 100644
--- a/skia/skia.vcproj
+++ b/skia/skia.vcproj
@@ -1305,6 +1305,62 @@
>
</File>
</Filter>
+ <Filter
+ Name="ext"
+ >
+ <File
+ RelativePath=".\ext\bitmap_platform_device.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\bitmap_platform_device_win.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\bitmap_platform_device_win.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\platform_canvas.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\platform_canvas_win.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\platform_canvas_win.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\platform_device.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\platform_device_win.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\platform_device_win.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\vector_canvas.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\vector_canvas.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\vector_device.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\vector_device.h"
+ >
+ </File>
+ </Filter>
<File
RelativePath=".\precompiled.cc"
>
diff --git a/webkit/SConscript.port b/webkit/SConscript.port
index 7f3132d..f518675 100644
--- a/webkit/SConscript.port
+++ b/webkit/SConscript.port
@@ -169,12 +169,6 @@ if env['PLATFORM'] == 'win32':
'$PORT_DIR/platform/graphics/UniscribeHelper.cpp',
'$PORT_DIR/platform/graphics/UniscribeHelperTextRun.cpp',
- '$PORT_DIR/platform/graphics/skia/public/BitmapPlatformDeviceWin.cpp',
- '$PORT_DIR/platform/graphics/skia/public/PlatformCanvasWin.cpp',
- '$PORT_DIR/platform/graphics/skia/public/PlatformDeviceWin.cpp',
- '$PORT_DIR/platform/graphics/skia/public/VectorCanvas.cpp',
- '$PORT_DIR/platform/graphics/skia/public/VectorDevice.cpp',
-
'$PORT_DIR/rendering/RenderThemeWin.cpp',
])
diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj
index 20200c5..e459cb4 100644
--- a/webkit/build/port/port.vcproj
+++ b/webkit/build/port/port.vcproj
@@ -1234,66 +1234,6 @@
>
</File>
</Filter>
- <Filter
- Name="skia"
- >
- <Filter
- Name="public"
- >
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\BitmapPlatformDevice.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\BitmapPlatformDeviceWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\BitmapPlatformDeviceWin.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformCanvas.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformCanvasWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformCanvasWin.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformDevice.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformDeviceWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformDeviceWin.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\VectorCanvas.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\VectorCanvas.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\VectorDevice.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\skia\public\VectorDevice.h"
- >
- </File>
- </Filter>
- </Filter>
</Filter>
<Filter
Name="image-decoders"
diff --git a/webkit/port/platform/graphics/skia/public/BitmapPlatformDevice.h b/webkit/port/platform/graphics/skia/public/BitmapPlatformDevice.h
index 1f933a4..1b0df28 100644
--- a/webkit/port/platform/graphics/skia/public/BitmapPlatformDevice.h
+++ b/webkit/port/platform/graphics/skia/public/BitmapPlatformDevice.h
@@ -7,7 +7,7 @@
// around.
#if defined(WIN32)
-#include "BitmapPlatformDeviceWin.h"
+#include "skia/ext/bitmap_platform_device_win.h"
namespace gfx {
typedef BitmapPlatformDeviceWin BitmapPlatformDevice;
diff --git a/webkit/port/platform/graphics/skia/public/PlatformCanvas.h b/webkit/port/platform/graphics/skia/public/PlatformCanvas.h
index 162bf3e..a2af39e 100644
--- a/webkit/port/platform/graphics/skia/public/PlatformCanvas.h
+++ b/webkit/port/platform/graphics/skia/public/PlatformCanvas.h
@@ -7,7 +7,7 @@
// around.
#if defined(WIN32)
-#include "PlatformCanvasWin.h"
+#include "skia/ext/platform_canvas_win.h"
namespace gfx {
typedef PlatformCanvasWin PlatformCanvas;
diff --git a/webkit/port/platform/graphics/skia/public/PlatformDevice.h b/webkit/port/platform/graphics/skia/public/PlatformDevice.h
index a381fd1..1cd8847 100644
--- a/webkit/port/platform/graphics/skia/public/PlatformDevice.h
+++ b/webkit/port/platform/graphics/skia/public/PlatformDevice.h
@@ -7,7 +7,7 @@
// around.
#if defined(WIN32)
-#include "PlatformDeviceWin.h"
+#include "skia/ext/platform_device_win.h"
#elif defined(__APPLE__)
#include "skia/ext/platform_device_mac.h"
#elif defined(__linux__)
diff --git a/webkit/tools/test_shell/test_shell_tests.vcproj b/webkit/tools/test_shell/test_shell_tests.vcproj
index 26bd25d..4f6a036 100644
--- a/webkit/tools/test_shell/test_shell_tests.vcproj
+++ b/webkit/tools/test_shell/test_shell_tests.vcproj
@@ -363,7 +363,7 @@
>
</File>
<File
- RelativePath="..\..\port\platform\graphics\skia\public\PlatformCanvas_unittest.cpp"
+ RelativePath="..\..\..\skia\ext\platform_canvas_unittest.cc"
>
</File>
<File
@@ -387,7 +387,7 @@
>
</File>
<File
- RelativePath="..\..\port\platform\graphics\skia\public\VectorCanvas_unittest.cpp"
+ RelativePath="..\..\..\skia\ext\vector_canvas_unittest.cc"
>
</File>
<File