OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/test/layer_tree_pixel_test.h" | 5 #include "cc/test/layer_tree_pixel_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "cc/base/switches.h" | 9 #include "cc/base/switches.h" |
10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 | 217 |
218 scoped_ptr<SkBitmap> LayerTreePixelTest::CopyTextureMailboxToBitmap( | 218 scoped_ptr<SkBitmap> LayerTreePixelTest::CopyTextureMailboxToBitmap( |
219 gfx::Size size, | 219 gfx::Size size, |
220 const TextureMailbox& texture_mailbox) { | 220 const TextureMailbox& texture_mailbox) { |
221 DCHECK(texture_mailbox.IsTexture()); | 221 DCHECK(texture_mailbox.IsTexture()); |
222 if (!texture_mailbox.IsTexture()) | 222 if (!texture_mailbox.IsTexture()) |
223 return scoped_ptr<SkBitmap>(); | 223 return scoped_ptr<SkBitmap>(); |
224 | 224 |
225 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 225 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
226 scoped_ptr<WebKit::WebGraphicsContext3D> context3d( | 226 scoped_ptr<blink::WebGraphicsContext3D> context3d( |
227 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( | 227 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
228 WebKit::WebGraphicsContext3D::Attributes())); | 228 blink::WebGraphicsContext3D::Attributes())); |
229 | 229 |
230 EXPECT_TRUE(context3d->makeContextCurrent()); | 230 EXPECT_TRUE(context3d->makeContextCurrent()); |
231 | 231 |
232 if (texture_mailbox.sync_point()) | 232 if (texture_mailbox.sync_point()) |
233 context3d->waitSyncPoint(texture_mailbox.sync_point()); | 233 context3d->waitSyncPoint(texture_mailbox.sync_point()); |
234 | 234 |
235 unsigned texture_id = context3d->createTexture(); | 235 unsigned texture_id = context3d->createTexture(); |
236 context3d->bindTexture(GL_TEXTURE_2D, texture_id); | 236 context3d->bindTexture(GL_TEXTURE_2D, texture_id); |
237 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 237 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
238 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 238 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 out_pixels[dest_y + x + SK_G32_SHIFT/8] = pixels.get()[src_y + x + 1]; | 286 out_pixels[dest_y + x + SK_G32_SHIFT/8] = pixels.get()[src_y + x + 1]; |
287 out_pixels[dest_y + x + SK_B32_SHIFT/8] = pixels.get()[src_y + x + 2]; | 287 out_pixels[dest_y + x + SK_B32_SHIFT/8] = pixels.get()[src_y + x + 2]; |
288 out_pixels[dest_y + x + SK_A32_SHIFT/8] = pixels.get()[src_y + x + 3]; | 288 out_pixels[dest_y + x + SK_A32_SHIFT/8] = pixels.get()[src_y + x + 3]; |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 return bitmap.Pass(); | 292 return bitmap.Pass(); |
293 } | 293 } |
294 | 294 |
295 void LayerTreePixelTest::ReleaseTextureMailbox( | 295 void LayerTreePixelTest::ReleaseTextureMailbox( |
296 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 296 scoped_ptr<blink::WebGraphicsContext3D> context3d, |
297 uint32 texture, | 297 uint32 texture, |
298 uint32 sync_point, | 298 uint32 sync_point, |
299 bool lost_resource) { | 299 bool lost_resource) { |
300 if (sync_point) | 300 if (sync_point) |
301 context3d->waitSyncPoint(sync_point); | 301 context3d->waitSyncPoint(sync_point); |
302 context3d->deleteTexture(texture); | 302 context3d->deleteTexture(texture); |
303 pending_texture_mailbox_callbacks_--; | 303 pending_texture_mailbox_callbacks_--; |
304 TryEndTest(); | 304 TryEndTest(); |
305 } | 305 } |
306 | 306 |
307 void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture( | 307 void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture( |
308 const SkBitmap& bitmap, | 308 const SkBitmap& bitmap, |
309 TextureMailbox* texture_mailbox, | 309 TextureMailbox* texture_mailbox, |
310 scoped_ptr<SingleReleaseCallback>* release_callback) { | 310 scoped_ptr<SingleReleaseCallback>* release_callback) { |
311 DCHECK_GT(bitmap.width(), 0); | 311 DCHECK_GT(bitmap.width(), 0); |
312 DCHECK_GT(bitmap.height(), 0); | 312 DCHECK_GT(bitmap.height(), 0); |
313 | 313 |
314 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); | 314 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); |
315 | 315 |
316 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 316 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
317 scoped_ptr<WebKit::WebGraphicsContext3D> context3d( | 317 scoped_ptr<blink::WebGraphicsContext3D> context3d( |
318 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( | 318 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
319 WebKit::WebGraphicsContext3D::Attributes())); | 319 blink::WebGraphicsContext3D::Attributes())); |
320 | 320 |
321 EXPECT_TRUE(context3d->makeContextCurrent()); | 321 EXPECT_TRUE(context3d->makeContextCurrent()); |
322 | 322 |
323 unsigned texture_id = context3d->createTexture(); | 323 unsigned texture_id = context3d->createTexture(); |
324 context3d->bindTexture(GL_TEXTURE_2D, texture_id); | 324 context3d->bindTexture(GL_TEXTURE_2D, texture_id); |
325 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 325 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
326 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 326 context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
327 context3d->texParameteri( | 327 context3d->texParameteri( |
328 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 328 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
329 context3d->texParameteri( | 329 context3d->texParameteri( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 371 |
372 *texture_mailbox = TextureMailbox(mailbox, sync_point); | 372 *texture_mailbox = TextureMailbox(mailbox, sync_point); |
373 *release_callback = SingleReleaseCallback::Create( | 373 *release_callback = SingleReleaseCallback::Create( |
374 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, | 374 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, |
375 base::Unretained(this), | 375 base::Unretained(this), |
376 base::Passed(&context3d), | 376 base::Passed(&context3d), |
377 texture_id)); | 377 texture_id)); |
378 } | 378 } |
379 | 379 |
380 } // namespace cc | 380 } // namespace cc |
OLD | NEW |