| 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 "SkTLazy.h" | 15 #include "SkTLazy.h" | 
| 16 #include "SkTypes.h" | 16 #include "SkTypes.h" | 
| 17 | 17 | 
| 18 class SkCanvas; | 18 class SkCanvas; | 
| 19 class SkSVGLength; | 19 class SkSVGLength; | 
| 20 | 20 | 
| 21 class SkSVGLengthContext { | 21 class SkSVGLengthContext { | 
| 22 public: | 22 public: | 
| 23     SkSVGLengthContext(const SkSize& viewport) : fViewport(viewport) {} | 23     SkSVGLengthContext(const SkSize& viewport, SkScalar dpi = 90) | 
|  | 24         : fViewport(viewport), fDPI(dpi) {} | 
| 24 | 25 | 
| 25     enum class LengthType { | 26     enum class LengthType { | 
| 26         kHorizontal, | 27         kHorizontal, | 
| 27         kVertical, | 28         kVertical, | 
| 28         kOther, | 29         kOther, | 
| 29     }; | 30     }; | 
| 30 | 31 | 
| 31     const SkSize& viewPort() const { return fViewport; } | 32     const SkSize& viewPort() const { return fViewport; } | 
| 32     void setViewPort(const SkSize& viewport) { fViewport = viewport; } | 33     void setViewPort(const SkSize& viewport) { fViewport = viewport; } | 
| 33 | 34 | 
| 34     SkScalar resolve(const SkSVGLength&, LengthType) const; | 35     SkScalar resolve(const SkSVGLength&, LengthType) const; | 
| 35     SkRect   resolveRect(const SkSVGLength& x, const SkSVGLength& y, | 36     SkRect   resolveRect(const SkSVGLength& x, const SkSVGLength& y, | 
| 36                          const SkSVGLength& w, const SkSVGLength& h) const; | 37                          const SkSVGLength& w, const SkSVGLength& h) const; | 
| 37 | 38 | 
| 38 private: | 39 private: | 
| 39     SkSize fViewport; | 40     SkSize   fViewport; | 
|  | 41     SkScalar fDPI; | 
| 40 }; | 42 }; | 
| 41 | 43 | 
| 42 struct SkSVGPresentationContext { | 44 struct SkSVGPresentationContext { | 
| 43     SkSVGPresentationContext(); | 45     SkSVGPresentationContext(); | 
| 44     SkSVGPresentationContext(const SkSVGPresentationContext&)            = defau
    lt; | 46     SkSVGPresentationContext(const SkSVGPresentationContext&)            = defau
    lt; | 
| 45     SkSVGPresentationContext& operator=(const SkSVGPresentationContext&) = defau
    lt; | 47     SkSVGPresentationContext& operator=(const SkSVGPresentationContext&) = defau
    lt; | 
| 46 | 48 | 
| 47     // Inherited presentation attributes, computed for the current node. | 49     // Inherited presentation attributes, computed for the current node. | 
| 48     SkSVGPresentationAttributes fInherited; | 50     SkSVGPresentationAttributes fInherited; | 
| 49 | 51 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 76 | 78 | 
| 77     SkTCopyOnFirstWrite<SkSVGLengthContext>       fLengthContext; | 79     SkTCopyOnFirstWrite<SkSVGLengthContext>       fLengthContext; | 
| 78     SkTCopyOnFirstWrite<SkSVGPresentationContext> fPresentationContext; | 80     SkTCopyOnFirstWrite<SkSVGPresentationContext> fPresentationContext; | 
| 79     SkCanvas*                                     fCanvas; | 81     SkCanvas*                                     fCanvas; | 
| 80     // The save count on 'fCanvas' at construction time. | 82     // The save count on 'fCanvas' at construction time. | 
| 81     // A restoreToCount() will be issued on destruction. | 83     // A restoreToCount() will be issued on destruction. | 
| 82     int                                           fCanvasSaveCount; | 84     int                                           fCanvasSaveCount; | 
| 83 }; | 85 }; | 
| 84 | 86 | 
| 85 #endif // SkSVGRenderContext_DEFINED | 87 #endif // SkSVGRenderContext_DEFINED | 
| OLD | NEW | 
|---|