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

Side by Side Diff: Source/platform/graphics/gpu/DrawingBufferTest.cpp

Issue 223223003: Re-land "WebGL: Transfer ownership of WebGraphicsContext3D to DrawingBuffer" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix errata on comment Created 6 years, 8 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
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698