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