| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | |
| 3 * | |
| 4 * This library is free software; you can redistribute it and/or | |
| 5 * modify it under the terms of the GNU Library General Public | |
| 6 * License as published by the Free Software Foundation; either | |
| 7 * version 2 of the License, or (at your option) any later version. | |
| 8 * | |
| 9 * This library is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 * Library General Public License for more details. | |
| 13 * | |
| 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 | |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 17 * Boston, MA 02110-1301, USA. | |
| 18 */ | |
| 19 | |
| 20 #ifndef RenderSVGResourcePaintServer_h | |
| 21 #define RenderSVGResourcePaintServer_h | |
| 22 | |
| 23 #include "core/rendering/svg/RenderSVGResourceContainer.h" | |
| 24 #include "platform/graphics/Color.h" | |
| 25 #include "platform/graphics/Gradient.h" | |
| 26 #include "platform/graphics/Pattern.h" | |
| 27 | |
| 28 namespace blink { | |
| 29 | |
| 30 enum RenderSVGResourceMode { | |
| 31 ApplyToFillMode, | |
| 32 ApplyToStrokeMode, | |
| 33 }; | |
| 34 | |
| 35 class GraphicsContext; | |
| 36 class GraphicsContextStateSaver; | |
| 37 class LayoutObject; | |
| 38 class RenderSVGResourcePaintServer; | |
| 39 class LayoutStyle; | |
| 40 | |
| 41 class SVGPaintServer { | |
| 42 public: | |
| 43 explicit SVGPaintServer(Color); | |
| 44 explicit SVGPaintServer(PassRefPtr<Gradient>); | |
| 45 explicit SVGPaintServer(PassRefPtr<Pattern>); | |
| 46 | |
| 47 static SVGPaintServer requestForRenderer(const LayoutObject&, const LayoutSt
yle&, RenderSVGResourceMode); | |
| 48 static bool existsForRenderer(const LayoutObject&, const LayoutStyle&, Rende
rSVGResourceMode); | |
| 49 | |
| 50 void apply(GraphicsContext&, RenderSVGResourceMode, float paintAlpha, Graphi
csContextStateSaver&); | |
| 51 | |
| 52 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa
rent)); } | |
| 53 bool isValid() const { return m_color != Color::transparent; } | |
| 54 | |
| 55 bool isTransformDependent() const { return m_gradient || m_pattern; } | |
| 56 void prependTransform(const AffineTransform&); | |
| 57 | |
| 58 private: | |
| 59 RefPtr<Gradient> m_gradient; | |
| 60 RefPtr<Pattern> m_pattern; | |
| 61 Color m_color; | |
| 62 }; | |
| 63 | |
| 64 // If |SVGPaintDescription::hasFallback| is true, |SVGPaintDescription::color| i
s set to a fallback color. | |
| 65 struct SVGPaintDescription { | |
| 66 SVGPaintDescription() : resource(nullptr), isValid(false), hasFallback(false
) { } | |
| 67 SVGPaintDescription(Color color) : resource(nullptr), color(color), isValid(
true), hasFallback(false) { } | |
| 68 SVGPaintDescription(RenderSVGResourcePaintServer* resource) : resource(resou
rce), isValid(true), hasFallback(false) { ASSERT(resource); } | |
| 69 SVGPaintDescription(RenderSVGResourcePaintServer* resource, Color fallbackCo
lor) : resource(resource), color(fallbackColor), isValid(true), hasFallback(true
) { ASSERT(resource); } | |
| 70 | |
| 71 RenderSVGResourcePaintServer* resource; | |
| 72 Color color; | |
| 73 bool isValid; | |
| 74 bool hasFallback; | |
| 75 }; | |
| 76 | |
| 77 class RenderSVGResourcePaintServer : public RenderSVGResourceContainer { | |
| 78 public: | |
| 79 RenderSVGResourcePaintServer(SVGElement*); | |
| 80 virtual ~RenderSVGResourcePaintServer(); | |
| 81 | |
| 82 virtual SVGPaintServer preparePaintServer(const LayoutObject&) = 0; | |
| 83 | |
| 84 // Helper utilities used in to access the underlying resources for DRT. | |
| 85 static SVGPaintDescription requestPaintDescription(const LayoutObject&, cons
t LayoutStyle&, RenderSVGResourceMode); | |
| 86 }; | |
| 87 | |
| 88 DEFINE_TYPE_CASTS(RenderSVGResourcePaintServer, RenderSVGResourceContainer, reso
urce, resource->isSVGPaintServer(), resource.isSVGPaintServer()); | |
| 89 | |
| 90 } | |
| 91 | |
| 92 #endif | |
| OLD | NEW |