OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
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 #ifndef SkSVGRenderContext_DEFINED | 8 #ifndef SkSVGRenderContext_DEFINED |
9 #define SkSVGRenderContext_DEFINED | 9 #define SkSVGRenderContext_DEFINED |
10 | 10 |
11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #include "SkSize.h" | 13 #include "SkSize.h" |
14 #include "SkSVGAttribute.h" | 14 #include "SkSVGAttribute.h" |
| 15 #include "SkSVGIDMapper.h" |
15 #include "SkTLazy.h" | 16 #include "SkTLazy.h" |
16 #include "SkTypes.h" | 17 #include "SkTypes.h" |
17 | 18 |
18 class SkCanvas; | 19 class SkCanvas; |
19 class SkSVGLength; | 20 class SkSVGLength; |
20 | 21 |
21 class SkSVGLengthContext { | 22 class SkSVGLengthContext { |
22 public: | 23 public: |
23 SkSVGLengthContext(const SkSize& viewport, SkScalar dpi = 90) | 24 SkSVGLengthContext(const SkSize& viewport, SkScalar dpi = 90) |
24 : fViewport(viewport), fDPI(dpi) {} | 25 : fViewport(viewport), fDPI(dpi) {} |
(...skipping 24 matching lines...) Expand all Loading... |
49 // Inherited presentation attributes, computed for the current node. | 50 // Inherited presentation attributes, computed for the current node. |
50 SkSVGPresentationAttributes fInherited; | 51 SkSVGPresentationAttributes fInherited; |
51 | 52 |
52 // Cached paints, reflecting the current presentation attributes. | 53 // Cached paints, reflecting the current presentation attributes. |
53 SkPaint fFillPaint; | 54 SkPaint fFillPaint; |
54 SkPaint fStrokePaint; | 55 SkPaint fStrokePaint; |
55 }; | 56 }; |
56 | 57 |
57 class SkSVGRenderContext { | 58 class SkSVGRenderContext { |
58 public: | 59 public: |
59 SkSVGRenderContext(SkCanvas*, const SkSVGLengthContext&, const SkSVGPresenta
tionContext&); | 60 SkSVGRenderContext(SkCanvas*, const SkSVGIDMapper&, const SkSVGLengthContext
&, |
| 61 const SkSVGPresentationContext&); |
60 SkSVGRenderContext(const SkSVGRenderContext&); | 62 SkSVGRenderContext(const SkSVGRenderContext&); |
61 ~SkSVGRenderContext(); | 63 ~SkSVGRenderContext(); |
62 | 64 |
63 const SkSVGLengthContext& lengthContext() const { return *fLengthContext; } | 65 const SkSVGLengthContext& lengthContext() const { return *fLengthContext; } |
64 SkSVGLengthContext* writableLengthContext() { return fLengthContext.writable
(); } | 66 SkSVGLengthContext* writableLengthContext() { return fLengthContext.writable
(); } |
65 | 67 |
66 SkCanvas* canvas() const { return fCanvas; } | 68 SkCanvas* canvas() const { return fCanvas; } |
67 | 69 |
68 void applyPresentationAttributes(const SkSVGPresentationAttributes&); | 70 void applyPresentationAttributes(const SkSVGPresentationAttributes&); |
69 | 71 |
| 72 const SkSVGNode* findNodeById(const SkString&) const; |
| 73 |
70 const SkPaint* fillPaint() const; | 74 const SkPaint* fillPaint() const; |
71 const SkPaint* strokePaint() const; | 75 const SkPaint* strokePaint() const; |
72 | 76 |
73 private: | 77 private: |
74 // Stack-only | 78 // Stack-only |
75 void* operator new(size_t) = delete; | 79 void* operator new(size_t) = delete; |
76 void* operator new(size_t, void*) = delete; | 80 void* operator new(size_t, void*) = delete; |
77 SkSVGRenderContext& operator=(const SkSVGRenderContext&) = delete; | 81 SkSVGRenderContext& operator=(const SkSVGRenderContext&) = delete; |
78 | 82 |
| 83 const SkSVGIDMapper& fIDMapper; |
79 SkTCopyOnFirstWrite<SkSVGLengthContext> fLengthContext; | 84 SkTCopyOnFirstWrite<SkSVGLengthContext> fLengthContext; |
80 SkTCopyOnFirstWrite<SkSVGPresentationContext> fPresentationContext; | 85 SkTCopyOnFirstWrite<SkSVGPresentationContext> fPresentationContext; |
81 SkCanvas* fCanvas; | 86 SkCanvas* fCanvas; |
82 // The save count on 'fCanvas' at construction time. | 87 // The save count on 'fCanvas' at construction time. |
83 // A restoreToCount() will be issued on destruction. | 88 // A restoreToCount() will be issued on destruction. |
84 int fCanvasSaveCount; | 89 int fCanvasSaveCount; |
85 }; | 90 }; |
86 | 91 |
87 #endif // SkSVGRenderContext_DEFINED | 92 #endif // SkSVGRenderContext_DEFINED |
OLD | NEW |