OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 17 matching lines...) Expand all Loading... |
28 PatternResourceType, | 28 PatternResourceType, |
29 LinearGradientResourceType, | 29 LinearGradientResourceType, |
30 RadialGradientResourceType, | 30 RadialGradientResourceType, |
31 SolidColorResourceType, | 31 SolidColorResourceType, |
32 FilterResourceType, | 32 FilterResourceType, |
33 ClipperResourceType | 33 ClipperResourceType |
34 }; | 34 }; |
35 | 35 |
36 // If this enum changes change the unsigned bitfields using it. | 36 // If this enum changes change the unsigned bitfields using it. |
37 enum RenderSVGResourceMode { | 37 enum RenderSVGResourceMode { |
38 ApplyToDefaultMode = 1 << 0, // used for all resources except gradient/patte
rn | 38 ApplyToFillMode = 1 << 0, |
39 ApplyToFillMode = 1 << 1, | 39 ApplyToStrokeMode = 1 << 1, |
40 ApplyToStrokeMode = 1 << 2, | 40 ApplyToTextMode = 1 << 2 // used in combination with ApplyTo{Fill|Stroke}
Mode |
41 ApplyToTextMode = 1 << 3 // used in combination with ApplyTo{Fill|Stroke}
Mode | |
42 }; | 41 }; |
43 typedef unsigned RenderSVGResourceModeFlags; | 42 typedef unsigned RenderSVGResourceModeFlags; |
44 | 43 |
45 class GraphicsContext; | 44 class GraphicsContext; |
46 class RenderObject; | 45 class RenderObject; |
47 class RenderStyle; | 46 class RenderStyle; |
48 class RenderSVGResourceSolidColor; | 47 class RenderSVGResourceSolidColor; |
49 | 48 |
50 class RenderSVGResource { | 49 class RenderSVGResource { |
51 public: | 50 public: |
52 RenderSVGResource() { } | 51 RenderSVGResource() { } |
53 virtual ~RenderSVGResource() { } | 52 virtual ~RenderSVGResource() { } |
54 | 53 |
55 virtual void removeAllClientsFromCache(bool markForInvalidation = true) = 0; | 54 virtual void removeAllClientsFromCache(bool markForInvalidation = true) = 0; |
56 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation =
true) = 0; | 55 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation =
true) = 0; |
57 | 56 |
58 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u
nsigned short resourceMode) = 0; | 57 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u
nsigned short resourceMode); |
59 virtual void postApplyResource(RenderObject*, GraphicsContext*&) { } | 58 virtual void postApplyResource(RenderObject*, GraphicsContext*&) { } |
60 | 59 |
61 virtual RenderSVGResourceType resourceType() const = 0; | 60 virtual RenderSVGResourceType resourceType() const = 0; |
62 | 61 |
63 template<class Renderer> | 62 template<class Renderer> |
64 Renderer* cast() | 63 Renderer* cast() |
65 { | 64 { |
66 if (Renderer::s_resourceType == resourceType()) | 65 if (Renderer::s_resourceType == resourceType()) |
67 return static_cast<Renderer*>(this); | 66 return static_cast<Renderer*>(this); |
68 | 67 |
69 return 0; | 68 return 0; |
70 } | 69 } |
71 | 70 |
72 // Helper utilities used in the render tree to access resources used for pai
nting shapes/text (gradients & patterns & solid colors only) | 71 // Helper utilities used in the render tree to access resources used for pai
nting shapes/text (gradients & patterns & solid colors only) |
73 // If hasFallback gets set to true, the sharedSolidPaintingResource is set t
o a fallback color. | 72 // If hasFallback gets set to true, the sharedSolidPaintingResource is set t
o a fallback color. |
74 static RenderSVGResource* requestPaintingResource(RenderSVGResourceMode, Ren
derObject*, const RenderStyle*, bool& hasFallback); | 73 static RenderSVGResource* requestPaintingResource(RenderSVGResourceMode, Ren
derObject*, const RenderStyle*, bool& hasFallback); |
75 static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); | 74 static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); |
76 | 75 |
77 static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool n
eedsLayout = true); | 76 static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool n
eedsLayout = true); |
78 }; | 77 }; |
79 | 78 |
80 #define DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ | 79 #define DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ |
81 DEFINE_TYPE_CASTS(thisType, RenderSVGResource, resource, resource->resourceT
ype() == typeName, resource.resourceType() == typeName) | 80 DEFINE_TYPE_CASTS(thisType, RenderSVGResource, resource, resource->resourceT
ype() == typeName, resource.resourceType() == typeName) |
82 | 81 |
83 } | 82 } |
84 | 83 |
85 #endif | 84 #endif |
OLD | NEW |