Line data Source code
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 GrFragmentProcessor;
16 : class SkArenaAlloc;
17 :
18 0 : class SkLocalMatrixShader : public SkShader {
19 : public:
20 0 : SkLocalMatrixShader(sk_sp<SkShader> proxy, const SkMatrix& localMatrix)
21 0 : : INHERITED(&localMatrix)
22 0 : , fProxyShader(std::move(proxy))
23 0 : {}
24 :
25 0 : GradientType asAGradient(GradientInfo* info) const override {
26 0 : return fProxyShader->asAGradient(info);
27 : }
28 :
29 : #if SK_SUPPORT_GPU
30 : sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
31 : #endif
32 :
33 0 : sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const override {
34 0 : if (localMatrix) {
35 0 : *localMatrix = this->getLocalMatrix();
36 : }
37 0 : return fProxyShader;
38 : }
39 :
40 : SK_TO_STRING_OVERRIDE()
41 0 : SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixShader)
42 :
43 : protected:
44 : void flatten(SkWriteBuffer&) const override;
45 :
46 : Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
47 :
48 : SkImage* onIsAImage(SkMatrix* matrix, TileMode* mode) const override;
49 :
50 : bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
51 : const SkMatrix&, const SkPaint&, const SkMatrix*) const override;
52 :
53 : #ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
54 : bool onIsABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* mode) const override {
55 : return fProxyShader->isABitmap(bitmap, matrix, mode);
56 : }
57 : #endif
58 :
59 : private:
60 : sk_sp<SkShader> fProxyShader;
61 :
62 : typedef SkShader INHERITED;
63 : };
64 :
65 : #endif
|