| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef SVGImageForContainer_h | |
| 27 #define SVGImageForContainer_h | |
| 28 | |
| 29 #include "core/platform/graphics/Image.h" | |
| 30 #include "core/svg/graphics/SVGImage.h" | |
| 31 #include "platform/geometry/FloatRect.h" | |
| 32 #include "platform/geometry/FloatSize.h" | |
| 33 | |
| 34 namespace WebCore { | |
| 35 | |
| 36 class SVGImageForContainer : public Image { | |
| 37 public: | |
| 38 static PassRefPtr<SVGImageForContainer> create(SVGImage* image, const FloatS
ize& containerSize, float zoom) | |
| 39 { | |
| 40 return adoptRef(new SVGImageForContainer(image, containerSize, zoom)); | |
| 41 } | |
| 42 | |
| 43 virtual bool isSVGImage() const OVERRIDE { return true; } | |
| 44 | |
| 45 virtual IntSize size() const OVERRIDE; | |
| 46 | |
| 47 virtual bool usesContainerSize() const OVERRIDE { return m_image->usesContai
nerSize(); } | |
| 48 virtual bool hasRelativeWidth() const OVERRIDE { return m_image->hasRelative
Width(); } | |
| 49 virtual bool hasRelativeHeight() const OVERRIDE { return m_image->hasRelativ
eHeight(); } | |
| 50 virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intr
insicHeight, FloatSize& intrinsicRatio) OVERRIDE | |
| 51 { | |
| 52 m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, int
rinsicRatio); | |
| 53 } | |
| 54 | |
| 55 virtual void draw(GraphicsContext*, const FloatRect&, const FloatRect&, Comp
ositeOperator, BlendMode) OVERRIDE; | |
| 56 | |
| 57 virtual void drawPattern(GraphicsContext*, const FloatRect&, const FloatSize
&, const FloatPoint&, CompositeOperator, const FloatRect&, BlendMode) OVERRIDE; | |
| 58 | |
| 59 // FIXME: Implement this to be less conservative. | |
| 60 virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; } | |
| 61 | |
| 62 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() OVERRIDE; | |
| 63 | |
| 64 private: | |
| 65 SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float
zoom) | |
| 66 : m_image(image) | |
| 67 , m_containerSize(containerSize) | |
| 68 , m_zoom(zoom) | |
| 69 { | |
| 70 } | |
| 71 | |
| 72 virtual void destroyDecodedData(bool) OVERRIDE { } | |
| 73 virtual unsigned decodedSize() const OVERRIDE { return 0; } | |
| 74 | |
| 75 SVGImage* m_image; | |
| 76 const FloatSize m_containerSize; | |
| 77 const float m_zoom; | |
| 78 }; | |
| 79 } | |
| 80 | |
| 81 #endif // SVGImageForContainer_h | |
| OLD | NEW |