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/bitmap_platform_device_linux.h" | 5 #include "skia/ext/bitmap_platform_device_linux.h" |
6 | 6 |
7 #include "skia/ext/bitmap_platform_device_data.h" | 7 #include "skia/ext/bitmap_platform_device_data.h" |
8 | 8 |
9 #include <cairo/cairo.h> | 9 #include <cairo/cairo.h> |
10 | 10 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width)); | 113 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width)); |
114 | 114 |
115 return Create(width, height, is_opaque, surface); | 115 return Create(width, height, is_opaque, surface); |
116 } | 116 } |
117 | 117 |
118 // The device will own the bitmap, which corresponds to also owning the pixel | 118 // The device will own the bitmap, which corresponds to also owning the pixel |
119 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. | 119 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. |
120 BitmapPlatformDevice::BitmapPlatformDevice( | 120 BitmapPlatformDevice::BitmapPlatformDevice( |
121 const SkBitmap& bitmap, | 121 const SkBitmap& bitmap, |
122 BitmapPlatformDeviceData* data) | 122 BitmapPlatformDeviceData* data) |
123 : PlatformDevice(bitmap), | 123 : SkDevice(bitmap), |
124 data_(data) { | 124 data_(data) { |
| 125 SetPlatformDevice(this, this); |
125 } | 126 } |
126 | 127 |
127 BitmapPlatformDevice::~BitmapPlatformDevice() { | 128 BitmapPlatformDevice::~BitmapPlatformDevice() { |
128 } | 129 } |
129 | 130 |
130 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 131 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
131 SkBitmap::Config config, int width, int height, bool isOpaque, | 132 SkBitmap::Config config, int width, int height, bool isOpaque, |
132 Usage /*usage*/) { | 133 Usage /*usage*/) { |
133 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 134 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
134 return BitmapPlatformDevice::Create(width, height, isOpaque); | 135 return BitmapPlatformDevice::Create(width, height, isOpaque); |
135 } | 136 } |
136 | 137 |
137 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { | 138 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { |
138 data_->LoadConfig(); | 139 data_->LoadConfig(); |
139 cairo_t* cairo = data_->bitmap_context(); | 140 cairo_t* cairo = data_->bitmap_context(); |
140 cairo_surface_t* surface = cairo_get_target(cairo); | 141 cairo_surface_t* surface = cairo_get_target(cairo); |
141 // Tell cairo to flush anything it has pending. | 142 // Tell cairo to flush anything it has pending. |
142 cairo_surface_flush(surface); | 143 cairo_surface_flush(surface); |
143 // Tell Cairo that we (probably) modified (actually, will modify) its pixel | 144 // Tell Cairo that we (probably) modified (actually, will modify) its pixel |
144 // buffer directly. | 145 // buffer directly. |
145 cairo_surface_mark_dirty(surface); | 146 cairo_surface_mark_dirty(surface); |
146 return cairo; | 147 return cairo; |
147 } | 148 } |
148 | 149 |
| 150 void BitmapPlatformDevice::DrawToNativeContext( |
| 151 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { |
| 152 // Should never be called on Linux. |
| 153 SkASSERT(false); |
| 154 } |
| 155 |
149 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 156 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
150 const SkRegion& region, | 157 const SkRegion& region, |
151 const SkClipStack&) { | 158 const SkClipStack&) { |
152 data_->SetMatrixClip(transform, region); | 159 data_->SetMatrixClip(transform, region); |
153 } | 160 } |
154 | 161 |
155 } // namespace skia | 162 } // namespace skia |
OLD | NEW |