Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/web/tests/DrawingBufferTest.cpp

Issue 163773007: WebGL: Transfer ownership of WebGraphicsContext3D from WebGLRenderingContext to DrawingBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@correct_webgl_destroy
Patch Set: rebase to upstream Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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)
Ken Russell (switch to Gerrit) 2014/02/27 22:49:09 Why was this test removed? Is this just a mistake
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698