Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: skia/ext/vector_canvas_linux.cc

Issue 172115: Pass printing result to the browser.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia/ext/vector_canvas.h" 5 #include "skia/ext/vector_canvas.h"
6 6
7 #include "skia/ext/bitmap_platform_device.h" 7 #include "skia/ext/bitmap_platform_device.h"
8 #include "skia/ext/vector_platform_device.h" 8 #include "skia/ext/vector_platform_device.h"
9 9
10 namespace skia { 10 namespace skia {
11 11
12 VectorCanvas::VectorCanvas(int width, int height) { 12 VectorCanvas::VectorCanvas(cairo_t* context, int width, int height) {
13 bool initialized = initialize(width, height); 13 bool initialized = initialize(context, width, height);
14 14
15 SkASSERT(initialized); 15 SkASSERT(initialized);
16 } 16 }
17 17
18 bool VectorCanvas::initialize(int width, int height) { 18 bool VectorCanvas::initialize(cairo_t* context, int width, int height) {
19 SkDevice* device = createPlatformDevice(width, height, true); 19 SkDevice* device = createPlatformDevice(context, width, height, true);
20 if (!device) 20 if (!device)
21 return false; 21 return false;
22 22
23 setDevice(device); 23 setDevice(device);
24 device->unref(); // was created with refcount 1, and setDevice also refs 24 device->unref(); // was created with refcount 1, and setDevice also refs
25 return true; 25 return true;
26 } 26 }
27 27
28 SkDevice* VectorCanvas::createDevice(SkBitmap::Config config, 28 SkDevice* VectorCanvas::createDevice(SkBitmap::Config config,
29 int width, int height, 29 int width, int height,
30 bool is_opaque, bool isForLayer) { 30 bool is_opaque, bool isForLayer) {
31 SkASSERT(config == SkBitmap::kARGB_8888_Config); 31 SkASSERT(config == SkBitmap::kARGB_8888_Config);
32 return createPlatformDevice(width, height, is_opaque); 32 return createPlatformDevice(NULL, width, height, is_opaque);
33 } 33 }
34 34
35 SkDevice* VectorCanvas::createPlatformDevice(int width, 35 SkDevice* VectorCanvas::createPlatformDevice(cairo_t* context,
36 int height, bool is_opaque) { 36 int width,
37 int height,
38 bool is_opaque) {
37 // TODO(myhuang): Here we might also have similar issues as those on Windows 39 // TODO(myhuang): Here we might also have similar issues as those on Windows
38 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). 40 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383).
39 // Please note that is_opaque is true when we use this class for printing. 41 // Please note that is_opaque is true when we use this class for printing.
40 if (!is_opaque) { 42 // Fallback to bitmap when context is NULL.
43 if (!is_opaque || NULL == context) {
41 return BitmapPlatformDevice::Create(width, height, is_opaque); 44 return BitmapPlatformDevice::Create(width, height, is_opaque);
42 } 45 }
43 46
44 PlatformDevice* device = VectorPlatformDevice::create(width, height); 47 PlatformDevice* device =
48 VectorPlatformDevice::create(context, width, height);
45 return device; 49 return device;
46 } 50 }
47 51
48 } // namespace skia 52 } // namespace skia
49 53
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698