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