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

Side by Side Diff: include/core/SkShader.h

Issue 1810383004: allow more options for shader blitprocs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gcc hates my curlies Created 4 years, 9 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/SkBlitter_PM4f.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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkShader_DEFINED 8 #ifndef SkShader_DEFINED
9 #define SkShader_DEFINED 9 #define SkShader_DEFINED
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 /** 136 /**
137 * Called for each span of the object being drawn. Your subclass should 137 * Called for each span of the object being drawn. Your subclass should
138 * set the appropriate colors (with premultiplied alpha) that correspon d 138 * set the appropriate colors (with premultiplied alpha) that correspon d
139 * to the specified device coordinates. 139 * to the specified device coordinates.
140 */ 140 */
141 virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0; 141 virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0;
142 142
143 virtual void shadeSpan4f(int x, int y, SkPM4f[], int count); 143 virtual void shadeSpan4f(int x, int y, SkPM4f[], int count);
144 144
145 struct BlitState;
146 typedef void (*BlitBW)(BlitState*,
147 int x, int y, const SkPixmap&, int count);
148 typedef void (*BlitAA)(BlitState*,
149 int x, int y, const SkPixmap&, int count, const S kAlpha[]);
150
145 struct BlitState { 151 struct BlitState {
152 // inputs
146 Context* fCtx; 153 Context* fCtx;
147 SkXfermode* fXfer; 154 SkXfermode* fXfer;
155
156 // outputs
148 enum { N = 2 }; 157 enum { N = 2 };
149 void* fStorage[N]; 158 void* fStorage[N];
159 BlitBW fBlitBW;
160 BlitAA fBlitAA;
150 }; 161 };
151 typedef void (*BlitProc)(BlitState*, 162
152 int x, int y, const SkPixmap&, int count, const SkAlpha[]); 163 // Returns true if one or more of the blitprocs are set in the BlitState
153 BlitProc chooseBlitProc(const SkImageInfo& info, BlitState* state) { 164 bool chooseBlitProcs(const SkImageInfo& info, BlitState* state) {
154 return this->onChooseBlitProc(info, state); 165 state->fBlitBW = nullptr;
166 state->fBlitAA = nullptr;
167 if (this->onChooseBlitProcs(info, state)) {
168 SkASSERT(state->fBlitBW || state->fBlitAA);
169 return true;
170 }
171 return false;
155 } 172 }
156 173
157 /** 174 /**
158 * The const void* ctx is only const because all the implementations are const. 175 * The const void* ctx is only const because all the implementations are const.
159 * This can be changed to non-const if a new shade proc needs to change the ctx. 176 * This can be changed to non-const if a new shade proc needs to change the ctx.
160 */ 177 */
161 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in t count); 178 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in t count);
162 virtual ShadeProc asAShadeProc(void** ctx); 179 virtual ShadeProc asAShadeProc(void** ctx);
163 180
164 /** 181 /**
165 * Similar to shadeSpan, but only returns the alpha-channel for a span. 182 * Similar to shadeSpan, but only returns the alpha-channel for a span.
166 * The default implementation calls shadeSpan() and then extracts the a lpha 183 * The default implementation calls shadeSpan() and then extracts the a lpha
(...skipping 14 matching lines...) Expand all
181 // scanline 198 // scanline
182 kPerspective_MatrixClass // slow perspective, need to mappoin ts each pixel 199 kPerspective_MatrixClass // slow perspective, need to mappoin ts each pixel
183 }; 200 };
184 static MatrixClass ComputeMatrixClass(const SkMatrix&); 201 static MatrixClass ComputeMatrixClass(const SkMatrix&);
185 202
186 uint8_t getPaintAlpha() const { return fPaintAlpha; } 203 uint8_t getPaintAlpha() const { return fPaintAlpha; }
187 const SkMatrix& getTotalInverse() const { return fTotalInverse; } 204 const SkMatrix& getTotalInverse() const { return fTotalInverse; }
188 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; } 205 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; }
189 const SkMatrix& getCTM() const { return fCTM; } 206 const SkMatrix& getCTM() const { return fCTM; }
190 207
191 virtual BlitProc onChooseBlitProc(const SkImageInfo&, BlitState*) { 208 virtual bool onChooseBlitProcs(const SkImageInfo&, BlitState*) { return false; }
192 return nullptr;
193 }
194 209
195 private: 210 private:
196 SkMatrix fCTM; 211 SkMatrix fCTM;
197 SkMatrix fTotalInverse; 212 SkMatrix fTotalInverse;
198 uint8_t fPaintAlpha; 213 uint8_t fPaintAlpha;
199 uint8_t fTotalInverseClass; 214 uint8_t fTotalInverseClass;
200 215
201 typedef SkNoncopyable INHERITED; 216 typedef SkNoncopyable INHERITED;
202 }; 217 };
203 218
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 SkMatrix fLocalMatrix; 487 SkMatrix fLocalMatrix;
473 488
474 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. 489 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor.
475 friend class SkLocalMatrixShader; 490 friend class SkLocalMatrixShader;
476 friend class SkBitmapProcShader; // for computeTotalInverse() 491 friend class SkBitmapProcShader; // for computeTotalInverse()
477 492
478 typedef SkFlattenable INHERITED; 493 typedef SkFlattenable INHERITED;
479 }; 494 };
480 495
481 #endif 496 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBlitter_PM4f.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698