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

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

Issue 1311963007: switch to isABitmap, deprecate SK_SUPPORT_LEGACY_SHADERBITMAPTYPE (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/SkBitmapProcShader.h » ('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 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
231 /** 226 /**
232 Gives method bitmap should be read to implement a shader. 227 * Returns true if this shader is just a bitmap, and if not null, returns t he bitmap,
233 Also determines number and interpretation of "extra" parameters returned 228 * localMatrix, and tilemodes. If this is not a bitmap, returns false and i gnores the
234 by asABitmap 229 * out-parameters.
235 */ 230 */
236 enum BitmapType { 231 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co nst {
237 kNone_BitmapType, //<! Shader is not represented as a bitmap 232 return this->onIsABitmap(outTexture, outMatrix, xy);
238 kDefault_BitmapType,//<! Access bitmap using local coords transformed 233 }
239 };
240 /** Optional methods for shaders that can pretend to be a bitmap/texture
241 to play along with opengl. Default just returns kNone_BitmapType and
242 ignores the out parameters.
243 234
244 @param outTexture if non-NULL will be the bitmap representing the shader
245 after return.
246 @param outMatrix if non-NULL will be the matrix to apply to vertices
247 to access the bitmap after return.
248 @param xy if non-NULL will be the tile modes that should be
249 used to access the bitmap after return.
250 @param twoPointRadialParams Two extra return values needed for two point
251 radial bitmaps. The first is the x-offset of
252 the second point and the second is the radiu s
253 about the first point.
254 */
255 virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix,
256 TileMode xy[2]) const;
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 { 235 bool isABitmap() const {
263 return this->isABitmap(nullptr, nullptr, nullptr); 236 return this->isABitmap(nullptr, nullptr, nullptr);
264 } 237 }
265 238
266 /** 239 /**
267 * If the shader subclass can be represented as a gradient, asAGradient 240 * If the shader subclass can be represented as a gradient, asAGradient
268 * returns the matching GradientType enum (or kNone_GradientType if it 241 * returns the matching GradientType enum (or kNone_GradientType if it
269 * cannot). Also, if info is not null, asAGradient populates info with 242 * cannot). Also, if info is not null, asAGradient populates info with
270 * the relevant (see below) parameters for the gradient. fColorCount 243 * the relevant (see below) parameters for the gradient. fColorCount
271 * is both an input and output parameter. On input, it indicates how 244 * is both an input and output parameter. On input, it indicates how
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 418
446 /** 419 /**
447 * Your subclass must also override contextSize() if it overrides onCreateC ontext(). 420 * Your subclass must also override contextSize() if it overrides onCreateC ontext().
448 * Base class impl returns NULL. 421 * Base class impl returns NULL.
449 */ 422 */
450 virtual Context* onCreateContext(const ContextRec&, void* storage) const; 423 virtual Context* onCreateContext(const ContextRec&, void* storage) const;
451 424
452 virtual bool onAsLuminanceColor(SkColor*) const { 425 virtual bool onAsLuminanceColor(SkColor*) const {
453 return false; 426 return false;
454 } 427 }
428
429 virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const {
430 return false;
431 }
432
455 private: 433 private:
456 // This is essentially const, but not officially so it can be modified in 434 // This is essentially const, but not officially so it can be modified in
457 // constructors. 435 // constructors.
458 SkMatrix fLocalMatrix; 436 SkMatrix fLocalMatrix;
459 437
460 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. 438 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor.
461 friend class SkLocalMatrixShader; 439 friend class SkLocalMatrixShader;
462 440
463 typedef SkFlattenable INHERITED; 441 typedef SkFlattenable INHERITED;
464 }; 442 };
465 443
466 #endif 444 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698