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

Side by Side Diff: src/core/SkBlitter.h

Issue 399593007: Let blitters be notified when they're done being used (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove constructor definition. Created 6 years, 5 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 | src/core/SkScan_AntiPath.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkBlitter_DEFINED 10 #ifndef SkBlitter_DEFINED
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 virtual SkShader::Context* getShaderContext() const; 69 virtual SkShader::Context* getShaderContext() const;
70 70
71 /** 71 /**
72 * Special methods for blitters that can blit more than one row at a time. 72 * Special methods for blitters that can blit more than one row at a time.
73 * This function returns the number of rows that this blitter could optimall y 73 * This function returns the number of rows that this blitter could optimall y
74 * process at a time. It is still required to support blitting one scanline 74 * process at a time. It is still required to support blitting one scanline
75 * at a time. 75 * at a time.
76 */ 76 */
77 virtual int requestRowsPreserved() const { return 1; } 77 virtual int requestRowsPreserved() const { return 1; }
78 78
79 /**
80 * This function allocates memory for the blitter that the blitter then owns .
81 * The memory can be used by the calling function at will, but it will be
82 * released when the blitter's destructor is called. This function returns
83 * NULL if no persistent memory is needed by the blitter.
84 */
85 virtual void* allocBlitMemory(size_t sz) {
86 return fBlitMemory.reset(sz, SkAutoMalloc::kReuse_OnShrink);
87 }
88
79 ///@name non-virtual helpers 89 ///@name non-virtual helpers
80 void blitMaskRegion(const SkMask& mask, const SkRegion& clip); 90 void blitMaskRegion(const SkMask& mask, const SkRegion& clip);
81 void blitRectRegion(const SkIRect& rect, const SkRegion& clip); 91 void blitRectRegion(const SkIRect& rect, const SkRegion& clip);
82 void blitRegion(const SkRegion& clip); 92 void blitRegion(const SkRegion& clip);
83 ///@} 93 ///@}
84 94
85 /** @name Factories 95 /** @name Factories
86 Return the correct blitter to use given the specified context. 96 Return the correct blitter to use given the specified context.
87 */ 97 */
88 static SkBlitter* Choose(const SkBitmap& device, 98 static SkBlitter* Choose(const SkBitmap& device,
89 const SkMatrix& matrix, 99 const SkMatrix& matrix,
90 const SkPaint& paint, 100 const SkPaint& paint,
91 SkTBlitterAllocator*, 101 SkTBlitterAllocator*,
92 bool drawCoverage = false); 102 bool drawCoverage = false);
93 103
94 static SkBlitter* ChooseSprite(const SkBitmap& device, 104 static SkBlitter* ChooseSprite(const SkBitmap& device,
95 const SkPaint&, 105 const SkPaint&,
96 const SkBitmap& src, 106 const SkBitmap& src,
97 int left, int top, 107 int left, int top,
98 SkTBlitterAllocator*); 108 SkTBlitterAllocator*);
99 ///@} 109 ///@}
100 110
111 protected:
112
113 SkAutoMalloc fBlitMemory;
114
101 private: 115 private:
102 }; 116 };
103 117
104 /** This blitter silently never draws anything. 118 /** This blitter silently never draws anything.
105 */ 119 */
106 class SkNullBlitter : public SkBlitter { 120 class SkNullBlitter : public SkBlitter {
107 public: 121 public:
108 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 122 virtual void blitH(int x, int y, int width) SK_OVERRIDE;
109 virtual void blitAntiH(int x, int y, const SkAlpha[], 123 virtual void blitAntiH(int x, int y, const SkAlpha[],
110 const int16_t runs[]) SK_OVERRIDE; 124 const int16_t runs[]) SK_OVERRIDE;
(...skipping 19 matching lines...) Expand all
130 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 144 virtual void blitH(int x, int y, int width) SK_OVERRIDE;
131 virtual void blitAntiH(int x, int y, const SkAlpha[], 145 virtual void blitAntiH(int x, int y, const SkAlpha[],
132 const int16_t runs[]) SK_OVERRIDE; 146 const int16_t runs[]) SK_OVERRIDE;
133 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 147 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE;
134 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 148 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
135 virtual void blitAntiRect(int x, int y, int width, int height, 149 virtual void blitAntiRect(int x, int y, int width, int height,
136 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; 150 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE;
137 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; 151 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE;
138 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; 152 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE;
139 153
154 virtual void* allocBlitMemory(size_t sz) SK_OVERRIDE {
155 return fBlitter->allocBlitMemory(sz);
156 }
157
140 private: 158 private:
141 SkBlitter* fBlitter; 159 SkBlitter* fBlitter;
142 SkIRect fClipRect; 160 SkIRect fClipRect;
143 }; 161 };
144 162
145 /** Wraps another (real) blitter, and ensures that the real blitter is only 163 /** Wraps another (real) blitter, and ensures that the real blitter is only
146 called with coordinates that have been clipped by the specified clipRgn. 164 called with coordinates that have been clipped by the specified clipRgn.
147 This means the caller need not perform the clipping ahead of time. 165 This means the caller need not perform the clipping ahead of time.
148 */ 166 */
149 class SkRgnClipBlitter : public SkBlitter { 167 class SkRgnClipBlitter : public SkBlitter {
150 public: 168 public:
151 void init(SkBlitter* blitter, const SkRegion* clipRgn) { 169 void init(SkBlitter* blitter, const SkRegion* clipRgn) {
152 SkASSERT(clipRgn && !clipRgn->isEmpty()); 170 SkASSERT(clipRgn && !clipRgn->isEmpty());
153 fBlitter = blitter; 171 fBlitter = blitter;
154 fRgn = clipRgn; 172 fRgn = clipRgn;
155 } 173 }
156 174
157 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 175 virtual void blitH(int x, int y, int width) SK_OVERRIDE;
158 virtual void blitAntiH(int x, int y, const SkAlpha[], 176 virtual void blitAntiH(int x, int y, const SkAlpha[],
159 const int16_t runs[]) SK_OVERRIDE; 177 const int16_t runs[]) SK_OVERRIDE;
160 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 178 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE;
161 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 179 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
162 virtual void blitAntiRect(int x, int y, int width, int height, 180 virtual void blitAntiRect(int x, int y, int width, int height,
163 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; 181 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE;
164 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; 182 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE;
165 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; 183 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE;
166 184
185 virtual void* allocBlitMemory(size_t sz) SK_OVERRIDE {
186 return fBlitter->allocBlitMemory(sz);
187 }
188
167 private: 189 private:
168 SkBlitter* fBlitter; 190 SkBlitter* fBlitter;
169 const SkRegion* fRgn; 191 const SkRegion* fRgn;
170 }; 192 };
171 193
172 /** Factory to set up the appropriate most-efficient wrapper blitter 194 /** Factory to set up the appropriate most-efficient wrapper blitter
173 to apply a clip. Returns a pointer to a member, so lifetime must 195 to apply a clip. Returns a pointer to a member, so lifetime must
174 be managed carefully. 196 be managed carefully.
175 */ 197 */
176 class SkBlitterClipper { 198 class SkBlitterClipper {
177 public: 199 public:
178 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, 200 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip,
179 const SkIRect* bounds = NULL); 201 const SkIRect* bounds = NULL);
180 202
181 private: 203 private:
182 SkNullBlitter fNullBlitter; 204 SkNullBlitter fNullBlitter;
183 SkRectClipBlitter fRectBlitter; 205 SkRectClipBlitter fRectBlitter;
184 SkRgnClipBlitter fRgnBlitter; 206 SkRgnClipBlitter fRgnBlitter;
185 }; 207 };
186 208
187 #endif 209 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkScan_AntiPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698