| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 108 } // namespace |
| 109 | 109 |
| 110 class DrawingBufferTest : public Test { | 110 class DrawingBufferTest : public Test { |
| 111 protected: | 111 protected: |
| 112 virtual void SetUp() | 112 virtual void SetUp() |
| 113 { | 113 { |
| 114 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new
FakeContextEvictionManager()); | 114 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new
FakeContextEvictionManager()); |
| 115 m_context = adoptPtr(new WebGraphicsContext3DForTests); | 115 OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsC
ontext3DForTests); |
| 116 m_drawingBuffer = DrawingBuffer::create(m_context.get(), IntSize(initial
Width, initialHeight), DrawingBuffer::Preserve, contextEvictionManager.release()
); | 116 m_context = context.get(); |
| 117 m_drawingBuffer = DrawingBuffer::create(context.release(), IntSize(initi
alWidth, initialHeight), DrawingBuffer::Preserve, contextEvictionManager.release
()); |
| 117 } | 118 } |
| 118 | 119 |
| 119 WebGraphicsContext3DForTests* webContext() | 120 WebGraphicsContext3DForTests* webContext() |
| 120 { | 121 { |
| 121 return m_context.get(); | 122 return m_context; |
| 122 } | 123 } |
| 123 | 124 |
| 124 OwnPtr<WebGraphicsContext3DForTests> m_context; | 125 WebGraphicsContext3DForTests* m_context; |
| 125 RefPtr<DrawingBuffer> m_drawingBuffer; | 126 RefPtr<DrawingBuffer> m_drawingBuffer; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 namespace { | 129 namespace { |
| 129 | 130 |
| 130 TEST_F(DrawingBufferTest, testPaintRenderingResultsToCanvas) | 131 TEST_F(DrawingBufferTest, testPaintRenderingResultsToCanvas) |
| 131 { | 132 { |
| 132 OwnPtr<ImageBufferSurface> imageBufferSurface = adoptPtr(new UnacceleratedIm
ageBufferSurface(IntSize(initialWidth, initialHeight))); | 133 OwnPtr<ImageBufferSurface> imageBufferSurface = adoptPtr(new UnacceleratedIm
ageBufferSurface(IntSize(initialWidth, initialHeight))); |
| 133 EXPECT_FALSE(!imageBufferSurface); | 134 EXPECT_FALSE(!imageBufferSurface); |
| 134 EXPECT_TRUE(imageBufferSurface->isValid()); | 135 EXPECT_TRUE(imageBufferSurface->isValid()); |
| 135 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageBufferSurface.rel
ease()); | 136 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageBufferSurface.rel
ease()); |
| 136 EXPECT_FALSE(!imageBuffer); | 137 EXPECT_FALSE(!imageBuffer); |
| 137 EXPECT_FALSE(imageBuffer->isAccelerated()); | 138 EXPECT_FALSE(imageBuffer->isAccelerated()); |
| 138 EXPECT_FALSE(imageBuffer->bitmap().isNull()); | 139 EXPECT_FALSE(imageBuffer->bitmap().isNull()); |
| 139 m_drawingBuffer->paintRenderingResultsToCanvas(imageBuffer.get()); | 140 m_drawingBuffer->paintRenderingResultsToCanvas(imageBuffer.get()); |
| 140 EXPECT_FALSE(imageBuffer->isAccelerated()); | 141 EXPECT_FALSE(imageBuffer->isAccelerated()); |
| 141 EXPECT_FALSE(imageBuffer->bitmap().isNull()); | 142 EXPECT_FALSE(imageBuffer->bitmap().isNull()); |
| 142 } | 143 } |
| 143 | 144 |
| 144 TEST_F(DrawingBufferTest, verifyNoNewBuffersAfterContextLostWithMailboxes) | |
| 145 { | |
| 146 // Tell the buffer its contents changed and context was lost. | |
| 147 m_drawingBuffer->markContentsChanged(); | |
| 148 m_drawingBuffer->releaseResources(); | |
| 149 | |
| 150 blink::WebExternalTextureMailbox mailbox; | |
| 151 EXPECT_FALSE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | |
| 152 } | |
| 153 | |
| 154 TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) | 145 TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) |
| 155 { | 146 { |
| 156 blink::WebExternalTextureMailbox mailbox; | 147 blink::WebExternalTextureMailbox mailbox; |
| 157 | 148 |
| 158 IntSize initialSize(initialWidth, initialHeight); | 149 IntSize initialSize(initialWidth, initialHeight); |
| 159 IntSize alternateSize(initialWidth, alternateHeight); | 150 IntSize alternateSize(initialWidth, alternateHeight); |
| 160 | 151 |
| 161 // Produce one mailbox at size 100x100. | 152 // Produce one mailbox at size 100x100. |
| 162 m_drawingBuffer->markContentsChanged(); | 153 m_drawingBuffer->markContentsChanged(); |
| 163 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 154 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); | 229 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); |
| 239 EXPECT_EQ(TextureMailboxWrapper(mailbox3), TextureMailboxWrapper(recycledMai
lbox)); | 230 EXPECT_EQ(TextureMailboxWrapper(mailbox3), TextureMailboxWrapper(recycledMai
lbox)); |
| 240 | 231 |
| 241 // The third recycled mailbox must be 1. | 232 // The third recycled mailbox must be 1. |
| 242 m_drawingBuffer->markContentsChanged(); | 233 m_drawingBuffer->markContentsChanged(); |
| 243 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); | 234 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); |
| 244 EXPECT_EQ(TextureMailboxWrapper(mailbox1), TextureMailboxWrapper(recycledMai
lbox)); | 235 EXPECT_EQ(TextureMailboxWrapper(mailbox1), TextureMailboxWrapper(recycledMai
lbox)); |
| 245 } | 236 } |
| 246 | 237 |
| 247 } // namespace | 238 } // namespace |
| OLD | NEW |