Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 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 GrProcessor_DEFINED | 8 #ifndef GrProcessor_DEFINED |
| 9 #define GrProcessor_DEFINED | 9 #define GrProcessor_DEFINED |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 virtual ~GrProcessor(); | 38 virtual ~GrProcessor(); |
| 39 | 39 |
| 40 struct InvariantOutput{ | 40 struct InvariantOutput{ |
| 41 GrColor fColor; | 41 GrColor fColor; |
| 42 uint32_t fValidFlags; | 42 uint32_t fValidFlags; |
| 43 bool fIsSingleComponent; | 43 bool fIsSingleComponent; |
| 44 | 44 |
| 45 InvariantOutput() : fColor(0), fValidFlags(0), fIsSingleComponent(false) {} | 45 InvariantOutput() : fColor(0), fValidFlags(0), fIsSingleComponent(false) {} |
| 46 | 46 |
| 47 void mulByUnknownOpaqueColor() { | |
| 48 if (this->isOpaque()) { | |
| 49 fValidFlags = kA_GrColorComponentFlag; | |
| 50 fIsSingleComponent = false; | |
| 51 } else { | |
| 52 // Since the current state is not opaque we no longer care if th e color being | |
| 53 // multiplied is opaque. | |
| 54 this->mulByUnknownColor(); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 void mulByUnknownColor() { | |
| 59 if (this->hasZeroAlpha()) { | |
| 60 this->transparentBlackOutput(); | |
| 61 } else { | |
| 62 this->unknownOutput(); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 void mulByUnknownAlpha() { | |
| 67 if (this->hasZeroAlpha()) { | |
| 68 this->transparentBlackOutput(); | |
| 69 } else { | |
| 70 // We don't need to change fIsSingleComponent in this case | |
| 71 fValidFlags = 0; | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 void transparentBlackOutput() { | |
|
bsalomon
2014/10/10 19:48:16
setToTransparentBlack() ?
egdaniel
2014/10/13 16:44:57
Done.
| |
| 76 fValidFlags = kRGBA_GrColorComponentFlags; | |
| 77 fColor = 0; | |
| 78 fIsSingleComponent = true; | |
| 79 } | |
| 80 | |
| 81 void unknownOutput() { | |
|
bsalomon
2014/10/10 19:48:16
setUnknownOutput?
(just trying to avoid confusion
egdaniel
2014/10/13 16:44:57
Done.
| |
| 82 fValidFlags = 0; | |
| 83 fIsSingleComponent = false; | |
| 84 } | |
| 85 | |
| 47 bool isOpaque() const { | 86 bool isOpaque() const { |
| 48 return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUn packA(fColor)); | 87 return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUn packA(fColor)); |
| 49 } | 88 } |
| 50 | 89 |
| 51 bool isSolidWhite() const { | 90 bool isSolidWhite() const { |
| 52 return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor); | 91 return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor); |
| 53 } | 92 } |
| 54 | 93 |
| 55 /** | 94 /** |
| 56 * If isSingleComponent is true, then the flag values for r, g, b, and a must all be the | 95 * If isSingleComponent is true, then the flag values for r, g, b, and a must all be the |
| 57 * same. If the flags are all set then all color components must be equa l. | 96 * same. If the flags are all set then all color components must be equa l. |
| 58 */ | 97 */ |
| 59 SkDEBUGCODE(void validate() const;) | 98 SkDEBUGCODE(void validate() const;) |
| 60 | 99 |
| 61 private: | 100 private: |
| 101 bool hasZeroAlpha() const { | |
| 102 return ((fValidFlags & kA_GrColorComponentFlag) && 0 == GrColorUnpac kA(fColor)); | |
| 103 } | |
| 104 | |
| 62 SkDEBUGCODE(bool colorComponentsAllEqual() const;) | 105 SkDEBUGCODE(bool colorComponentsAllEqual() const;) |
| 63 | |
| 64 /** | 106 /** |
| 65 * If alpha is valid, check that any valid R,G,B values are <= A | 107 * If alpha is valid, check that any valid R,G,B values are <= A |
| 66 */ | 108 */ |
| 67 SkDEBUGCODE(bool validPreMulColor() const;) | 109 SkDEBUGCODE(bool validPreMulColor() const;) |
| 68 }; | 110 }; |
| 69 | 111 |
| 70 /** | 112 /** |
| 71 * This function is used to perform optimizations. When called the invarient Ouput param | 113 * This function is used to perform optimizations. When called the invarient Ouput param |
| 72 * indicate whether the input components to this effect in the FS will have known values. | 114 * indicate whether the input components to this effect in the FS will have known values. |
| 73 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th e isSingleComponent | 115 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th e isSingleComponent |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called | 290 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called |
| 249 * at global destruction time. NAME will be the name of the created GrProcessor. | 291 * at global destruction time. NAME will be the name of the created GrProcessor. |
| 250 */ | 292 */ |
| 251 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \ | 293 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \ |
| 252 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ | 294 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ |
| 253 static GrFragmentProcessor* \ | 295 static GrFragmentProcessor* \ |
| 254 NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \ | 296 NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \ |
| 255 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME); | 297 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME); |
| 256 | 298 |
| 257 #endif | 299 #endif |
| OLD | NEW |