Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: Source/core/platform/graphics/ImageForContainer.h

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

Powered by Google App Engine
This is Rietveld 408576698