| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "skia/ext/bitmap_platform_device_data.h" | 6 #include "skia/ext/bitmap_platform_device_data.h" |
| 7 #include "skia/ext/platform_canvas.h" | 7 #include "skia/ext/platform_canvas.h" |
| 8 | 8 |
| 9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
| 10 #include <cairo.h> | 10 #include <cairo.h> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bool is_opaque, | 126 bool is_opaque, |
| 127 uint8_t* data) { | 127 uint8_t* data) { |
| 128 cairo_surface_t* surface = cairo_image_surface_create_for_data( | 128 cairo_surface_t* surface = cairo_image_surface_create_for_data( |
| 129 data, CAIRO_FORMAT_ARGB32, width, height, | 129 data, CAIRO_FORMAT_ARGB32, width, height, |
| 130 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width)); | 130 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width)); |
| 131 | 131 |
| 132 return Create(width, height, is_opaque, surface); | 132 return Create(width, height, is_opaque, surface); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // The device will own the bitmap, which corresponds to also owning the pixel | 135 // The device will own the bitmap, which corresponds to also owning the pixel |
| 136 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. | 136 // data. Therefore, we do not transfer ownership to the SkBitmapDevice's bitmap. |
| 137 BitmapPlatformDevice::BitmapPlatformDevice( | 137 BitmapPlatformDevice::BitmapPlatformDevice( |
| 138 const SkBitmap& bitmap, | 138 const SkBitmap& bitmap, |
| 139 BitmapPlatformDeviceData* data) | 139 BitmapPlatformDeviceData* data) |
| 140 : SkDevice(bitmap), | 140 : SkBitmapDevice(bitmap), |
| 141 data_(data) { | 141 data_(data) { |
| 142 SetPlatformDevice(this, this); | 142 SetPlatformDevice(this, this); |
| 143 } | 143 } |
| 144 | 144 |
| 145 BitmapPlatformDevice::~BitmapPlatformDevice() { | 145 BitmapPlatformDevice::~BitmapPlatformDevice() { |
| 146 } | 146 } |
| 147 | 147 |
| 148 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 148 SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
| 149 SkBitmap::Config config, int width, int height, bool isOpaque, | 149 SkBitmap::Config config, int width, int height, bool isOpaque, |
| 150 Usage /*usage*/) { | 150 Usage /*usage*/) { |
| 151 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 151 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 152 return BitmapPlatformDevice::Create(width, height, isOpaque); | 152 return BitmapPlatformDevice::Create(width, height, isOpaque); |
| 153 } | 153 } |
| 154 | 154 |
| 155 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { | 155 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { |
| 156 data_->LoadConfig(); | 156 data_->LoadConfig(); |
| 157 cairo_t* cairo = data_->bitmap_context(); | 157 cairo_t* cairo = data_->bitmap_context(); |
| 158 cairo_surface_t* surface = cairo_get_target(cairo); | 158 cairo_surface_t* surface = cairo_get_target(cairo); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 173 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 173 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
| 174 const SkRegion& region, | 174 const SkRegion& region, |
| 175 const SkClipStack&) { | 175 const SkClipStack&) { |
| 176 data_->SetMatrixClip(transform, region); | 176 data_->SetMatrixClip(transform, region); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // PlatformCanvas impl | 179 // PlatformCanvas impl |
| 180 | 180 |
| 181 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, | 181 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, |
| 182 uint8_t* data, OnFailureType failureType) { | 182 uint8_t* data, OnFailureType failureType) { |
| 183 skia::RefPtr<SkDevice> dev = skia::AdoptRef( | 183 skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef( |
| 184 BitmapPlatformDevice::Create(width, height, is_opaque, data)); | 184 BitmapPlatformDevice::Create(width, height, is_opaque, data)); |
| 185 return CreateCanvas(dev, failureType); | 185 return CreateCanvas(dev, failureType); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Port of PlatformBitmap to linux | 188 // Port of PlatformBitmap to linux |
| 189 PlatformBitmap::~PlatformBitmap() { | 189 PlatformBitmap::~PlatformBitmap() { |
| 190 cairo_destroy(surface_); | 190 cairo_destroy(surface_); |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 193 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 210 cairo_surface_destroy(surf); | 210 cairo_surface_destroy(surf); |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 | 213 |
| 214 surface_ = cairo_create(surf); | 214 surface_ = cairo_create(surf); |
| 215 cairo_surface_destroy(surf); | 215 cairo_surface_destroy(surf); |
| 216 return true; | 216 return true; |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace skia | 219 } // namespace skia |
| OLD | NEW |