| OLD | NEW |
| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * Called for each span of the object being drawn. Your subclass should | 139 * Called for each span of the object being drawn. Your subclass should |
| 140 * set the appropriate colors (with premultiplied alpha) that correspon
d | 140 * set the appropriate colors (with premultiplied alpha) that correspon
d |
| 141 * to the specified device coordinates. | 141 * to the specified device coordinates. |
| 142 */ | 142 */ |
| 143 virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0; | 143 virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0; |
| 144 | 144 |
| 145 virtual void shadeSpan4f(int x, int y, SkPM4f[], int count); | 145 virtual void shadeSpan4f(int x, int y, SkPM4f[], int count); |
| 146 | 146 |
| 147 struct BlitState { |
| 148 Context* fCtx; |
| 149 SkXfermode* fXfer; |
| 150 enum { N = 2 }; |
| 151 void* fStorage[N]; |
| 152 }; |
| 153 typedef void (*BlitProc)(BlitState*, |
| 154 int x, int y, const SkPixmap&, int count, const
SkAlpha[]); |
| 155 BlitProc chooseBlitProc(const SkImageInfo& info, BlitState* state) { |
| 156 return this->onChooseBlitProc(info, state); |
| 157 } |
| 158 |
| 147 /** | 159 /** |
| 148 * The const void* ctx is only const because all the implementations are
const. | 160 * The const void* ctx is only const because all the implementations are
const. |
| 149 * This can be changed to non-const if a new shade proc needs to change
the ctx. | 161 * This can be changed to non-const if a new shade proc needs to change
the ctx. |
| 150 */ | 162 */ |
| 151 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in
t count); | 163 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in
t count); |
| 152 virtual ShadeProc asAShadeProc(void** ctx); | 164 virtual ShadeProc asAShadeProc(void** ctx); |
| 153 | 165 |
| 154 /** | 166 /** |
| 155 * Similar to shadeSpan, but only returns the alpha-channel for a span. | 167 * Similar to shadeSpan, but only returns the alpha-channel for a span. |
| 156 * The default implementation calls shadeSpan() and then extracts the a
lpha | 168 * The default implementation calls shadeSpan() and then extracts the a
lpha |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 kFixedStepInX_MatrixClass, // fast perspective, need to call fi
xedStepInX() each | 182 kFixedStepInX_MatrixClass, // fast perspective, need to call fi
xedStepInX() each |
| 171 // scanline | 183 // scanline |
| 172 kPerspective_MatrixClass // slow perspective, need to mappoin
ts each pixel | 184 kPerspective_MatrixClass // slow perspective, need to mappoin
ts each pixel |
| 173 }; | 185 }; |
| 174 static MatrixClass ComputeMatrixClass(const SkMatrix&); | 186 static MatrixClass ComputeMatrixClass(const SkMatrix&); |
| 175 | 187 |
| 176 uint8_t getPaintAlpha() const { return fPaintAlpha; } | 188 uint8_t getPaintAlpha() const { return fPaintAlpha; } |
| 177 const SkMatrix& getTotalInverse() const { return fTotalInverse; } | 189 const SkMatrix& getTotalInverse() const { return fTotalInverse; } |
| 178 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve
rseClass; } | 190 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve
rseClass; } |
| 179 const SkMatrix& getCTM() const { return fCTM; } | 191 const SkMatrix& getCTM() const { return fCTM; } |
| 192 |
| 193 virtual BlitProc onChooseBlitProc(const SkImageInfo&, BlitState*) { |
| 194 return nullptr; |
| 195 } |
| 196 |
| 180 private: | 197 private: |
| 181 SkMatrix fCTM; | 198 SkMatrix fCTM; |
| 182 SkMatrix fTotalInverse; | 199 SkMatrix fTotalInverse; |
| 183 uint8_t fPaintAlpha; | 200 uint8_t fPaintAlpha; |
| 184 uint8_t fTotalInverseClass; | 201 uint8_t fTotalInverseClass; |
| 185 | 202 |
| 186 typedef SkNoncopyable INHERITED; | 203 typedef SkNoncopyable INHERITED; |
| 187 }; | 204 }; |
| 188 | 205 |
| 189 /** | 206 /** |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 SkMatrix fLocalMatrix; | 474 SkMatrix fLocalMatrix; |
| 458 | 475 |
| 459 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 476 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
| 460 friend class SkLocalMatrixShader; | 477 friend class SkLocalMatrixShader; |
| 461 friend class SkBitmapProcShader; // for computeTotalInverse() | 478 friend class SkBitmapProcShader; // for computeTotalInverse() |
| 462 | 479 |
| 463 typedef SkFlattenable INHERITED; | 480 typedef SkFlattenable INHERITED; |
| 464 }; | 481 }; |
| 465 | 482 |
| 466 #endif | 483 #endif |
| OLD | NEW |