From 6862ac6cbec1c9a3d7e332b3e8c696c9a3d172d6 Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Wed, 5 Aug 2009 20:26:41 +0000 Subject: Original change by Min-Yu Huang 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 --- skia/ext/vector_canvas_linux.cc | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 skia/ext/vector_canvas_linux.cc (limited to 'skia/ext/vector_canvas_linux.cc') diff --git a/skia/ext/vector_canvas_linux.cc b/skia/ext/vector_canvas_linux.cc new file mode 100644 index 0000000..95722c9 --- /dev/null +++ b/skia/ext/vector_canvas_linux.cc @@ -0,0 +1,49 @@ +// Copyright (c) 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.h" +#include "skia/ext/vector_platform_device.h" + +namespace skia { + +VectorCanvas::VectorCanvas(int width, int height) { + bool initialized = initialize(width, height); + + SkASSERT(initialized); +} + +bool VectorCanvas::initialize(int width, int height) { + SkDevice* device = createPlatformDevice(width, height, true); + if (!device) + return false; + + setDevice(device); + device->unref(); // was created with refcount 1, and setDevice also refs + return true; +} + +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); +} + +SkDevice* VectorCanvas::createPlatformDevice(int width, + int height, bool is_opaque) { + // TODO(myhuang): Here we might also have similar issues as those on Windows + // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). + // Please note that is_opaque is true when we use this class for printing. + if (!is_opaque) { + return BitmapPlatformDevice::Create(width, height, is_opaque); + } + + PlatformDevice* device = VectorPlatformDevice::create(width, height); + return device; +} + +} // namespace skia + -- cgit v1.1