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

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

Issue 318923005: SkShader::asNewEffect Refactoring (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added macros to check for gpu support Created 6 years, 6 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 | « include/core/SkColorShader.h ('k') | include/effects/SkPerlinNoiseShader.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 8
9 #ifndef SkShader_DEFINED 9 #ifndef SkShader_DEFINED
10 #define SkShader_DEFINED 10 #define SkShader_DEFINED
11 11
12 #include "SkBitmap.h" 12 #include "SkBitmap.h"
13 #include "SkFlattenable.h" 13 #include "SkFlattenable.h"
14 #include "SkMask.h" 14 #include "SkMask.h"
15 #include "SkMatrix.h" 15 #include "SkMatrix.h"
16 #include "SkPaint.h" 16 #include "SkPaint.h"
17 #include "../gpu/GrColor.h"
17 18
18 class SkPath; 19 class SkPath;
19 class SkPicture; 20 class SkPicture;
20 class SkXfermode; 21 class SkXfermode;
21 class GrContext; 22 class GrContext;
22 class GrEffectRef; 23 class GrEffectRef;
23 24
24 /** \class SkShader 25 /** \class SkShader
25 * 26 *
26 * Shaders specify the source color(s) for what is being drawn. If a paint 27 * Shaders specify the source color(s) for what is being drawn. If a paint
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 struct ComposeRec { 367 struct ComposeRec {
367 const SkShader* fShaderA; 368 const SkShader* fShaderA;
368 const SkShader* fShaderB; 369 const SkShader* fShaderB;
369 const SkXfermode* fMode; 370 const SkXfermode* fMode;
370 }; 371 };
371 372
372 virtual bool asACompose(ComposeRec* rec) const { return false; } 373 virtual bool asACompose(ComposeRec* rec) const { return false; }
373 374
374 375
375 /** 376 /**
376 * If the shader subclass has a GrEffect implementation, this resturns the effect to install. 377 * Returns true if the shader subclass succeeds in setting the grEffect and the grColor output
378 * parameters to a value, returns false if it fails or if there is not an i mplementation of
379 * this method in the shader subclass.
377 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha. 380 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha.
378 * The output color should be the computed SkShader premul color modulated by the incoming 381 * The output color should be the computed SkShader premul color modulated by the incoming
379 * color. The GrContext may be used by the effect to create textures. The G PU device does not 382 * color. The GrContext may be used by the effect to create textures. The G PU device does not
380 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info. 383 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info.
381 */ 384 */
382 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint, 385 virtual bool asNewEffect(GrContext* context, const SkPaint& paint,
383 const SkMatrix* localMatrixOrNull) const; 386 const SkMatrix* localMatrixOrNull, GrColor* grColor ,
387 GrEffectRef** grEffect) const;
384 388
385 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 389 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
386 /** 390 /**
387 * If the shader is a custom shader which has data the caller might want, c all this function 391 * If the shader is a custom shader which has data the caller might want, c all this function
388 * to get that data. 392 * to get that data.
389 */ 393 */
390 virtual bool asACustomShader(void** customData) const { return false; } 394 virtual bool asACustomShader(void** customData) const { return false; }
391 #endif 395 #endif
392 396
393 ////////////////////////////////////////////////////////////////////////// 397 //////////////////////////////////////////////////////////////////////////
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; 460 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const;
457 461
458 /** 462 /**
459 * Your subclass must also override contextSize() if it overrides onCreateC ontext(). 463 * Your subclass must also override contextSize() if it overrides onCreateC ontext().
460 * Base class impl returns NULL. 464 * Base class impl returns NULL.
461 */ 465 */
462 virtual Context* onCreateContext(const ContextRec&, void* storage) const; 466 virtual Context* onCreateContext(const ContextRec&, void* storage) const;
463 467
464 private: 468 private:
465 SkMatrix fLocalMatrix; 469 SkMatrix fLocalMatrix;
466 470
467 typedef SkFlattenable INHERITED; 471 typedef SkFlattenable INHERITED;
468 }; 472 };
469 473
470 #endif 474 #endif
OLDNEW
« no previous file with comments | « include/core/SkColorShader.h ('k') | include/effects/SkPerlinNoiseShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698