OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 | |
9 #ifndef SkComposeShader_DEFINED | 8 #ifndef SkComposeShader_DEFINED |
10 #define SkComposeShader_DEFINED | 9 #define SkComposeShader_DEFINED |
11 | 10 |
12 #include "SkShader.h" | 11 #include "SkShader.h" |
13 | 12 #include "SkXfermode.h" |
14 class SkXfermode; | |
15 | 13 |
16 ////////////////////////////////////////////////////////////////////////////////
/////////// | 14 ////////////////////////////////////////////////////////////////////////////////
/////////// |
17 | 15 |
18 /** \class SkComposeShader | 16 /** \class SkComposeShader |
19 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 |
20 a xfermode. | 18 a xfermode. |
21 */ | 19 */ |
22 class SK_API SkComposeShader : public SkShader { | 20 class SK_API SkComposeShader : public SkShader { |
23 public: | 21 public: |
24 /** 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. |
25 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 |
26 "dst", and the result from shader B as its "src". | 24 "dst", and the result from shader B as its "src". |
27 mode->xfer32(sA_result, sB_result, ...) | 25 mode->xfer32(sA_result, sB_result, ...) |
28 @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 |
29 @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 |
30 @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 |
31 is null, then SRC_OVER is assumed. | 29 is null, then SRC_OVER is assumed. |
32 */ | 30 */ |
33 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) |
34 virtual ~SkComposeShader(); | 32 : fShaderA(std::move(sA)) |
| 33 , fShaderB(std::move(sB)) |
| 34 , fMode(std::move(mode)) |
| 35 {} |
35 | 36 |
36 #if SK_SUPPORT_GPU | 37 #if SK_SUPPORT_GPU |
37 const GrFragmentProcessor* asFragmentProcessor(GrContext*, | 38 const GrFragmentProcessor* asFragmentProcessor(GrContext*, |
38 const SkMatrix& viewM, | 39 const SkMatrix& viewM, |
39 const SkMatrix* localMatrix, | 40 const SkMatrix* localMatrix, |
40 SkFilterQuality) const overr
ide; | 41 SkFilterQuality) const overr
ide; |
41 #endif | 42 #endif |
42 | 43 |
43 class ComposeShaderContext : public SkShader::Context { | 44 class ComposeShaderContext : public SkShader::Context { |
44 public: | 45 public: |
(...skipping 20 matching lines...) Expand all Loading... |
65 SkShader* getShaderA() { return fShaderA.get(); } | 66 SkShader* getShaderA() { return fShaderA.get(); } |
66 SkShader* getShaderB() { return fShaderB.get(); } | 67 SkShader* getShaderB() { return fShaderB.get(); } |
67 #endif | 68 #endif |
68 | 69 |
69 bool asACompose(ComposeRec* rec) const override; | 70 bool asACompose(ComposeRec* rec) const override; |
70 | 71 |
71 SK_TO_STRING_OVERRIDE() | 72 SK_TO_STRING_OVERRIDE() |
72 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) | 73 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) |
73 | 74 |
74 protected: | 75 protected: |
75 SkComposeShader(SkReadBuffer& ); | 76 SkComposeShader(SkReadBuffer&); |
76 void flatten(SkWriteBuffer&) const override; | 77 void flatten(SkWriteBuffer&) const override; |
77 size_t onContextSize(const ContextRec&) const override; | 78 size_t onContextSize(const ContextRec&) const override; |
78 Context* onCreateContext(const ContextRec&, void*) const override; | 79 Context* onCreateContext(const ContextRec&, void*) const override; |
79 | 80 |
80 private: | 81 private: |
81 sk_sp<SkShader> fShaderA; | 82 sk_sp<SkShader> fShaderA; |
82 sk_sp<SkShader> fShaderB; | 83 sk_sp<SkShader> fShaderB; |
83 SkXfermode* fMode; | 84 sk_sp<SkXfermode> fMode; |
84 | 85 |
85 typedef SkShader INHERITED; | 86 typedef SkShader INHERITED; |
86 }; | 87 }; |
87 | 88 |
88 #endif | 89 #endif |
OLD | NEW |