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

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

Issue 1839113002: Limit manual control of platform painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Privatize Created 4 years, 8 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
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 28 matching lines...) Expand all
39 // typically don't do alpha blending of drawables at the user level. Composite 39 // typically don't do alpha blending of drawables at the user level. Composite
40 // extensions aside.) 40 // extensions aside.)
41 // 41 //
42 // We don't use GdkPixbuf because its byte order differs from the rest. Most 42 // We don't use GdkPixbuf because its byte order differs from the rest. Most
43 // importantly, it differs from Cairo which, being a system library, is 43 // importantly, it differs from Cairo which, being a system library, is
44 // something that we can't easily change. 44 // something that we can't easily change.
45 // ----------------------------------------------------------------------------- 45 // -----------------------------------------------------------------------------
46 46
47 namespace skia { 47 namespace skia {
48 48
49 class ScopedPlatformPaint;
50
49 // ----------------------------------------------------------------------------- 51 // -----------------------------------------------------------------------------
50 // This is the Linux bitmap backing for Skia. We create a Cairo image surface 52 // This is the Linux bitmap backing for Skia. We create a Cairo image surface
51 // to store the backing buffer. This buffer is BGRA in memory (on little-endian 53 // to store the backing buffer. This buffer is BGRA in memory (on little-endian
52 // machines). 54 // machines).
53 // 55 //
54 // For now we are also using Cairo to paint to the Drawables so we provide an 56 // For now we are also using Cairo to paint to the Drawables so we provide an
55 // accessor for getting the surface. 57 // accessor for getting the surface.
56 // 58 //
57 // This is all quite ok for test_shell. In the future we will want to use 59 // This is all quite ok for test_shell. In the future we will want to use
58 // shared memory between the renderer and the main process at least. In this 60 // shared memory between the renderer and the main process at least. In this
(...skipping 18 matching lines...) Expand all
77 // 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
78 // of the device are initialized to 0. 80 // of the device are initialized to 0.
79 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, 81 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
80 uint8_t* data); 82 uint8_t* data);
81 83
82 // Overridden from SkBaseDevice: 84 // Overridden from SkBaseDevice:
83 void setMatrixClip(const SkMatrix& transform, 85 void setMatrixClip(const SkMatrix& transform,
84 const SkRegion& region, 86 const SkRegion& region,
85 const SkClipStack&) override; 87 const SkClipStack&) override;
86 88
87 // Overridden from PlatformDevice:
88 cairo_t* BeginPlatformPaint() override;
89
90 protected: 89 protected:
91 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; 90 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
92 91
93 private: 92 private:
93 // Overridden from PlatformDevice:
94 cairo_t* BeginPlatformPaint() override;
95
94 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, 96 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
95 cairo_surface_t* surface); 97 cairo_surface_t* surface);
96 98
97 // Sets the transform and clip operations. This will not update the Cairo 99 // Sets the transform and clip operations. This will not update the Cairo
98 // context, but will mark the config as dirty. The next call of LoadConfig 100 // context, but will mark the config as dirty. The next call of LoadConfig
99 // will pick up these changes. 101 // will pick up these changes.
100 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); 102 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
101 103
102 // Loads the current transform and clip into the context. 104 // Loads the current transform and clip into the context.
103 void LoadConfig(); 105 void LoadConfig();
104 106
105 // Graphics context used to draw into the surface. 107 // Graphics context used to draw into the surface.
106 cairo_t* cairo_; 108 cairo_t* cairo_;
107 109
108 // True when there is a transform or clip that has not been set to the 110 // True when there is a transform or clip that has not been set to the
109 // context. The context is retrieved for every text operation, and the 111 // context. The context is retrieved for every text operation, and the
110 // transform and clip do not change as much. We can save time by not loading 112 // transform and clip do not change as much. We can save time by not loading
111 // the clip and transform for every one. 113 // the clip and transform for every one.
112 bool config_dirty_; 114 bool config_dirty_;
113 115
114 // Translation assigned to the context: we need to keep track of this 116 // Translation assigned to the context: we need to keep track of this
115 // separately so it can be updated even if the context isn't created yet. 117 // separately so it can be updated even if the context isn't created yet.
116 SkMatrix transform_; 118 SkMatrix transform_;
117 119
118 // The current clipping 120 // The current clipping
119 SkRegion clip_region_; 121 SkRegion clip_region_;
120 122
121 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 123 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
124 friend class ScopedPlatformPaint;
122 }; 125 };
123 126
124 } // namespace skia 127 } // namespace skia
125 128
126 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_ 129 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_win.cc ('k') | skia/ext/bitmap_platform_device_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698