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