OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkLocalMatrixShader_DEFINED |
| 9 #define SkLocalMatrixShader_DEFINED |
| 10 |
| 11 #include "SkShader.h" |
| 12 #include "SkReadBuffer.h" |
| 13 #include "SkWriteBuffer.h" |
| 14 |
| 15 class SkLocalMatrixShader : public SkShader { |
| 16 public: |
| 17 SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) |
| 18 : fProxyShader(SkRef(proxy)) |
| 19 , fProxyLocalMatrix(localMatrix) |
| 20 {} |
| 21 |
| 22 virtual size_t contextSize() const SK_OVERRIDE { |
| 23 return fProxyShader->contextSize(); |
| 24 } |
| 25 |
| 26 virtual BitmapType asABitmap(SkBitmap* bitmap, SkMatrix* matrix, |
| 27 TileMode* mode) const SK_OVERRIDE { |
| 28 return fProxyShader->asABitmap(bitmap, matrix, mode); |
| 29 } |
| 30 |
| 31 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE { |
| 32 return fProxyShader->asAGradient(info); |
| 33 } |
| 34 |
| 35 virtual GrEffectRef* asNewEffect(GrContext* ctx, const SkPaint& paint, |
| 36 const SkMatrix* localMatrix) const SK_OVERR
IDE { |
| 37 SkMatrix tmp = fProxyLocalMatrix; |
| 38 if (localMatrix) { |
| 39 tmp.preConcat(*localMatrix); |
| 40 } |
| 41 return fProxyShader->asNewEffect(ctx, paint, &tmp); |
| 42 } |
| 43 |
| 44 virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const SK_OV
ERRIDE { |
| 45 if (localMatrix) { |
| 46 *localMatrix = fProxyLocalMatrix; |
| 47 } |
| 48 return SkRef(fProxyShader.get()); |
| 49 } |
| 50 |
| 51 SK_TO_STRING_OVERRIDE() |
| 52 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixShader) |
| 53 |
| 54 protected: |
| 55 SkLocalMatrixShader(SkReadBuffer&); |
| 56 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 57 virtual Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE
; |
| 58 |
| 59 private: |
| 60 SkAutoTUnref<SkShader> fProxyShader; |
| 61 SkMatrix fProxyLocalMatrix; |
| 62 |
| 63 typedef SkShader INHERITED; |
| 64 }; |
| 65 |
| 66 #endif |
OLD | NEW |