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

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

Issue 1793883002: add blitprocs to shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 Context* fCtx;
147 SkXfermode* fXfer;
148 enum { N = 2 };
149 void* fStorage[N];
150 };
151 typedef void (*BlitProc)(BlitState*,
152 int x, int y, const SkPixmap&, int count, const SkAlpha[]);
153 BlitProc chooseBlitProc(const SkImageInfo& info, BlitState* state) {
154 return this->onChooseBlitProc(info, state);
155 }
156
145 /** 157 /**
146 * The const void* ctx is only const because all the implementations are const. 158 * The const void* ctx is only const because all the implementations are const.
147 * This can be changed to non-const if a new shade proc needs to change the ctx. 159 * This can be changed to non-const if a new shade proc needs to change the ctx.
148 */ 160 */
149 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in t count); 161 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in t count);
150 virtual ShadeProc asAShadeProc(void** ctx); 162 virtual ShadeProc asAShadeProc(void** ctx);
151 163
152 /** 164 /**
153 * Similar to shadeSpan, but only returns the alpha-channel for a span. 165 * Similar to shadeSpan, but only returns the alpha-channel for a span.
154 * The default implementation calls shadeSpan() and then extracts the a lpha 166 * The default implementation calls shadeSpan() and then extracts the a lpha
(...skipping 13 matching lines...) Expand all
168 kFixedStepInX_MatrixClass, // fast perspective, need to call fi xedStepInX() each 180 kFixedStepInX_MatrixClass, // fast perspective, need to call fi xedStepInX() each
169 // scanline 181 // scanline
170 kPerspective_MatrixClass // slow perspective, need to mappoin ts each pixel 182 kPerspective_MatrixClass // slow perspective, need to mappoin ts each pixel
171 }; 183 };
172 static MatrixClass ComputeMatrixClass(const SkMatrix&); 184 static MatrixClass ComputeMatrixClass(const SkMatrix&);
173 185
174 uint8_t getPaintAlpha() const { return fPaintAlpha; } 186 uint8_t getPaintAlpha() const { return fPaintAlpha; }
175 const SkMatrix& getTotalInverse() const { return fTotalInverse; } 187 const SkMatrix& getTotalInverse() const { return fTotalInverse; }
176 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; } 188 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; }
177 const SkMatrix& getCTM() const { return fCTM; } 189 const SkMatrix& getCTM() const { return fCTM; }
190
191 virtual BlitProc onChooseBlitProc(const SkImageInfo&, BlitState*) {
192 return nullptr;
193 }
194
178 private: 195 private:
179 SkMatrix fCTM; 196 SkMatrix fCTM;
180 SkMatrix fTotalInverse; 197 SkMatrix fTotalInverse;
181 uint8_t fPaintAlpha; 198 uint8_t fPaintAlpha;
182 uint8_t fTotalInverseClass; 199 uint8_t fTotalInverseClass;
183 200
184 typedef SkNoncopyable INHERITED; 201 typedef SkNoncopyable INHERITED;
185 }; 202 };
186 203
187 /** 204 /**
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 SkMatrix fLocalMatrix; 472 SkMatrix fLocalMatrix;
456 473
457 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. 474 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor.
458 friend class SkLocalMatrixShader; 475 friend class SkLocalMatrixShader;
459 friend class SkBitmapProcShader; // for computeTotalInverse() 476 friend class SkBitmapProcShader; // for computeTotalInverse()
460 477
461 typedef SkFlattenable INHERITED; 478 typedef SkFlattenable INHERITED;
462 }; 479 };
463 480
464 #endif 481 #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