summaryrefslogtreecommitdiffstats
path: root/skia/ext/vector_canvas_win.cc
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 18:00:42 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 18:00:42 +0000
commitcb100b891482c42e5d4d6a234e6d0bf60f2e416f (patch)
tree2f2ec1917db09c4939680f4e248b5d255bdeb210 /skia/ext/vector_canvas_win.cc
parent937efca2308c6640b0cbee15051c50d3413760de (diff)
downloadchromium_src-cb100b891482c42e5d4d6a234e6d0bf60f2e416f.zip
chromium_src-cb100b891482c42e5d4d6a234e6d0bf60f2e416f.tar.gz
chromium_src-cb100b891482c42e5d4d6a234e6d0bf60f2e416f.tar.bz2
Copy files to preserve version history. Will be edited when I
land Min-Yu's changes in http://codereview.chromium.org/160347 . TBR=evan git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/vector_canvas_win.cc')
-rw-r--r--skia/ext/vector_canvas_win.cc91
1 files changed, 91 insertions, 0 deletions
diff --git a/skia/ext/vector_canvas_win.cc b/skia/ext/vector_canvas_win.cc
new file mode 100644
index 0000000..75b7310
--- /dev/null
+++ b/skia/ext/vector_canvas_win.cc
@@ -0,0 +1,91 @@
+// 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_canvas.h"
+
+#include "skia/ext/bitmap_platform_device_win.h"
+#include "skia/ext/vector_platform_device_win.h"
+
+namespace skia {
+
+VectorCanvas::VectorCanvas() {
+}
+
+VectorCanvas::VectorCanvas(HDC dc, int width, int height) {
+ bool initialized = initialize(dc, width, height);
+ if (!initialized)
+ __debugbreak();
+}
+
+VectorCanvas::~VectorCanvas() {
+}
+
+bool VectorCanvas::initialize(HDC context, int width, int height) {
+ SkDevice* device = createPlatformDevice(width, height, true, context);
+ if (!device)
+ return false;
+
+ setDevice(device);
+ device->unref(); // was created with refcount 1, and setDevice also refs
+ return true;
+}
+
+SkBounder* VectorCanvas::setBounder(SkBounder* bounder) {
+ if (!IsTopDeviceVectorial())
+ return PlatformCanvas::setBounder(bounder);
+
+ // This function isn't used in the code. Verify this assumption.
+ SkASSERT(false);
+ return NULL;
+}
+
+SkDevice* VectorCanvas::createDevice(SkBitmap::Config config,
+ int width, int height,
+ bool is_opaque, bool isForLayer) {
+ SkASSERT(config == SkBitmap::kARGB_8888_Config);
+ return createPlatformDevice(width, height, is_opaque, NULL);
+}
+
+SkDrawFilter* VectorCanvas::setDrawFilter(SkDrawFilter* filter) {
+ // This function isn't used in the code. Verify this assumption.
+ SkASSERT(false);
+ return NULL;
+}
+
+SkDevice* VectorCanvas::createPlatformDevice(int width,
+ int height, bool is_opaque,
+ HANDLE shared_section) {
+ if (!is_opaque) {
+ // TODO(maruel): http://b/1184002 1184002 When restoring a semi-transparent
+ // layer, i.e. merging it, we need to rasterize it because GDI doesn't
+ // support transparency except for AlphaBlend(). Right now, a
+ // BitmapPlatformDevice is created when VectorCanvas think a saveLayers()
+ // call is being done. The way to save a layer would be to create an
+ // EMF-based VectorDevice and have this device registers the drawing. When
+ // playing back the device into a bitmap, do it at the printer's dpi instead
+ // of the layout's dpi (which is much lower).
+ return BitmapPlatformDevice::create(width, height,
+ is_opaque, shared_section);
+ }
+
+ // TODO(maruel): http://b/1183870 Look if it would be worth to increase the
+ // resolution by ~10x (any worthy factor) to increase the rendering precision
+ // (think about printing) while using a relatively low dpi. This happens
+ // because we receive float as input but the GDI functions works with
+ // integers. The idea is to premultiply the matrix with this factor and
+ // multiply each SkScalar that are passed to SkScalarRound(value) as
+ // SkScalarRound(value * 10). Safari is already doing the same for text
+ // rendering.
+ SkASSERT(shared_section);
+ PlatformDevice* device = VectorPlatformDevice::create(
+ reinterpret_cast<HDC>(shared_section), width, height);
+ return device;
+}
+
+bool VectorCanvas::IsTopDeviceVectorial() const {
+ return getTopPlatformDevice().IsVectorial();
+}
+
+} // namespace skia
+