Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: skia/ext/bitmap_platform_device_cairo.h

Issue 1963713002: Replace setMatrixClip() with BeginPlatformPaint() logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compensate for any outstanding saveLayer() calls Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_cairo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_ 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_ 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Constructs a device with size |width| * |height| with contents initialized 74 // Constructs a device with size |width| * |height| with contents initialized
75 // to zero. |is_opaque| should be set if the caller knows the bitmap will be 75 // to zero. |is_opaque| should be set if the caller knows the bitmap will be
76 // completely opaque and allows some optimizations. 76 // completely opaque and allows some optimizations.
77 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); 77 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
78 78
79 // This doesn't take ownership of |data|. If |data| is NULL, the contents 79 // This doesn't take ownership of |data|. If |data| is NULL, the contents
80 // of the device are initialized to 0. 80 // of the device are initialized to 0.
81 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, 81 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
82 uint8_t* data); 82 uint8_t* data);
83 83
84 // Overridden from SkBaseDevice:
85 void setMatrixClip(const SkMatrix& transform,
86 const SkRegion& region,
87 const SkClipStack&) override;
88
89 protected: 84 protected:
90 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; 85 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
91 86
92 private: 87 private:
93 // Overridden from PlatformDevice: 88 // Overridden from PlatformDevice:
94 cairo_t* BeginPlatformPaint() override; 89 cairo_t* BeginPlatformPaint(const SkMatrix& transform,
90 const SkIRect& clip_bounds) override;
95 91
96 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, 92 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
97 cairo_surface_t* surface); 93 cairo_surface_t* surface);
98 94
99 // Sets the transform and clip operations. This will not update the Cairo
100 // context, but will mark the config as dirty. The next call of LoadConfig
101 // will pick up these changes.
102 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
103
104 // Loads the current transform and clip into the context. 95 // Loads the current transform and clip into the context.
105 void LoadConfig(); 96 void LoadConfig(const SkMatrix& transform, const SkIRect& clip_bounds);
106 97
107 // Graphics context used to draw into the surface. 98 // Graphics context used to draw into the surface.
108 cairo_t* cairo_; 99 cairo_t* cairo_;
109 100
110 // True when there is a transform or clip that has not been set to the 101 // True when there is a transform or clip that has not been set to the
111 // context. The context is retrieved for every text operation, and the 102 // context. The context is retrieved for every text operation, and the
112 // transform and clip do not change as much. We can save time by not loading 103 // transform and clip do not change as much. We can save time by not loading
113 // the clip and transform for every one. 104 // the clip and transform for every one.
114 bool config_dirty_; 105 bool config_dirty_;
115 106
116 // Translation assigned to the context: we need to keep track of this
117 // separately so it can be updated even if the context isn't created yet.
118 SkMatrix transform_;
119
120 // The current clipping
121 SkRegion clip_region_;
122
123 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 107 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
124 friend class ScopedPlatformPaint; 108 friend class ScopedPlatformPaint;
125 }; 109 };
126 110
127 } // namespace skia 111 } // namespace skia
128 112
129 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_ 113 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_cairo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698