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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 cairo_t* GetContext(); | 49 cairo_t* GetContext(); |
50 cairo_surface_t* GetSurface(); | 50 cairo_surface_t* GetSurface(); |
51 | 51 |
52 // Sets the transform and clip operations. This will not update the Cairo | 52 // 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 | 53 // surface, but will mark the config as dirty. The next call of LoadConfig |
54 // will pick up these changes. | 54 // will pick up these changes. |
55 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); | 55 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); |
56 | 56 |
57 protected: | 57 protected: |
58 friend class base::RefCounted<BitmapPlatformDeviceData>; | |
59 | |
60 ~BitmapPlatformDeviceData(); | |
61 | |
62 void LoadConfig(); | 58 void LoadConfig(); |
63 | 59 |
64 // The Cairo surface inside this DC. | 60 // The Cairo surface inside this DC. |
65 cairo_t* context_; | 61 cairo_t* context_; |
66 cairo_surface_t *const surface_; | 62 cairo_surface_t *const surface_; |
67 | 63 |
68 // True when there is a transform or clip that has not been set to the | 64 // True when there is a transform or clip that has not been set to the |
69 // surface. The surface is retrieved for every text operation, and the | 65 // surface. The surface is retrieved for every text operation, and the |
70 // transform and clip do not change as much. We can save time by not loading | 66 // transform and clip do not change as much. We can save time by not loading |
71 // the clip and transform for every one. | 67 // the clip and transform for every one. |
72 bool config_dirty_; | 68 bool config_dirty_; |
73 | 69 |
74 // Translation assigned to the DC: we need to keep track of this separately | 70 // Translation assigned to the DC: we need to keep track of this separately |
75 // so it can be updated even if the DC isn't created yet. | 71 // so it can be updated even if the DC isn't created yet. |
76 SkMatrix transform_; | 72 SkMatrix transform_; |
77 | 73 |
78 // The current clipping | 74 // The current clipping |
79 SkRegion clip_region_; | 75 SkRegion clip_region_; |
80 | 76 |
81 // Disallow copy & assign. | 77 // Disallow copy & assign. |
82 BitmapPlatformDeviceData(const BitmapPlatformDeviceData&); | 78 BitmapPlatformDeviceData(const BitmapPlatformDeviceData&); |
83 BitmapPlatformDeviceData& operator=( | 79 BitmapPlatformDeviceData& operator=( |
84 const BitmapPlatformDeviceData&); | 80 const BitmapPlatformDeviceData&); |
| 81 |
| 82 private: |
| 83 friend class base::RefCounted<BitmapPlatformDeviceData>; |
| 84 |
| 85 ~BitmapPlatformDeviceData(); |
85 }; | 86 }; |
86 | 87 |
87 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( | 88 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( |
88 cairo_surface_t* surface) | 89 cairo_surface_t* surface) |
89 : surface_(surface), | 90 : surface_(surface), |
90 config_dirty_(true) { // Want to load the config next time. | 91 config_dirty_(true) { // Want to load the config next time. |
91 context_ = cairo_create(surface); | 92 context_ = cairo_create(surface); |
92 } | 93 } |
93 | 94 |
94 BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { | 95 BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 data_->SetMatrixClip(transform, region); | 202 data_->SetMatrixClip(transform, region); |
202 } | 203 } |
203 | 204 |
204 BitmapPlatformDevice& BitmapPlatformDevice::operator=( | 205 BitmapPlatformDevice& BitmapPlatformDevice::operator=( |
205 const BitmapPlatformDevice& other) { | 206 const BitmapPlatformDevice& other) { |
206 data_ = other.data_; | 207 data_ = other.data_; |
207 return *this; | 208 return *this; |
208 } | 209 } |
209 | 210 |
210 } // namespace skia | 211 } // namespace skia |
OLD | NEW |