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_platform_device_cairo_linux.cc

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // static 71 // static
72 PlatformDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context, 72 SkDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context, int width,
73 int width, int height, 73 int height, bool isOpaque) {
74 bool isOpaque) {
75 // TODO(myhuang): Here we might also have similar issues as those on Windows 74 // TODO(myhuang): Here we might also have similar issues as those on Windows
76 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). 75 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383).
77 // Please note that is_opaque is true when we use this class for printing. 76 // Please note that is_opaque is true when we use this class for printing.
78 // Fallback to bitmap when context is NULL. 77 // Fallback to bitmap when context is NULL.
79 if (!isOpaque || NULL == context) { 78 if (!isOpaque || NULL == context) {
80 return BitmapPlatformDevice::Create(width, height, isOpaque); 79 return BitmapPlatformDevice::Create(width, height, isOpaque);
81 } 80 }
82 81
83 SkASSERT(cairo_status(context) == CAIRO_STATUS_SUCCESS); 82 SkASSERT(cairo_status(context) == CAIRO_STATUS_SUCCESS);
84 SkASSERT(width > 0); 83 SkASSERT(width > 0);
85 SkASSERT(height > 0); 84 SkASSERT(height > 0);
86 85
87 SkBitmap bitmap; 86 SkBitmap bitmap;
88 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 87 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
89 88
90 return new VectorPlatformDeviceCairo(context, bitmap); 89 return new VectorPlatformDeviceCairo(context, bitmap);
91 } 90 }
92 91
93 VectorPlatformDeviceCairo::VectorPlatformDeviceCairo(PlatformSurface context, 92 VectorPlatformDeviceCairo::VectorPlatformDeviceCairo(PlatformSurface context,
94 const SkBitmap& bitmap) 93 const SkBitmap& bitmap)
95 : PlatformDevice(bitmap), 94 : SkDevice(bitmap),
96 context_(context) { 95 context_(context) {
97 SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); 96 SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config);
98 97
98 SetPlatformDevice(this, this);
99
99 // Increase the reference count to keep the context alive. 100 // Increase the reference count to keep the context alive.
100 cairo_reference(context_); 101 cairo_reference(context_);
101 102
102 transform_.reset(); 103 transform_.reset();
103 } 104 }
104 105
105 VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() { 106 VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() {
106 // Un-ref |context_| since we referenced it in the constructor. 107 // Un-ref |context_| since we referenced it in the constructor.
107 cairo_destroy(context_); 108 cairo_destroy(context_);
108 } 109 }
109 110
110 PlatformDevice::PlatformSurface 111 PlatformSurface VectorPlatformDeviceCairo::BeginPlatformPaint() {
111 VectorPlatformDeviceCairo::BeginPlatformPaint() {
112 return context_; 112 return context_;
113 } 113 }
114 114
115 void VectorPlatformDeviceCairo::DrawToNativeContext(
116 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) {
117 // Should never be called on Linux.
118 SkASSERT(false);
119 }
120
115 SkDevice* VectorPlatformDeviceCairo::onCreateCompatibleDevice( 121 SkDevice* VectorPlatformDeviceCairo::onCreateCompatibleDevice(
116 SkBitmap::Config config, 122 SkBitmap::Config config,
117 int width, int height, 123 int width, int height,
118 bool isOpaque, Usage) { 124 bool isOpaque, Usage) {
119 SkASSERT(config == SkBitmap::kARGB_8888_Config); 125 SkASSERT(config == SkBitmap::kARGB_8888_Config);
120 return CreateDevice(NULL, width, height, isOpaque); 126 return CreateDevice(NULL, width, height, isOpaque);
121 } 127 }
122 128
123 uint32_t VectorPlatformDeviceCairo::getDeviceCapabilities() { 129 uint32_t VectorPlatformDeviceCairo::getDeviceCapabilities() {
124 return SkDevice::getDeviceCapabilities() | kVector_Capability; 130 return SkDevice::getDeviceCapabilities() | kVector_Capability;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 DCHECK(it->second.font_stream); 686 DCHECK(it->second.font_stream);
681 687
682 cairo_font_face_destroy(it->second.cairo_face); 688 cairo_font_face_destroy(it->second.cairo_face);
683 // |it->second.ft_face| is handled by Cairo. 689 // |it->second.ft_face| is handled by Cairo.
684 it->second.font_stream->unref(); 690 it->second.font_stream->unref();
685 } 691 }
686 g_font_cache->clear(); 692 g_font_cache->clear();
687 } 693 }
688 694
689 } // namespace skia 695 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/vector_platform_device_cairo_linux.h ('k') | skia/ext/vector_platform_device_emf_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698