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

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

Issue 198193005: Work (in progress) to make SkShader immutable. (Closed) Base URL: https://skia.googlesource.com/skia.git@shaderGenerator
Patch Set: Created 6 years, 9 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 | include/core/SkComposeShader.h » ('j') | src/core/SkShader.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkColorShader_DEFINED 10 #ifndef SkColorShader_DEFINED
(...skipping 12 matching lines...) Expand all
23 at draw time. 23 at draw time.
24 */ 24 */
25 SkColorShader(); 25 SkColorShader();
26 26
27 /** Create a ColorShader that ignores the color in the paint, and uses the 27 /** Create a ColorShader that ignores the color in the paint, and uses the
28 specified color. Note: like all shaders, at draw time the paint's alpha 28 specified color. Note: like all shaders, at draw time the paint's alpha
29 will be respected, and is applied to the specified color. 29 will be respected, and is applied to the specified color.
30 */ 30 */
31 SkColorShader(SkColor c); 31 SkColorShader(SkColor c);
32 32
33 virtual ~SkColorShader(); 33 virtual bool isOpaque() const SK_OVERRIDE;
34 34
35 virtual uint32_t getFlags() SK_OVERRIDE; 35 virtual size_t shaderImplSize() const OVERRIDE {
36 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; 36 return sizeof(CSImpl);
37 virtual bool isOpaque() const SK_OVERRIDE; 37 }
38 virtual bool setContext(const SkBitmap& device, const SkPaint& paint, 38
39 const SkMatrix& matrix) SK_OVERRIDE; 39 virtual ShaderImpl* createShaderImpl(const SkBitmap& device,
40 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRID E; 40 const SkPaint& paint,
41 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRI DE; 41 const SkMatrix& matrix,
42 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVE RRIDE; 42 void* storage) const SK_OVERRIDE;
43
44 class CSImpl : public SkShaderGenerator::ShaderImpl {
45 public:
46 CSImpl(const SkShaderGenerator& shader, const SkBitmap& device,
47 const SkPaint& paint, const SkMatrix& matrix);
48
49 virtual uint32_t getFlags() SK_OVERRIDE;
50 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
51 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE RRIDE;
52 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OV ERRIDE;
53 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK _OVERRIDE;
54
55 private:
56 SkPMColor fPMColor;
57 uint32_t fFlags;
58 uint16_t fColor16;
59 };
43 60
44 // we return false for this, use asAGradient 61 // we return false for this, use asAGradient
45 virtual BitmapType asABitmap(SkBitmap* outTexture, 62 virtual BitmapType asABitmap(SkBitmap* outTexture,
46 SkMatrix* outMatrix, 63 SkMatrix* outMatrix,
47 TileMode xy[2]) const SK_OVERRIDE; 64 TileMode xy[2]) const SK_OVERRIDE;
48 65
49 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; 66 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
50 67
51 SK_DEVELOPER_TO_STRING() 68 SK_DEVELOPER_TO_STRING()
52 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) 69
70 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
71 static SkFlattenable* CreateProc(SkReadBuffer& buffer);
53 72
54 protected: 73 protected:
55 SkColorShader(SkReadBuffer&);
56 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 74 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
57 75
58 private: 76 private:
77 const SkColor fColor; // ignored if fInheritColor is true
78 const SkBool8 fInheritColor;
59 79
60 SkColor fColor; // ignored if fInheritColor is true 80 friend class CSImpl;
61 SkPMColor fPMColor; // cached after setContext()
62 uint32_t fFlags; // cached after setContext()
63 uint16_t fColor16; // cached after setContext()
64 SkBool8 fInheritColor;
65 81
66 typedef SkShader INHERITED; 82 typedef SkShaderGenerator INHERITED;
67 }; 83 };
68 84
69 #endif 85 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkComposeShader.h » ('j') | src/core/SkShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698