Chromium Code Reviews| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef RenderSVGResource_h | 20 #ifndef RenderSVGResource_h |
| 21 #define RenderSVGResource_h | 21 #define RenderSVGResource_h |
| 22 | 22 |
| 23 #include "platform/graphics/Color.h" | |
| 24 #include "platform/graphics/Gradient.h" | |
| 25 #include "platform/graphics/Pattern.h" | |
| 26 | |
| 23 namespace blink { | 27 namespace blink { |
| 24 | 28 |
| 25 enum RenderSVGResourceType { | 29 enum RenderSVGResourceType { |
| 26 MaskerResourceType, | 30 MaskerResourceType, |
| 27 MarkerResourceType, | 31 MarkerResourceType, |
| 28 PatternResourceType, | 32 PatternResourceType, |
| 29 LinearGradientResourceType, | 33 LinearGradientResourceType, |
| 30 RadialGradientResourceType, | 34 RadialGradientResourceType, |
| 31 SolidColorResourceType, | 35 SolidColorResourceType, |
| 32 FilterResourceType, | 36 FilterResourceType, |
| 33 ClipperResourceType | 37 ClipperResourceType |
| 34 }; | 38 }; |
| 35 | 39 |
| 36 // If this enum changes change the unsigned bitfields using it. | 40 // If this enum changes change the unsigned bitfields using it. |
| 37 enum RenderSVGResourceMode { | 41 enum RenderSVGResourceMode { |
| 38 ApplyToFillMode = 1 << 0, | 42 ApplyToFillMode = 1 << 0, |
| 39 ApplyToStrokeMode = 1 << 1, | 43 ApplyToStrokeMode = 1 << 1, |
| 40 ApplyToTextMode = 1 << 2 // used in combination with ApplyTo{Fill|Stroke} Mode | 44 ApplyToTextMode = 1 << 2 // used in combination with ApplyTo{Fill|Stroke} Mode |
| 41 }; | 45 }; |
| 42 typedef unsigned RenderSVGResourceModeFlags; | 46 typedef unsigned RenderSVGResourceModeFlags; |
| 43 | 47 |
| 44 class GraphicsContext; | 48 class GraphicsContext; |
| 49 class GraphicsContextStateSaver; | |
| 45 class RenderObject; | 50 class RenderObject; |
| 46 class RenderStyle; | 51 class RenderStyle; |
| 47 class RenderSVGResourceSolidColor; | 52 class RenderSVGResourceSolidColor; |
| 48 | 53 |
| 54 class SVGPaintServer { | |
| 55 public: | |
| 56 explicit SVGPaintServer(Color); | |
| 57 explicit SVGPaintServer(PassRefPtr<Gradient>); | |
| 58 explicit SVGPaintServer(PassRefPtr<Pattern>); | |
| 59 | |
| 60 static SVGPaintServer requestForRenderer(RenderObject&, RenderStyle*, Render SVGResourceModeFlags); | |
| 61 | |
| 62 void apply(GraphicsContext&, RenderSVGResourceMode, GraphicsContextStateSave r* = 0); | |
| 63 | |
| 64 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); } | |
| 65 bool isValid() const { return m_color != Color::transparent; } | |
|
pdr.
2014/10/13 17:08:57
(For a followup) What do you think about isNonTran
| |
| 66 | |
| 67 private: | |
| 68 RefPtr<Gradient> m_gradient; | |
| 69 RefPtr<Pattern> m_pattern; | |
| 70 Color m_color; | |
| 71 }; | |
| 72 | |
| 49 class RenderSVGResource { | 73 class RenderSVGResource { |
| 50 public: | 74 public: |
| 51 RenderSVGResource() { } | 75 RenderSVGResource() { } |
| 52 virtual ~RenderSVGResource() { } | 76 virtual ~RenderSVGResource() { } |
| 53 | 77 |
| 54 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*, Re nderSVGResourceModeFlags); | 78 virtual SVGPaintServer preparePaintServer(RenderObject*, RenderStyle*, Rende rSVGResourceModeFlags); |
| 55 virtual void postApplyResource(GraphicsContext*) { } | |
| 56 | 79 |
| 57 virtual RenderSVGResourceType resourceType() const = 0; | 80 virtual RenderSVGResourceType resourceType() const = 0; |
| 58 | 81 |
| 59 // Helper utilities used in the render tree to access resources used for pai nting shapes/text (gradients & patterns & solid colors only) | 82 // Helper utilities used in the render tree to access resources used for pai nting shapes/text (gradients & patterns & solid colors only) |
| 60 // If hasFallback gets set to true, the sharedSolidPaintingResource is set t o a fallback color. | 83 // If hasFallback gets set to true, the sharedSolidPaintingResource is set t o a fallback color. |
| 61 static RenderSVGResource* requestPaintingResource(RenderSVGResourceMode, Ren derObject*, const RenderStyle*, bool& hasFallback); | 84 static RenderSVGResource* requestPaintingResource(RenderSVGResourceMode, Ren derObject*, const RenderStyle*, bool& hasFallback); |
| 62 static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); | 85 static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); |
| 63 | 86 |
| 64 static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool n eedsLayout = true); | 87 static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool n eedsLayout = true); |
| 65 | |
| 66 protected: | |
| 67 // Transfer fill/stroke style (except paint server) to the GC. | |
| 68 static void updateGraphicsContext(GraphicsContext*, const RenderStyle*, cons t RenderObject&, unsigned resourceModeFlags); | |
| 69 }; | 88 }; |
| 70 | 89 |
| 71 #define DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ | 90 #define DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ |
| 72 DEFINE_TYPE_CASTS(thisType, RenderSVGResource, resource, resource->resourceT ype() == typeName, resource.resourceType() == typeName) | 91 DEFINE_TYPE_CASTS(thisType, RenderSVGResource, resource, resource->resourceT ype() == typeName, resource.resourceType() == typeName) |
| 73 | 92 |
| 74 } | 93 } |
| 75 | 94 |
| 76 #endif | 95 #endif |
| OLD | NEW |