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 19 matching lines...) Expand all Loading... |
30 #include "wtf/PassOwnPtr.h" | 30 #include "wtf/PassOwnPtr.h" |
31 | 31 |
32 #include <gtest/gtest.h> | 32 #include <gtest/gtest.h> |
33 | 33 |
34 using namespace blink; | 34 using namespace blink; |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 class MockGraphicsLayerClient : public GraphicsLayerClient { | 38 class MockGraphicsLayerClient : public GraphicsLayerClient { |
39 public: | 39 public: |
40 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) OVERRIDE { } | 40 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) override { } |
41 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) OVERRIDE { } | 41 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) override { } |
42 virtual String debugName(const GraphicsLayer*) OVERRIDE { return String(); } | 42 virtual String debugName(const GraphicsLayer*) override { return String(); } |
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 isOpaque) | 48 static PassRefPtr<TestImage> create(const IntSize& size, bool isOpaque) |
49 { | 49 { |
50 return adoptRef(new TestImage(size, isOpaque)); | 50 return adoptRef(new TestImage(size, isOpaque)); |
51 } | 51 } |
52 | 52 |
53 explicit TestImage(const IntSize& size, bool isOpaque) | 53 explicit TestImage(const IntSize& size, bool isOpaque) |
54 : Image(0) | 54 : Image(0) |
55 , m_size(size) | 55 , m_size(size) |
56 { | 56 { |
57 SkBitmap bitmap; | 57 SkBitmap bitmap; |
58 bitmap.allocN32Pixels(size.width(), size.height(), isOpaque); | 58 bitmap.allocN32Pixels(size.width(), size.height(), isOpaque); |
59 m_nativeImage = NativeImageSkia::create(bitmap); | 59 m_nativeImage = NativeImageSkia::create(bitmap); |
60 } | 60 } |
61 | 61 |
62 virtual bool isBitmapImage() const OVERRIDE | 62 virtual bool isBitmapImage() const override |
63 { | 63 { |
64 return true; | 64 return true; |
65 } | 65 } |
66 | 66 |
67 virtual bool currentFrameKnownToBeOpaque() OVERRIDE | 67 virtual bool currentFrameKnownToBeOpaque() override |
68 { | 68 { |
69 return m_nativeImage->bitmap().isOpaque(); | 69 return m_nativeImage->bitmap().isOpaque(); |
70 } | 70 } |
71 | 71 |
72 virtual IntSize size() const OVERRIDE | 72 virtual IntSize size() const override |
73 { | 73 { |
74 return m_size; | 74 return m_size; |
75 } | 75 } |
76 | 76 |
77 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() OVERRIDE | 77 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() override |
78 { | 78 { |
79 if (m_size.isZero()) | 79 if (m_size.isZero()) |
80 return nullptr; | 80 return nullptr; |
81 | 81 |
82 return m_nativeImage; | 82 return m_nativeImage; |
83 } | 83 } |
84 | 84 |
85 // Stub implementations of pure virtual Image functions. | 85 // Stub implementations of pure virtual Image functions. |
86 virtual void destroyDecodedData(bool) OVERRIDE | 86 virtual void destroyDecodedData(bool) override |
87 { | 87 { |
88 } | 88 } |
89 | 89 |
90 virtual void draw(GraphicsContext*, const FloatRect&, const FloatRect&, Comp
ositeOperator, WebBlendMode) OVERRIDE | 90 virtual void draw(GraphicsContext*, const FloatRect&, const FloatRect&, Comp
ositeOperator, WebBlendMode) override |
91 { | 91 { |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 | 95 |
96 IntSize m_size; | 96 IntSize m_size; |
97 | 97 |
98 RefPtr<NativeImageSkia> m_nativeImage; | 98 RefPtr<NativeImageSkia> m_nativeImage; |
99 }; | 99 }; |
100 | 100 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 141 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
142 | 142 |
143 graphicsLayer->setContentsToImage(opaqueImage.get()); | 143 graphicsLayer->setContentsToImage(opaqueImage.get()); |
144 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); | 144 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); |
145 | 145 |
146 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); | 146 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); |
147 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); | 147 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); |
148 } | 148 } |
149 | 149 |
150 } // namespace | 150 } // namespace |
OLD | NEW |