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

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

Issue 1759653004: enforce 16byte alignment in shader contexts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « src/core/SkColorFilterShader.cpp ('k') | src/core/SkComposeShader.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 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
11 #include "SkShader.h" 11 #include "SkShader.h"
12 #include "SkPM4f.h" 12 #include "SkPM4f.h"
13 13
14 /** \class SkColorShader 14 /** \class SkColorShader
15 A Shader that represents a single color. In general, this effect can be 15 A Shader that represents a single color. In general, this effect can be
16 accomplished by just using the color field on the paint, but if an 16 accomplished by just using the color field on the paint, but if an
17 actual shader object is needed, this provides that feature. 17 actual shader object is needed, this provides that feature.
18 */ 18 */
19 class SK_API SkColorShader : public SkShader { 19 class SK_API SkColorShader : public SkShader {
20 public: 20 public:
21 /** Create a ColorShader that ignores the color in the paint, and uses the 21 /** Create a ColorShader that ignores the color in the paint, and uses the
22 specified color. Note: like all shaders, at draw time the paint's alpha 22 specified color. Note: like all shaders, at draw time the paint's alpha
23 will be respected, and is applied to the specified color. 23 will be respected, and is applied to the specified color.
24 */ 24 */
25 explicit SkColorShader(SkColor c); 25 explicit SkColorShader(SkColor c);
26 26
27 bool isOpaque() const override; 27 bool isOpaque() const override;
28 28
29 size_t contextSize(const ContextRec&) const override {
30 return sizeof(ColorShaderContext);
31 }
32
33 class ColorShaderContext : public SkShader::Context { 29 class ColorShaderContext : public SkShader::Context {
34 public: 30 public:
35 ColorShaderContext(const SkColorShader& shader, const ContextRec&); 31 ColorShaderContext(const SkColorShader& shader, const ContextRec&);
36 32
37 uint32_t getFlags() const override; 33 uint32_t getFlags() const override;
38 void shadeSpan(int x, int y, SkPMColor span[], int count) override; 34 void shadeSpan(int x, int y, SkPMColor span[], int count) override;
39 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; 35 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override;
40 void shadeSpan4f(int x, int y, SkPM4f[], int count) override; 36 void shadeSpan4f(int x, int y, SkPM4f[], int count) override;
41 37
42 private: 38 private:
(...skipping 11 matching lines...) Expand all
54 const SkMatrix*, SkFilterQual ity) const override; 50 const SkMatrix*, SkFilterQual ity) const override;
55 #endif 51 #endif
56 52
57 SK_TO_STRING_OVERRIDE() 53 SK_TO_STRING_OVERRIDE()
58 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) 54 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
59 55
60 protected: 56 protected:
61 SkColorShader(SkReadBuffer&); 57 SkColorShader(SkReadBuffer&);
62 void flatten(SkWriteBuffer&) const override; 58 void flatten(SkWriteBuffer&) const override;
63 Context* onCreateContext(const ContextRec&, void* storage) const override; 59 Context* onCreateContext(const ContextRec&, void* storage) const override;
60 size_t onContextSize(const ContextRec&) const override {
61 return sizeof(ColorShaderContext);
62 }
64 bool onAsLuminanceColor(SkColor* lum) const override { 63 bool onAsLuminanceColor(SkColor* lum) const override {
65 *lum = fColor; 64 *lum = fColor;
66 return true; 65 return true;
67 } 66 }
68 67
69 private: 68 private:
70 SkColor fColor; 69 SkColor fColor;
71 70
72 typedef SkShader INHERITED; 71 typedef SkShader INHERITED;
73 }; 72 };
74 73
75 #endif 74 #endif
OLDNEW
« no previous file with comments | « src/core/SkColorFilterShader.cpp ('k') | src/core/SkComposeShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698