| 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 19 matching lines...) Expand all Loading... |
| 30 // TODO(brettw) support non-rect clips. | 30 // TODO(brettw) support non-rect clips. |
| 31 SkIRect bounding = clip.getBounds(); | 31 SkIRect bounding = clip.getBounds(); |
| 32 cairo_rectangle(context, bounding.fLeft, bounding.fTop, | 32 cairo_rectangle(context, bounding.fLeft, bounding.fTop, |
| 33 bounding.fRight - bounding.fLeft, | 33 bounding.fRight - bounding.fLeft, |
| 34 bounding.fBottom - bounding.fTop); | 34 bounding.fBottom - bounding.fTop); |
| 35 cairo_clip(context); | 35 cairo_clip(context); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 SkDevice* BitmapPlatformDeviceFactory::newDevice(SkCanvas* ignored, | |
| 41 SkBitmap::Config config, | |
| 42 int width, int height, | |
| 43 bool isOpaque, | |
| 44 bool isForLayer) { | |
| 45 SkASSERT(config == SkBitmap::kARGB_8888_Config); | |
| 46 return BitmapPlatformDevice::Create(width, height, isOpaque); | |
| 47 } | |
| 48 | |
| 49 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( | 40 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( |
| 50 cairo_surface_t* surface) | 41 cairo_surface_t* surface) |
| 51 : surface_(surface), | 42 : surface_(surface), |
| 52 config_dirty_(true) { // Want to load the config next time. | 43 config_dirty_(true) { // Want to load the config next time. |
| 53 bitmap_context_ = cairo_create(surface); | 44 bitmap_context_ = cairo_create(surface); |
| 54 } | 45 } |
| 55 | 46 |
| 56 BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { | 47 BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { |
| 57 cairo_destroy(bitmap_context_); | 48 cairo_destroy(bitmap_context_); |
| 58 cairo_surface_destroy(surface_); | 49 cairo_surface_destroy(surface_); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 BitmapPlatformDevice::BitmapPlatformDevice( | 120 BitmapPlatformDevice::BitmapPlatformDevice( |
| 130 const SkBitmap& bitmap, | 121 const SkBitmap& bitmap, |
| 131 BitmapPlatformDeviceData* data) | 122 BitmapPlatformDeviceData* data) |
| 132 : PlatformDevice(bitmap), | 123 : PlatformDevice(bitmap), |
| 133 data_(data) { | 124 data_(data) { |
| 134 } | 125 } |
| 135 | 126 |
| 136 BitmapPlatformDevice::~BitmapPlatformDevice() { | 127 BitmapPlatformDevice::~BitmapPlatformDevice() { |
| 137 } | 128 } |
| 138 | 129 |
| 139 SkDeviceFactory* BitmapPlatformDevice::onNewDeviceFactory() { | 130 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
| 140 return SkNEW(BitmapPlatformDeviceFactory); | 131 SkBitmap::Config config, int width, int height, bool isOpaque, Usage) { |
| 132 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 133 return BitmapPlatformDevice::Create(width, height, isOpaque); |
| 141 } | 134 } |
| 142 | 135 |
| 143 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { | 136 cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { |
| 144 data_->LoadConfig(); | 137 data_->LoadConfig(); |
| 145 cairo_t* cairo = data_->bitmap_context(); | 138 cairo_t* cairo = data_->bitmap_context(); |
| 146 cairo_surface_t* surface = cairo_get_target(cairo); | 139 cairo_surface_t* surface = cairo_get_target(cairo); |
| 147 // Tell cairo to flush anything it has pending. | 140 // Tell cairo to flush anything it has pending. |
| 148 cairo_surface_flush(surface); | 141 cairo_surface_flush(surface); |
| 149 // Tell Cairo that we (probably) modified (actually, will modify) its pixel | 142 // Tell Cairo that we (probably) modified (actually, will modify) its pixel |
| 150 // buffer directly. | 143 // buffer directly. |
| 151 cairo_surface_mark_dirty(surface); | 144 cairo_surface_mark_dirty(surface); |
| 152 return cairo; | 145 return cairo; |
| 153 } | 146 } |
| 154 | 147 |
| 155 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 148 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
| 156 const SkRegion& region, | 149 const SkRegion& region, |
| 157 const SkClipStack&) { | 150 const SkClipStack&) { |
| 158 data_->SetMatrixClip(transform, region); | 151 data_->SetMatrixClip(transform, region); |
| 159 } | 152 } |
| 160 | 153 |
| 161 } // namespace skia | 154 } // namespace skia |
| OLD | NEW |