OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_platform_device_cairo_linux.h" | 5 #include "skia/ext/vector_platform_device_cairo_linux.h" |
6 | 6 |
7 #include <cairo.h> | 7 #include <cairo.h> |
8 #include <cairo-ft.h> | 8 #include <cairo-ft.h> |
9 | 9 |
10 #include <ft2build.h> | 10 #include <ft2build.h> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 | 61 |
62 // Verify cairo surface after creation/modification. | 62 // Verify cairo surface after creation/modification. |
63 bool IsContextValid(cairo_t* context) { | 63 bool IsContextValid(cairo_t* context) { |
64 return cairo_status(context) == CAIRO_STATUS_SUCCESS; | 64 return cairo_status(context) == CAIRO_STATUS_SUCCESS; |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 namespace skia { | 69 namespace skia { |
70 | 70 |
71 SkDevice* VectorPlatformDeviceCairoFactory::newDevice(SkCanvas* ignored, | 71 SkDevice* VectorPlatformDeviceCairo::onCreateCompatibleDevice( |
72 SkBitmap::Config config, | 72 SkBitmap::Config config, int width, int height, bool isOpaque, Usage) { |
73 int width, int height, | |
74 bool isOpaque, | |
75 bool isForLayer) { | |
76 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 73 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
77 return CreateDevice(NULL, width, height, isOpaque); | 74 return VectorPlatformDeviceCairoFactory::CreateDevice(NULL, width, height, |
alokp
2011/06/28 16:19:46
Two things:
1. In chromium functions are defined i
| |
75 isOpaque); | |
78 } | 76 } |
79 | 77 |
80 // static | 78 // static |
81 PlatformDevice* VectorPlatformDeviceCairoFactory::CreateDevice(cairo_t* context, | 79 PlatformDevice* VectorPlatformDeviceCairoFactory::CreateDevice(cairo_t* context, |
82 int width, | 80 int width, |
83 int height, | 81 int height, |
84 bool isOpaque) { | 82 bool isOpaque) { |
85 // TODO(myhuang): Here we might also have similar issues as those on Windows | 83 // TODO(myhuang): Here we might also have similar issues as those on Windows |
86 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). | 84 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). |
87 // Please note that is_opaque is true when we use this class for printing. | 85 // Please note that is_opaque is true when we use this class for printing. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 cairo_reference(context_); | 120 cairo_reference(context_); |
123 | 121 |
124 transform_.reset(); | 122 transform_.reset(); |
125 } | 123 } |
126 | 124 |
127 VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() { | 125 VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() { |
128 // Un-ref |context_| since we referenced it in the constructor. | 126 // Un-ref |context_| since we referenced it in the constructor. |
129 cairo_destroy(context_); | 127 cairo_destroy(context_); |
130 } | 128 } |
131 | 129 |
132 SkDeviceFactory* VectorPlatformDeviceCairo::onNewDeviceFactory() { | |
133 return SkNEW(VectorPlatformDeviceCairoFactory); | |
134 } | |
135 | |
136 PlatformDevice::PlatformSurface | 130 PlatformDevice::PlatformSurface |
137 VectorPlatformDeviceCairo::BeginPlatformPaint() { | 131 VectorPlatformDeviceCairo::BeginPlatformPaint() { |
138 return context_; | 132 return context_; |
139 } | 133 } |
140 | 134 |
141 uint32_t VectorPlatformDeviceCairo::getDeviceCapabilities() { | 135 uint32_t VectorPlatformDeviceCairo::getDeviceCapabilities() { |
142 return SkDevice::getDeviceCapabilities() | kVector_Capability; | 136 return SkDevice::getDeviceCapabilities() | kVector_Capability; |
143 } | 137 } |
144 | 138 |
145 void VectorPlatformDeviceCairo::drawBitmap(const SkDraw& draw, | 139 void VectorPlatformDeviceCairo::drawBitmap(const SkDraw& draw, |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 DCHECK(it->second.font_stream); | 692 DCHECK(it->second.font_stream); |
699 | 693 |
700 cairo_font_face_destroy(it->second.cairo_face); | 694 cairo_font_face_destroy(it->second.cairo_face); |
701 // |it->second.ft_face| is handled by Cairo. | 695 // |it->second.ft_face| is handled by Cairo. |
702 it->second.font_stream->unref(); | 696 it->second.font_stream->unref(); |
703 } | 697 } |
704 g_font_cache->clear(); | 698 g_font_cache->clear(); |
705 } | 699 } |
706 | 700 |
707 } // namespace skia | 701 } // namespace skia |
OLD | NEW |