| OLD | NEW |
| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "platform/graphics/gpu/DrawingBuffer.h" | 33 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 34 | 34 |
| 35 #include "platform/graphics/ImageBuffer.h" | 35 #include "platform/graphics/ImageBuffer.h" |
| 36 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 36 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 37 #include "platform/graphics/test/MockWebGraphicsContext3D.h" |
| 37 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 38 #include "public/platform/WebExternalTextureMailbox.h" | 39 #include "public/platform/WebExternalTextureMailbox.h" |
| 39 #include "web/tests/MockWebGraphicsContext3D.h" | |
| 40 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 41 | 41 |
| 42 #include <gmock/gmock.h> | 42 #include <gmock/gmock.h> |
| 43 #include <gtest/gtest.h> | 43 #include <gtest/gtest.h> |
| 44 | 44 |
| 45 using namespace WebCore; | 45 using namespace WebCore; |
| 46 using namespace blink; | 46 using namespace blink; |
| 47 using testing::Test; | 47 using testing::Test; |
| 48 using testing::_; | 48 using testing::_; |
| 49 | 49 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 WebGLId m_boundTexture; | 98 WebGLId m_boundTexture; |
| 99 HashMap<WebGLId, IntSize> m_textureSizes; | 99 HashMap<WebGLId, IntSize> m_textureSizes; |
| 100 WGC3Dbyte m_currentMailboxByte; | 100 WGC3Dbyte m_currentMailboxByte; |
| 101 IntSize m_mostRecentlyProducedSize; | 101 IntSize m_mostRecentlyProducedSize; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 static const int initialWidth = 100; | 104 static const int initialWidth = 100; |
| 105 static const int initialHeight = 100; | 105 static const int initialHeight = 100; |
| 106 static const int alternateHeight = 50; | 106 static const int alternateHeight = 50; |
| 107 | 107 |
| 108 } // namespace | |
| 109 | |
| 110 class DrawingBufferTest : public Test { | 108 class DrawingBufferTest : public Test { |
| 111 protected: | 109 protected: |
| 112 virtual void SetUp() | 110 virtual void SetUp() |
| 113 { | 111 { |
| 114 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new
FakeContextEvictionManager()); | 112 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new
FakeContextEvictionManager()); |
| 115 m_context = adoptPtr(new WebGraphicsContext3DForTests); | 113 m_context = adoptPtr(new WebGraphicsContext3DForTests); |
| 116 m_drawingBuffer = DrawingBuffer::create(m_context.get(), IntSize(initial
Width, initialHeight), DrawingBuffer::Preserve, contextEvictionManager.release()
); | 114 m_drawingBuffer = DrawingBuffer::create(m_context.get(), IntSize(initial
Width, initialHeight), DrawingBuffer::Preserve, contextEvictionManager.release()
); |
| 117 } | 115 } |
| 118 | 116 |
| 119 WebGraphicsContext3DForTests* webContext() | 117 WebGraphicsContext3DForTests* webContext() |
| 120 { | 118 { |
| 121 return m_context.get(); | 119 return m_context.get(); |
| 122 } | 120 } |
| 123 | 121 |
| 124 OwnPtr<WebGraphicsContext3DForTests> m_context; | 122 OwnPtr<WebGraphicsContext3DForTests> m_context; |
| 125 RefPtr<DrawingBuffer> m_drawingBuffer; | 123 RefPtr<DrawingBuffer> m_drawingBuffer; |
| 126 }; | 124 }; |
| 127 | 125 |
| 128 namespace { | |
| 129 | |
| 130 TEST_F(DrawingBufferTest, testPaintRenderingResultsToCanvas) | 126 TEST_F(DrawingBufferTest, testPaintRenderingResultsToCanvas) |
| 131 { | 127 { |
| 132 OwnPtr<ImageBufferSurface> imageBufferSurface = adoptPtr(new UnacceleratedIm
ageBufferSurface(IntSize(initialWidth, initialHeight))); | 128 OwnPtr<ImageBufferSurface> imageBufferSurface = adoptPtr(new UnacceleratedIm
ageBufferSurface(IntSize(initialWidth, initialHeight))); |
| 133 EXPECT_FALSE(!imageBufferSurface); | 129 EXPECT_FALSE(!imageBufferSurface); |
| 134 EXPECT_TRUE(imageBufferSurface->isValid()); | 130 EXPECT_TRUE(imageBufferSurface->isValid()); |
| 135 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageBufferSurface.rel
ease()); | 131 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageBufferSurface.rel
ease()); |
| 136 EXPECT_FALSE(!imageBuffer); | 132 EXPECT_FALSE(!imageBuffer); |
| 137 EXPECT_FALSE(imageBuffer->isAccelerated()); | 133 EXPECT_FALSE(imageBuffer->isAccelerated()); |
| 138 EXPECT_FALSE(imageBuffer->bitmap().isNull()); | 134 EXPECT_FALSE(imageBuffer->bitmap().isNull()); |
| 139 m_drawingBuffer->paintRenderingResultsToCanvas(imageBuffer.get()); | 135 m_drawingBuffer->paintRenderingResultsToCanvas(imageBuffer.get()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); | 234 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); |
| 239 EXPECT_EQ(TextureMailboxWrapper(mailbox3), TextureMailboxWrapper(recycledMai
lbox)); | 235 EXPECT_EQ(TextureMailboxWrapper(mailbox3), TextureMailboxWrapper(recycledMai
lbox)); |
| 240 | 236 |
| 241 // The third recycled mailbox must be 1. | 237 // The third recycled mailbox must be 1. |
| 242 m_drawingBuffer->markContentsChanged(); | 238 m_drawingBuffer->markContentsChanged(); |
| 243 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); | 239 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); |
| 244 EXPECT_EQ(TextureMailboxWrapper(mailbox1), TextureMailboxWrapper(recycledMai
lbox)); | 240 EXPECT_EQ(TextureMailboxWrapper(mailbox1), TextureMailboxWrapper(recycledMai
lbox)); |
| 245 } | 241 } |
| 246 | 242 |
| 247 } // namespace | 243 } // namespace |
| OLD | NEW |