OLD | NEW |
---|---|
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkComposeShader_DEFINED | 8 #ifndef SkComposeShader_DEFINED |
11 #define SkComposeShader_DEFINED | 9 #define SkComposeShader_DEFINED |
12 | 10 |
13 #include "SkShader.h" | 11 #include "SkShader.h" |
14 | 12 #include "SkXfermode.h" |
15 class SkXfermode; | |
16 | 13 |
17 //////////////////////////////////////////////////////////////////////////////// /////////// | 14 //////////////////////////////////////////////////////////////////////////////// /////////// |
18 | 15 |
19 /** \class SkComposeShader | 16 /** \class SkComposeShader |
20 This subclass of shader returns the composition of two other shaders, combin ed by | 17 This subclass of shader returns the composition of two other shaders, combin ed by |
21 a xfermode. | 18 a xfermode. |
22 */ | 19 */ |
23 class SK_API SkComposeShader : public SkShader { | 20 class SK_API SkComposeShader : public SkShader { |
24 public: | 21 public: |
25 /** Create a new compose shader, given shaders A, B, and a combining xfermod e mode. | 22 /** Create a new compose shader, given shaders A, B, and a combining xfermod e mode. |
26 When the xfermode is called, it will be given the result from shader A a s its | 23 When the xfermode is called, it will be given the result from shader A a s its |
27 "dst", and the result from shader B as its "src". | 24 "dst", and the result from shader B as its "src". |
28 mode->xfer32(sA_result, sB_result, ...) | 25 mode->xfer32(sA_result, sB_result, ...) |
29 @param shaderA The colors from this shader are seen as the "dst" by the xfermode | 26 @param shaderA The colors from this shader are seen as the "dst" by the xfermode |
30 @param shaderB The colors from this shader are seen as the "src" by the xfermode | 27 @param shaderB The colors from this shader are seen as the "src" by the xfermode |
31 @param mode The xfermode that combines the colors from the two shade rs. If mode | 28 @param mode The xfermode that combines the colors from the two shade rs. If mode |
32 is null, then SRC_OVER is assumed. | 29 is null, then SRC_OVER is assumed. |
33 */ | 30 */ |
34 SkComposeShader(sk_sp<SkShader> sA, sk_sp<SkShader> sB, SkXfermode* mode = N ULL); | 31 SkComposeShader(sk_sp<SkShader> sA, sk_sp<SkShader> sB, sk_sp<SkXfermode> mo de) |
tomhudson
2016/03/28 17:46:26
Nit: Removed the default argument; will need to up
reed1
2016/03/29 16:13:52
This class is private (in src/core) so all the cal
| |
35 virtual ~SkComposeShader(); | 32 : fShaderA(std::move(sA)) |
33 , fShaderB(std::move(sB)) | |
34 , fMode(std::move(mode)) | |
35 {} | |
36 | 36 |
37 #if SK_SUPPORT_GPU | 37 #if SK_SUPPORT_GPU |
38 const GrFragmentProcessor* asFragmentProcessor(GrContext*, | 38 const GrFragmentProcessor* asFragmentProcessor(GrContext*, |
39 const SkMatrix& viewM, | 39 const SkMatrix& viewM, |
40 const SkMatrix* localMatrix, | 40 const SkMatrix* localMatrix, |
41 SkFilterQuality) const overr ide; | 41 SkFilterQuality) const overr ide; |
42 #endif | 42 #endif |
43 | 43 |
44 class ComposeShaderContext : public SkShader::Context { | 44 class ComposeShaderContext : public SkShader::Context { |
45 public: | 45 public: |
(...skipping 20 matching lines...) Expand all Loading... | |
66 SkShader* getShaderA() { return fShaderA.get(); } | 66 SkShader* getShaderA() { return fShaderA.get(); } |
67 SkShader* getShaderB() { return fShaderB.get(); } | 67 SkShader* getShaderB() { return fShaderB.get(); } |
68 #endif | 68 #endif |
69 | 69 |
70 bool asACompose(ComposeRec* rec) const override; | 70 bool asACompose(ComposeRec* rec) const override; |
71 | 71 |
72 SK_TO_STRING_OVERRIDE() | 72 SK_TO_STRING_OVERRIDE() |
73 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) | 73 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) |
74 | 74 |
75 protected: | 75 protected: |
76 SkComposeShader(SkReadBuffer& ); | 76 SkComposeShader(SkReadBuffer&); |
77 void flatten(SkWriteBuffer&) const override; | 77 void flatten(SkWriteBuffer&) const override; |
78 size_t onContextSize(const ContextRec&) const override; | 78 size_t onContextSize(const ContextRec&) const override; |
79 Context* onCreateContext(const ContextRec&, void*) const override; | 79 Context* onCreateContext(const ContextRec&, void*) const override; |
80 | 80 |
81 private: | 81 private: |
82 sk_sp<SkShader> fShaderA; | 82 sk_sp<SkShader> fShaderA; |
83 sk_sp<SkShader> fShaderB; | 83 sk_sp<SkShader> fShaderB; |
84 SkXfermode* fMode; | 84 sk_sp<SkXfermode> fMode; |
85 | 85 |
86 typedef SkShader INHERITED; | 86 typedef SkShader INHERITED; |
87 }; | 87 }; |
88 | 88 |
89 #endif | 89 #endif |
OLD | NEW |