OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "core/platform/graphics/skia/NativeImageSkia.h" | 31 #include "core/platform/graphics/skia/NativeImageSkia.h" |
32 #include <public/WebImageLayer.h> | 32 #include <public/WebImageLayer.h> |
33 #include <wtf/PassOwnPtr.h> | 33 #include <wtf/PassOwnPtr.h> |
34 | 34 |
35 using namespace WebCore; | 35 using namespace WebCore; |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 class MockGraphicsLayerClient : public GraphicsLayerClient { | 39 class MockGraphicsLayerClient : public GraphicsLayerClient { |
40 public: | 40 public: |
41 virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { } | 41 virtual void notifyAnimationStarted(const GraphicsLayer*, double time) OVERR
IDE { } |
42 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) { } | 42 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) OVERRIDE { } |
43 }; | 43 }; |
44 | 44 |
45 class TestImage : public Image { | 45 class TestImage : public Image { |
46 public: | 46 public: |
47 | 47 |
48 static PassRefPtr<TestImage> create(const IntSize& size, bool opaque) | 48 static PassRefPtr<TestImage> create(const IntSize& size, bool opaque) |
49 { | 49 { |
50 return adoptRef(new TestImage(size, opaque)); | 50 return adoptRef(new TestImage(size, opaque)); |
51 } | 51 } |
52 | 52 |
53 explicit TestImage(const IntSize& size, bool opaque) | 53 explicit TestImage(const IntSize& size, bool opaque) |
54 : Image(0) | 54 : Image(0) |
55 , m_size(size) | 55 , m_size(size) |
56 { | 56 { |
57 m_nativeImage = NativeImageSkia::create(); | 57 m_nativeImage = NativeImageSkia::create(); |
58 m_nativeImage->bitmap().setConfig(SkBitmap::kARGB_8888_Config, | 58 m_nativeImage->bitmap().setConfig(SkBitmap::kARGB_8888_Config, |
59 size.width(), size.height(), 0); | 59 size.width(), size.height(), 0); |
60 m_nativeImage->bitmap().allocPixels(); | 60 m_nativeImage->bitmap().allocPixels(); |
61 m_nativeImage->bitmap().setIsOpaque(opaque); | 61 m_nativeImage->bitmap().setIsOpaque(opaque); |
62 } | 62 } |
63 | 63 |
64 virtual bool isBitmapImage() const | 64 virtual bool isBitmapImage() const OVERRIDE |
65 { | 65 { |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 virtual bool currentFrameKnownToBeOpaque() | 69 virtual bool currentFrameKnownToBeOpaque() OVERRIDE |
70 { | 70 { |
71 return m_nativeImage->bitmap().isOpaque(); | 71 return m_nativeImage->bitmap().isOpaque(); |
72 } | 72 } |
73 | 73 |
74 virtual IntSize size() const | 74 virtual IntSize size() const OVERRIDE |
75 { | 75 { |
76 return m_size; | 76 return m_size; |
77 } | 77 } |
78 | 78 |
79 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() | 79 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() OVERRIDE |
80 { | 80 { |
81 if (m_size.isZero()) | 81 if (m_size.isZero()) |
82 return 0; | 82 return 0; |
83 | 83 |
84 return m_nativeImage; | 84 return m_nativeImage; |
85 } | 85 } |
86 | 86 |
87 // Stub implementations of pure virtual Image functions. | 87 // Stub implementations of pure virtual Image functions. |
88 virtual void destroyDecodedData(bool) | 88 virtual void destroyDecodedData() OVERRIDE |
89 { | 89 { |
90 } | 90 } |
91 | 91 |
92 virtual unsigned int decodedSize() const | 92 virtual unsigned decodedSize() const OVERRIDE |
93 { | 93 { |
94 return 0u; | 94 return 0u; |
95 } | 95 } |
96 | 96 |
97 virtual void draw(WebCore::GraphicsContext*, const WebCore::FloatRect&, | 97 virtual void draw(GraphicsContext*, const FloatRect&, const FloatRect&, Colo
rSpace, CompositeOperator, BlendMode) OVERRIDE |
98 const WebCore::FloatRect&, WebCore::ColorSpace, | |
99 WebCore::CompositeOperator, WebCore::BlendMode) | |
100 { | 98 { |
101 } | 99 } |
102 | 100 |
103 private: | 101 private: |
104 | 102 |
105 IntSize m_size; | 103 IntSize m_size; |
106 | 104 |
107 RefPtr<NativeImageSkia> m_nativeImage; | 105 RefPtr<NativeImageSkia> m_nativeImage; |
108 }; | 106 }; |
109 | 107 |
(...skipping 11 matching lines...) Expand all Loading... |
121 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 119 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
122 | 120 |
123 graphicsLayer->setContentsToImage(opaqueImage.get()); | 121 graphicsLayer->setContentsToImage(opaqueImage.get()); |
124 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); | 122 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); |
125 | 123 |
126 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); | 124 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); |
127 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); | 125 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); |
128 } | 126 } |
129 | 127 |
130 } // namespace | 128 } // namespace |
OLD | NEW |