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

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

Issue 1309943004: Revert of 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
226 /** 231 /**
227 * Returns true if this shader is just a bitmap, and if not null, returns t he bitmap, 232 Gives method bitmap should be read to implement a shader.
228 * localMatrix, and tilemodes. If this is not a bitmap, returns false and i gnores the 233 Also determines number and interpretation of "extra" parameters returned
229 * out-parameters. 234 by asABitmap
230 */ 235 */
231 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co nst { 236 enum BitmapType {
232 return this->onIsABitmap(outTexture, outMatrix, xy); 237 kNone_BitmapType, //<! Shader is not represented as a bitmap
238 kDefault_BitmapType,//<! Access bitmap using local coords transformed
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
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;
233 } 261 }
234
235 bool isABitmap() const { 262 bool isABitmap() const {
236 return this->isABitmap(nullptr, nullptr, nullptr); 263 return this->isABitmap(nullptr, nullptr, nullptr);
237 } 264 }
238 265
239 /** 266 /**
240 * If the shader subclass can be represented as a gradient, asAGradient 267 * If the shader subclass can be represented as a gradient, asAGradient
241 * returns the matching GradientType enum (or kNone_GradientType if it 268 * returns the matching GradientType enum (or kNone_GradientType if it
242 * cannot). Also, if info is not null, asAGradient populates info with 269 * cannot). Also, if info is not null, asAGradient populates info with
243 * the relevant (see below) parameters for the gradient. fColorCount 270 * the relevant (see below) parameters for the gradient. fColorCount
244 * 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
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 445
419 /** 446 /**
420 * Your subclass must also override contextSize() if it overrides onCreateC ontext(). 447 * Your subclass must also override contextSize() if it overrides onCreateC ontext().
421 * Base class impl returns NULL. 448 * Base class impl returns NULL.
422 */ 449 */
423 virtual Context* onCreateContext(const ContextRec&, void* storage) const; 450 virtual Context* onCreateContext(const ContextRec&, void* storage) const;
424 451
425 virtual bool onAsLuminanceColor(SkColor*) const { 452 virtual bool onAsLuminanceColor(SkColor*) const {
426 return false; 453 return false;
427 } 454 }
428
429 virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const {
430 return false;
431 }
432
433 private: 455 private:
434 // This is essentially const, but not officially so it can be modified in 456 // This is essentially const, but not officially so it can be modified in
435 // constructors. 457 // constructors.
436 SkMatrix fLocalMatrix; 458 SkMatrix fLocalMatrix;
437 459
438 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. 460 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor.
439 friend class SkLocalMatrixShader; 461 friend class SkLocalMatrixShader;
440 462
441 typedef SkFlattenable INHERITED; 463 typedef SkFlattenable INHERITED;
442 }; 464 };
443 465
444 #endif 466 #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