| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
| 8 | 8 |
| 9 namespace skia { | 9 namespace skia { |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // the backing store for a Skia bitmap and we reference count it so that we can | 40 // the backing store for a Skia bitmap and we reference count it so that we can |
| 41 // copy BitmapPlatformDevice objects without having to copy all the image | 41 // copy BitmapPlatformDevice objects without having to copy all the image |
| 42 // data. | 42 // data. |
| 43 // ----------------------------------------------------------------------------- | 43 // ----------------------------------------------------------------------------- |
| 44 class BitmapPlatformDevice::BitmapPlatformDeviceData | 44 class BitmapPlatformDevice::BitmapPlatformDeviceData |
| 45 : public base::RefCounted<BitmapPlatformDeviceData> { | 45 : public base::RefCounted<BitmapPlatformDeviceData> { |
| 46 public: | 46 public: |
| 47 explicit BitmapPlatformDeviceData(cairo_surface_t* surface); | 47 explicit BitmapPlatformDeviceData(cairo_surface_t* surface); |
| 48 | 48 |
| 49 cairo_t* GetContext(); | 49 cairo_t* GetContext(); |
| 50 cairo_surface_t* GetSurface(); | |
| 51 | 50 |
| 52 // Sets the transform and clip operations. This will not update the Cairo | 51 // Sets the transform and clip operations. This will not update the Cairo |
| 53 // surface, but will mark the config as dirty. The next call of LoadConfig | 52 // surface, but will mark the config as dirty. The next call of LoadConfig |
| 54 // will pick up these changes. | 53 // will pick up these changes. |
| 55 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); | 54 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); |
| 56 | 55 |
| 57 protected: | 56 protected: |
| 58 void LoadConfig(); | 57 void LoadConfig(); |
| 59 | 58 |
| 60 // The Cairo surface inside this DC. | 59 // The Cairo surface inside this DC. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 102 } |
| 104 | 103 |
| 105 void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip( | 104 void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip( |
| 106 const SkMatrix& transform, | 105 const SkMatrix& transform, |
| 107 const SkRegion& region) { | 106 const SkRegion& region) { |
| 108 transform_ = transform; | 107 transform_ = transform; |
| 109 clip_region_ = region; | 108 clip_region_ = region; |
| 110 config_dirty_ = true; | 109 config_dirty_ = true; |
| 111 } | 110 } |
| 112 | 111 |
| 113 cairo_surface_t* | |
| 114 BitmapPlatformDevice::BitmapPlatformDeviceData::GetSurface() { | |
| 115 // TODO(brettw) this function should be removed. | |
| 116 LoadConfig(); | |
| 117 return surface_; | |
| 118 } | |
| 119 | |
| 120 void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() { | 112 void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() { |
| 121 if (!config_dirty_ || !context_) | 113 if (!config_dirty_ || !context_) |
| 122 return; // Nothing to do. | 114 return; // Nothing to do. |
| 123 config_dirty_ = false; | 115 config_dirty_ = false; |
| 124 | 116 |
| 125 // Load the identity matrix since this is what our clip is relative to. | 117 // Load the identity matrix since this is what our clip is relative to. |
| 126 cairo_matrix_t cairo_matrix; | 118 cairo_matrix_t cairo_matrix; |
| 127 cairo_matrix_init_identity(&cairo_matrix); | 119 cairo_matrix_init_identity(&cairo_matrix); |
| 128 cairo_set_matrix(context_, &cairo_matrix); | 120 cairo_set_matrix(context_, &cairo_matrix); |
| 129 | 121 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 data_->SetMatrixClip(transform, region); | 195 data_->SetMatrixClip(transform, region); |
| 204 } | 196 } |
| 205 | 197 |
| 206 BitmapPlatformDevice& BitmapPlatformDevice::operator=( | 198 BitmapPlatformDevice& BitmapPlatformDevice::operator=( |
| 207 const BitmapPlatformDevice& other) { | 199 const BitmapPlatformDevice& other) { |
| 208 data_ = other.data_; | 200 data_ = other.data_; |
| 209 return *this; | 201 return *this; |
| 210 } | 202 } |
| 211 | 203 |
| 212 } // namespace skia | 204 } // namespace skia |
| OLD | NEW |