| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 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 SkComposeShader_DEFINED | 10 #ifndef SkComposeShader_DEFINED |
| 11 #define SkComposeShader_DEFINED | 11 #define SkComposeShader_DEFINED |
| 12 | 12 |
| 13 #include "SkShader.h" | 13 #include "SkShader.h" |
| 14 | 14 |
| 15 class SkXfermode; | 15 class SkXfermode; |
| 16 | 16 |
| 17 ////////////////////////////////////////////////////////////////////////////////
/////////// | 17 ////////////////////////////////////////////////////////////////////////////////
/////////// |
| 18 | 18 |
| 19 /** \class SkComposeShader | 19 /** \class SkComposeShader |
| 20 This subclass of shader returns the coposition of two other shaders, combine
d by | 20 This subclass of shader returns the coposition of two other shaders, combine
d by |
| 21 a xfermode. | 21 a xfermode. |
| 22 */ | 22 */ |
| 23 class SK_API SkComposeShader : public SkShader { | 23 class SK_API SkComposeShader : public SkShaderGenerator { |
| 24 public: | 24 public: |
| 25 /** Create a new compose shader, given shaders A, B, and a combining xfermod
e mode. | 25 /** 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 | 26 When the xfermode is called, it will be given the result from shader A a
s its |
| 27 "dst", and the result of from shader B as its "src". | 27 "dst", and the result of from shader B as its "src". |
| 28 mode->xfer32(sA_result, sB_result, ...) | 28 mode->xfer32(sA_result, sB_result, ...) |
| 29 @param shaderA The colors from this shader are seen as the "dst" by the
xfermode | 29 @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 | 30 @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 | 31 @param mode The xfermode that combines the colors from the two shade
rs. If mode |
| 32 is null, then SRC_OVER is assumed. | 32 is null, then SRC_OVER is assumed. |
| 33 */ | 33 */ |
| 34 SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); | 34 SkComposeShader(SkShaderGenerator* sA, SkShaderGenerator* sB, SkXfermode* mo
de = NULL); |
| 35 virtual ~SkComposeShader(); | 35 virtual ~SkComposeShader(); |
| 36 | 36 |
| 37 virtual bool setContext(const SkBitmap&, const SkPaint&, | 37 virtual size_t shaderImplSize() const SK_OVERRIDE; |
| 38 const SkMatrix&) SK_OVERRIDE; | 38 |
| 39 virtual void endContext() SK_OVERRIDE; | 39 virtual bool validContext(const SkBitmap&, const SkPaint&, |
| 40 virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; | 40 const SkMatrix&) SK_OVERRIDE; |
| 41 |
| 42 virtual ShaderImpl* createShaderImpl(const SkBitmap&, const SkPaint&, |
| 43 const SkMatrix&, void*) const SK_OVERRI
DE; |
| 44 |
| 45 class ComposeImpl : public ShaderImpl { |
| 46 public: |
| 47 // Takes ownership of implA and implB, and calls their destructors. |
| 48 ComposeImpl(const SkComposeShader&, const SkBitmap&, const SkPaint&, |
| 49 const SkMatrix&, ShaderImpl* implA, ShaderImpl* implB); |
| 50 |
| 51 ~ComposeImpl(); |
| 52 |
| 53 virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE
; |
| 54 private: |
| 55 ShaderImpl* fShaderImplA; |
| 56 ShaderImpl* fShaderImplB; |
| 57 }; |
| 58 |
| 41 | 59 |
| 42 SK_DEVELOPER_TO_STRING() | 60 SK_DEVELOPER_TO_STRING() |
| 43 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) | 61 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) |
| 44 | 62 |
| 45 protected: | 63 protected: |
| 46 SkComposeShader(SkReadBuffer& ); | 64 SkComposeShader(SkReadBuffer& ); |
| 47 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 65 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 48 | 66 |
| 49 private: | 67 private: |
| 50 | 68 |
| 51 SkShader* fShaderA; | 69 SkShaderGenerator* fShaderA; |
| 52 SkShader* fShaderB; | 70 SkShaderGenerator* fShaderB; |
| 53 SkXfermode* fMode; | 71 SkXfermode* fMode; |
| 54 | 72 |
| 55 typedef SkShader INHERITED; | 73 friend class ComposeImpl; |
| 74 |
| 75 typedef SkShaderGenerator INHERITED; |
| 56 }; | 76 }; |
| 57 | 77 |
| 58 #endif | 78 #endif |
| OLD | NEW |