| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 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 SkColorShader_DEFINED | 8 #ifndef SkColorShader_DEFINED |
| 9 #define SkColorShader_DEFINED | 9 #define SkColorShader_DEFINED |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 *lum = fColor; | 65 *lum = fColor; |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 SkColor fColor; | 70 SkColor fColor; |
| 71 | 71 |
| 72 typedef SkShader INHERITED; | 72 typedef SkShader INHERITED; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class SkColor4Shader : public SkShader { |
| 76 public: |
| 77 SkColor4Shader(const SkColor4f&, sk_sp<SkColorSpace>); |
| 78 |
| 79 bool isOpaque() const override { |
| 80 return SkColorGetA(fCachedByteColor) == 255; |
| 81 } |
| 82 |
| 83 class Color4Context : public SkShader::Context { |
| 84 public: |
| 85 Color4Context(const SkColor4Shader& shader, const ContextRec&); |
| 86 |
| 87 uint32_t getFlags() const override; |
| 88 void shadeSpan(int x, int y, SkPMColor span[], int count) override; |
| 89 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; |
| 90 void shadeSpan4f(int x, int y, SkPM4f[], int count) override; |
| 91 |
| 92 protected: |
| 93 bool onChooseBlitProcs(const SkImageInfo&, BlitState*) override; |
| 94 |
| 95 private: |
| 96 SkPM4f fPM4f; |
| 97 SkPMColor fPMColor; |
| 98 uint32_t fFlags; |
| 99 |
| 100 typedef SkShader::Context INHERITED; |
| 101 }; |
| 102 |
| 103 GradientType asAGradient(GradientInfo* info) const override; |
| 104 |
| 105 #if SK_SUPPORT_GPU |
| 106 const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& v
iewM, |
| 107 const SkMatrix*, SkFilterQual
ity) const override; |
| 108 #endif |
| 109 |
| 110 SK_TO_STRING_OVERRIDE() |
| 111 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
| 112 |
| 113 protected: |
| 114 SkColor4Shader(SkReadBuffer&); |
| 115 void flatten(SkWriteBuffer&) const override; |
| 116 Context* onCreateContext(const ContextRec&, void* storage) const override; |
| 117 size_t onContextSize(const ContextRec&) const override { return sizeof(Color
4Context); } |
| 118 bool onAsLuminanceColor(SkColor* lum) const override { |
| 119 *lum = fCachedByteColor; |
| 120 return true; |
| 121 } |
| 122 |
| 123 private: |
| 124 sk_sp<SkColorSpace> fColorSpace; |
| 125 const SkColor4f fColor4; |
| 126 const SkColor fCachedByteColor; |
| 127 |
| 128 typedef SkShader INHERITED; |
| 129 }; |
| 130 |
| 75 #endif | 131 #endif |
| OLD | NEW |