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

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

Issue 7754001: Revert 98230 - CL removing inheritance of SkDevice from PlatformDevice. (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 SkDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context, int width, 72 PlatformDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context,
73 int height, bool isOpaque) { 73 int width, int height,
74 bool isOpaque) {
74 // TODO(myhuang): Here we might also have similar issues as those on Windows 75 // TODO(myhuang): Here we might also have similar issues as those on Windows
75 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). 76 // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383).
76 // Please note that is_opaque is true when we use this class for printing. 77 // Please note that is_opaque is true when we use this class for printing.
77 // Fallback to bitmap when context is NULL. 78 // Fallback to bitmap when context is NULL.
78 if (!isOpaque || NULL == context) { 79 if (!isOpaque || NULL == context) {
79 return BitmapPlatformDevice::Create(width, height, isOpaque); 80 return BitmapPlatformDevice::Create(width, height, isOpaque);
80 } 81 }
81 82
82 SkASSERT(cairo_status(context) == CAIRO_STATUS_SUCCESS); 83 SkASSERT(cairo_status(context) == CAIRO_STATUS_SUCCESS);
83 SkASSERT(width > 0); 84 SkASSERT(width > 0);
84 SkASSERT(height > 0); 85 SkASSERT(height > 0);
85 86
86 SkBitmap bitmap; 87 SkBitmap bitmap;
87 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 88 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
88 89
89 return new VectorPlatformDeviceCairo(context, bitmap); 90 return new VectorPlatformDeviceCairo(context, bitmap);
90 } 91 }
91 92
92 VectorPlatformDeviceCairo::VectorPlatformDeviceCairo(PlatformSurface context, 93 VectorPlatformDeviceCairo::VectorPlatformDeviceCairo(PlatformSurface context,
93 const SkBitmap& bitmap) 94 const SkBitmap& bitmap)
94 : SkDevice(bitmap), 95 : PlatformDevice(bitmap),
95 context_(context) { 96 context_(context) {
96 SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); 97 SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config);
97 98
98 SetPlatformDevice(this, this);
99
100 // Increase the reference count to keep the context alive. 99 // Increase the reference count to keep the context alive.
101 cairo_reference(context_); 100 cairo_reference(context_);
102 101
103 transform_.reset(); 102 transform_.reset();
104 } 103 }
105 104
106 VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() { 105 VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() {
107 // Un-ref |context_| since we referenced it in the constructor. 106 // Un-ref |context_| since we referenced it in the constructor.
108 cairo_destroy(context_); 107 cairo_destroy(context_);
109 } 108 }
110 109
111 PlatformSurface VectorPlatformDeviceCairo::BeginPlatformPaint() { 110 PlatformDevice::PlatformSurface
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
121 SkDevice* VectorPlatformDeviceCairo::onCreateCompatibleDevice( 115 SkDevice* VectorPlatformDeviceCairo::onCreateCompatibleDevice(
122 SkBitmap::Config config, 116 SkBitmap::Config config,
123 int width, int height, 117 int width, int height,
124 bool isOpaque, Usage) { 118 bool isOpaque, Usage) {
125 SkASSERT(config == SkBitmap::kARGB_8888_Config); 119 SkASSERT(config == SkBitmap::kARGB_8888_Config);
126 return CreateDevice(NULL, width, height, isOpaque); 120 return CreateDevice(NULL, width, height, isOpaque);
127 } 121 }
128 122
129 uint32_t VectorPlatformDeviceCairo::getDeviceCapabilities() { 123 uint32_t VectorPlatformDeviceCairo::getDeviceCapabilities() {
130 return SkDevice::getDeviceCapabilities() | kVector_Capability; 124 return SkDevice::getDeviceCapabilities() | kVector_Capability;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 DCHECK(it->second.font_stream); 680 DCHECK(it->second.font_stream);
687 681
688 cairo_font_face_destroy(it->second.cairo_face); 682 cairo_font_face_destroy(it->second.cairo_face);
689 // |it->second.ft_face| is handled by Cairo. 683 // |it->second.ft_face| is handled by Cairo.
690 it->second.font_stream->unref(); 684 it->second.font_stream->unref();
691 } 685 }
692 g_font_cache->clear(); 686 g_font_cache->clear();
693 } 687 }
694 688
695 } // namespace skia 689 } // 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