diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-05 20:26:41 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-05 20:26:41 +0000 |
commit | 6862ac6cbec1c9a3d7e332b3e8c696c9a3d172d6 (patch) | |
tree | 7b810a3eb33cb63e404c8f4d67e6f3676168b13b /skia/ext/vector_canvas.cc | |
parent | e7ef7150c893a1ff2fe4197ce9d76ccb21001caa (diff) | |
download | chromium_src-6862ac6cbec1c9a3d7e332b3e8c696c9a3d172d6.zip chromium_src-6862ac6cbec1c9a3d7e332b3e8c696c9a3d172d6.tar.gz chromium_src-6862ac6cbec1c9a3d7e332b3e8c696c9a3d172d6.tar.bz2 |
Original change by Min-Yu Huang <minyu.huang@gmail.com> in
http://codereview.chromium.org/160347
This is the very preliminary implementation to support printing on Linux and it
has not been finished yet. For each page to be printed, we convert rendering
actions on canvas into cairo APIs and generate a PS/PDF file.
chrome/chrome.gyp:
Include our newly added and renamed files.
chrome/browser/browser.h:
chrome/browser/browser.cc:
Allow the user print the web page by hitting ctrl-p.
chrome/browser/gtk/standard_menus.cc:
Show "Print" in the menu.
chrome/renderer/print_web_view_helper.cc:
chrome/renderer/print_web_view_helper.h:
chrome/renderer/print_web_view_helper_mac.cc
chrome/renderer/print_web_view_helper_win.cc
Move the class PrepareFrameAndViewForPrint to the header file and move
platform dependent parts to their corresponding files.
chrome/renderer/print_web_view_helper_linux.cc:
Hard-coded parameters for printing. Only print the first page now.
skia/ext/vector_canvas.cc:
skia/ext/vector_canvas.h:
skia/ext/vector_canvas_linux.cc:
skia/ext/vector_canvas_win.cc:
Move platform dependent parts to their corresponding files.
skia/ext/vector_platform_device.h:
skia/ext/vector_platform_device_linux.cc:
skia/ext/vector_platform_device_linux.h
We translate skia APIs into Cairo APIs here. A PDF file is also created and
saved to the disk at this moment for testing purpose (you have to run chrome
without the sandbox to save the file). There are still lots of bugs.
skia/skia.gyp:
Include our newly added files when compiling skia package on Linux.
BUG=9847
Review URL: http://codereview.chromium.org/160673
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/vector_canvas.cc')
-rw-r--r-- | skia/ext/vector_canvas.cc | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/skia/ext/vector_canvas.cc b/skia/ext/vector_canvas.cc index 75b7310..c80d0c3 100644 --- a/skia/ext/vector_canvas.cc +++ b/skia/ext/vector_canvas.cc @@ -1,36 +1,17 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 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); @@ -40,49 +21,12 @@ SkBounder* VectorCanvas::setBounder(SkBounder* bounder) { 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(); } |