| 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 : SkDevice(bitmap), | 123 : PlatformDevice(bitmap), |
| 124 data_(data) { | 124 data_(data) { |
| 125 SetPlatformDevice(this, this); | |
| 126 } | 125 } |
| 127 | 126 |
| 128 BitmapPlatformDevice::~BitmapPlatformDevice() { | 127 BitmapPlatformDevice::~BitmapPlatformDevice() { |
| 129 } | 128 } |
| 130 | 129 |
| 131 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 130 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
| 132 SkBitmap::Config config, int width, int height, bool isOpaque, | 131 SkBitmap::Config config, int width, int height, bool isOpaque, |
| 133 Usage /*usage*/) { | 132 Usage /*usage*/) { |
| 134 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 133 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 135 return BitmapPlatformDevice::Create(width, height, isOpaque); | 134 return BitmapPlatformDevice::Create(width, height, isOpaque); |
| 136 } | 135 } |
| 137 | 136 |
| 138 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { | 137 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { |
| 139 data_->LoadConfig(); | 138 data_->LoadConfig(); |
| 140 cairo_t* cairo = data_->bitmap_context(); | 139 cairo_t* cairo = data_->bitmap_context(); |
| 141 cairo_surface_t* surface = cairo_get_target(cairo); | 140 cairo_surface_t* surface = cairo_get_target(cairo); |
| 142 // Tell cairo to flush anything it has pending. | 141 // Tell cairo to flush anything it has pending. |
| 143 cairo_surface_flush(surface); | 142 cairo_surface_flush(surface); |
| 144 // Tell Cairo that we (probably) modified (actually, will modify) its pixel | 143 // Tell Cairo that we (probably) modified (actually, will modify) its pixel |
| 145 // buffer directly. | 144 // buffer directly. |
| 146 cairo_surface_mark_dirty(surface); | 145 cairo_surface_mark_dirty(surface); |
| 147 return cairo; | 146 return cairo; |
| 148 } | 147 } |
| 149 | 148 |
| 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 | |
| 156 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 149 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
| 157 const SkRegion& region, | 150 const SkRegion& region, |
| 158 const SkClipStack&) { | 151 const SkClipStack&) { |
| 159 data_->SetMatrixClip(transform, region); | 152 data_->SetMatrixClip(transform, region); |
| 160 } | 153 } |
| 161 | 154 |
| 162 } // namespace skia | 155 } // namespace skia |
| OLD | NEW |