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

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

Issue 1287263005: change asABitmap to isABitmap on shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 /* 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 */ 216 */
217 virtual size_t contextSize() const; 217 virtual size_t contextSize() const;
218 218
219 /** 219 /**
220 * Helper to check the flags to know if it is legal to call shadeSpan16() 220 * Helper to check the flags to know if it is legal to call shadeSpan16()
221 */ 221 */
222 static bool CanCallShadeSpan16(uint32_t flags) { 222 static bool CanCallShadeSpan16(uint32_t flags) {
223 return (flags & kHasSpan16_Flag) != 0; 223 return (flags & kHasSpan16_Flag) != 0;
224 } 224 }
225 225
226 #ifdef SK_SUPPORT_LEGACY_SHADERBITMAPTYPE
227 public:
228 #else
229 protected:
230 #endif
226 /** 231 /**
227 Gives method bitmap should be read to implement a shader. 232 Gives method bitmap should be read to implement a shader.
228 Also determines number and interpretation of "extra" parameters returned 233 Also determines number and interpretation of "extra" parameters returned
229 by asABitmap 234 by asABitmap
230 */ 235 */
231 enum BitmapType { 236 enum BitmapType {
232 kNone_BitmapType, //<! Shader is not represented as a bitmap 237 kNone_BitmapType, //<! Shader is not represented as a bitmap
233 kDefault_BitmapType,//<! Access bitmap using local coords transformed 238 kDefault_BitmapType,//<! Access bitmap using local coords transformed
234 // by matrix. No extras
235 kRadial_BitmapType, //<! Access bitmap by transforming local coordinates
236 // by the matrix and taking the distance of result
237 // from (0,0) as bitmap column. Bitmap is 1 pixel
238 // tall. No extras
239 kSweep_BitmapType, //<! Access bitmap by transforming local coordinates
240 // by the matrix and taking the angle of result
241 // to (0,0) as bitmap x coord, where angle = 0 is
242 // bitmap left edge of bitmap = 2pi is the
243 // right edge. Bitmap is 1 pixel tall. No extras
244 kTwoPointConical_BitmapType,
245 //<! Matrix transforms to space where (0,0) is
246 // the center of the starting circle. The second
247 // circle will be centered (x, 0) where x may be
248 // 0.
249 // Three extra parameters are returned:
250 // 0: x-offset of second circle center
251 // to first.
252 // 1: radius of first circle
253 // 2: the second radius minus the first radius
254 kLinear_BitmapType, //<! Access bitmap using local coords transformed
255 // by matrix. No extras
256
257 kLast_BitmapType = kLinear_BitmapType
258 }; 239 };
259 /** Optional methods for shaders that can pretend to be a bitmap/texture 240 /** Optional methods for shaders that can pretend to be a bitmap/texture
260 to play along with opengl. Default just returns kNone_BitmapType and 241 to play along with opengl. Default just returns kNone_BitmapType and
261 ignores the out parameters. 242 ignores the out parameters.
262 243
263 @param outTexture if non-NULL will be the bitmap representing the shader 244 @param outTexture if non-NULL will be the bitmap representing the shader
264 after return. 245 after return.
265 @param outMatrix if non-NULL will be the matrix to apply to vertices 246 @param outMatrix if non-NULL will be the matrix to apply to vertices
266 to access the bitmap after return. 247 to access the bitmap after return.
267 @param xy if non-NULL will be the tile modes that should be 248 @param xy if non-NULL will be the tile modes that should be
268 used to access the bitmap after return. 249 used to access the bitmap after return.
269 @param twoPointRadialParams Two extra return values needed for two point 250 @param twoPointRadialParams Two extra return values needed for two point
270 radial bitmaps. The first is the x-offset of 251 radial bitmaps. The first is the x-offset of
271 the second point and the second is the radiu s 252 the second point and the second is the radiu s
272 about the first point. 253 about the first point.
273 */ 254 */
274 virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, 255 virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix,
275 TileMode xy[2]) const; 256 TileMode xy[2]) const;
276 257
258 public:
259 bool isABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode xy[2]) const {
260 return this->asABitmap(bitmap, matrix, xy) == kDefault_BitmapType;
261 }
262 bool isABitmap() const {
263 return this->isABitmap(nullptr, nullptr, nullptr);
264 }
265
277 /** 266 /**
278 * If the shader subclass can be represented as a gradient, asAGradient 267 * If the shader subclass can be represented as a gradient, asAGradient
279 * returns the matching GradientType enum (or kNone_GradientType if it 268 * returns the matching GradientType enum (or kNone_GradientType if it
280 * cannot). Also, if info is not null, asAGradient populates info with 269 * cannot). Also, if info is not null, asAGradient populates info with
281 * the relevant (see below) parameters for the gradient. fColorCount 270 * the relevant (see below) parameters for the gradient. fColorCount
282 * is both an input and output parameter. On input, it indicates how 271 * is both an input and output parameter. On input, it indicates how
283 * many entries in fColors and fColorOffsets can be used, if they are 272 * many entries in fColors and fColorOffsets can be used, if they are
284 * non-NULL. After asAGradient has run, fColorCount indicates how 273 * non-NULL. After asAGradient has run, fColorCount indicates how
285 * many color-offset pairs there are in the gradient. If there is 274 * many color-offset pairs there are in the gradient. If there is
286 * insufficient space to store all of the color-offset pairs, fColors 275 * insufficient space to store all of the color-offset pairs, fColors
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // constructors. 464 // constructors.
476 SkMatrix fLocalMatrix; 465 SkMatrix fLocalMatrix;
477 466
478 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. 467 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor.
479 friend class SkLocalMatrixShader; 468 friend class SkLocalMatrixShader;
480 469
481 typedef SkFlattenable INHERITED; 470 typedef SkFlattenable INHERITED;
482 }; 471 };
483 472
484 #endif 473 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698