OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 group().texture_manager()->GetTexture(client_texture_id_); | 2310 group().texture_manager()->GetTexture(client_texture_id_); |
2311 ASSERT_TRUE(texture_ref != NULL); | 2311 ASSERT_TRUE(texture_ref != NULL); |
2312 Texture* texture = texture_ref->texture(); | 2312 Texture* texture = texture_ref->texture(); |
2313 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 2313 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
2314 | 2314 |
2315 const int32 kImageId = 1; | 2315 const int32 kImageId = 1; |
2316 scoped_refptr<MockGLImage> image(new MockGLImage); | 2316 scoped_refptr<MockGLImage> image(new MockGLImage); |
2317 GetImageManager()->AddImage(image.get(), kImageId); | 2317 GetImageManager()->AddImage(image.get(), kImageId); |
2318 | 2318 |
2319 // Bind image to texture. | 2319 // Bind image to texture. |
2320 EXPECT_CALL(*image, BindTexImage(GL_TEXTURE_2D)) | 2320 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) |
2321 .Times(1) | 2321 .Times(1) |
2322 .WillOnce(Return(true)) | 2322 .WillOnce(Return(true)) |
2323 .RetiresOnSaturation(); | 2323 .RetiresOnSaturation(); |
2324 EXPECT_CALL(*image, GetSize()) | 2324 EXPECT_CALL(*image.get(), GetSize()) |
2325 .Times(1) | 2325 .Times(1) |
2326 .WillOnce(Return(gfx::Size(1, 1))) | 2326 .WillOnce(Return(gfx::Size(1, 1))) |
2327 .RetiresOnSaturation(); | 2327 .RetiresOnSaturation(); |
2328 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 2328 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
2329 EXPECT_CALL(*gl_, GetError()) | 2329 EXPECT_CALL(*gl_, GetError()) |
2330 .WillOnce(Return(GL_NO_ERROR)) | 2330 .WillOnce(Return(GL_NO_ERROR)) |
2331 .WillOnce(Return(GL_NO_ERROR)) | 2331 .WillOnce(Return(GL_NO_ERROR)) |
2332 .RetiresOnSaturation(); | 2332 .RetiresOnSaturation(); |
2333 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | 2333 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
2334 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); | 2334 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); |
2335 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | 2335 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
2336 | 2336 |
2337 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | 2337 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
2338 SetupExpectationsForApplyingDefaultDirtyState(); | 2338 SetupExpectationsForApplyingDefaultDirtyState(); |
2339 | 2339 |
2340 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 2340 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
2341 EXPECT_CALL(*gl_, GetError()) | 2341 EXPECT_CALL(*gl_, GetError()) |
2342 .WillOnce(Return(GL_NO_ERROR)) | 2342 .WillOnce(Return(GL_NO_ERROR)) |
2343 .WillOnce(Return(GL_NO_ERROR)) | 2343 .WillOnce(Return(GL_NO_ERROR)) |
2344 .WillOnce(Return(GL_NO_ERROR)) | 2344 .WillOnce(Return(GL_NO_ERROR)) |
2345 .WillOnce(Return(GL_NO_ERROR)) | 2345 .WillOnce(Return(GL_NO_ERROR)) |
2346 .RetiresOnSaturation(); | 2346 .RetiresOnSaturation(); |
2347 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(3).RetiresOnSaturation(); | 2347 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(3).RetiresOnSaturation(); |
2348 EXPECT_CALL(*image, WillUseTexImage()).Times(1).RetiresOnSaturation(); | 2348 EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation(); |
2349 EXPECT_CALL(*image, DidUseTexImage()).Times(1).RetiresOnSaturation(); | 2349 EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation(); |
2350 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 2350 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
2351 .Times(1) | 2351 .Times(1) |
2352 .RetiresOnSaturation(); | 2352 .RetiresOnSaturation(); |
2353 DrawArrays cmd; | 2353 DrawArrays cmd; |
2354 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 2354 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
2355 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2355 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2356 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2356 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2357 | 2357 |
2358 DoBindFramebuffer( | 2358 DoBindFramebuffer( |
2359 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 2359 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
2360 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 2360 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
2361 EXPECT_CALL(*gl_, GetError()) | 2361 EXPECT_CALL(*gl_, GetError()) |
2362 .WillOnce(Return(GL_NO_ERROR)) | 2362 .WillOnce(Return(GL_NO_ERROR)) |
2363 .WillOnce(Return(GL_NO_ERROR)) | 2363 .WillOnce(Return(GL_NO_ERROR)) |
2364 .RetiresOnSaturation(); | 2364 .RetiresOnSaturation(); |
2365 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); | 2365 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
2366 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | 2366 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
2367 .Times(2) | 2367 .Times(2) |
2368 .RetiresOnSaturation(); | 2368 .RetiresOnSaturation(); |
2369 // Image will be 'in use' as long as bound to a framebuffer. | 2369 // Image will be 'in use' as long as bound to a framebuffer. |
2370 EXPECT_CALL(*image, WillUseTexImage()).Times(1).RetiresOnSaturation(); | 2370 EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation(); |
2371 EXPECT_CALL(*gl_, | 2371 EXPECT_CALL(*gl_, |
2372 FramebufferTexture2DEXT(GL_FRAMEBUFFER, | 2372 FramebufferTexture2DEXT(GL_FRAMEBUFFER, |
2373 GL_COLOR_ATTACHMENT0, | 2373 GL_COLOR_ATTACHMENT0, |
2374 GL_TEXTURE_2D, | 2374 GL_TEXTURE_2D, |
2375 kServiceTextureId, | 2375 kServiceTextureId, |
2376 0)) | 2376 0)) |
2377 .Times(1) | 2377 .Times(1) |
2378 .RetiresOnSaturation(); | 2378 .RetiresOnSaturation(); |
2379 EXPECT_CALL(*gl_, GetError()) | 2379 EXPECT_CALL(*gl_, GetError()) |
2380 .WillOnce(Return(GL_NO_ERROR)) | 2380 .WillOnce(Return(GL_NO_ERROR)) |
(...skipping 17 matching lines...) Expand all Loading... |
2398 GL_COLOR_ATTACHMENT0, | 2398 GL_COLOR_ATTACHMENT0, |
2399 GL_RENDERBUFFER, | 2399 GL_RENDERBUFFER, |
2400 kServiceRenderbufferId)) | 2400 kServiceRenderbufferId)) |
2401 .Times(1) | 2401 .Times(1) |
2402 .RetiresOnSaturation(); | 2402 .RetiresOnSaturation(); |
2403 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); | 2403 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
2404 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | 2404 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
2405 .Times(2) | 2405 .Times(2) |
2406 .RetiresOnSaturation(); | 2406 .RetiresOnSaturation(); |
2407 // Image should no longer be 'in use' after being unbound from framebuffer. | 2407 // Image should no longer be 'in use' after being unbound from framebuffer. |
2408 EXPECT_CALL(*image, DidUseTexImage()).Times(1).RetiresOnSaturation(); | 2408 EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation(); |
2409 EXPECT_CALL(*gl_, GetError()) | 2409 EXPECT_CALL(*gl_, GetError()) |
2410 .WillOnce(Return(GL_NO_ERROR)) | 2410 .WillOnce(Return(GL_NO_ERROR)) |
2411 .WillOnce(Return(GL_NO_ERROR)) | 2411 .WillOnce(Return(GL_NO_ERROR)) |
2412 .RetiresOnSaturation(); | 2412 .RetiresOnSaturation(); |
2413 FramebufferRenderbuffer fbrb_cmd; | 2413 FramebufferRenderbuffer fbrb_cmd; |
2414 fbrb_cmd.Init(GL_FRAMEBUFFER, | 2414 fbrb_cmd.Init(GL_FRAMEBUFFER, |
2415 GL_COLOR_ATTACHMENT0, | 2415 GL_COLOR_ATTACHMENT0, |
2416 GL_RENDERBUFFER, | 2416 GL_RENDERBUFFER, |
2417 client_renderbuffer_id_); | 2417 client_renderbuffer_id_); |
2418 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | 2418 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); |
(...skipping 18 matching lines...) Expand all Loading... |
2437 0, | 2437 0, |
2438 GL_RGBA, | 2438 GL_RGBA, |
2439 0, | 2439 0, |
2440 0, | 2440 0, |
2441 1, | 2441 1, |
2442 0, | 2442 0, |
2443 GL_RGBA, | 2443 GL_RGBA, |
2444 GL_UNSIGNED_BYTE, | 2444 GL_UNSIGNED_BYTE, |
2445 true); | 2445 true); |
2446 group().texture_manager()->SetLevelImage( | 2446 group().texture_manager()->SetLevelImage( |
2447 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image); | 2447 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image.get()); |
2448 | 2448 |
2449 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | 2449 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
2450 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2450 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2451 | 2451 |
2452 SetupSamplerExternalProgram(); | 2452 SetupSamplerExternalProgram(); |
2453 SetupIndexBuffer(); | 2453 SetupIndexBuffer(); |
2454 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); | 2454 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); |
2455 SetupExpectationsForApplyingDefaultDirtyState(); | 2455 SetupExpectationsForApplyingDefaultDirtyState(); |
2456 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); | 2456 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); |
2457 | 2457 |
2458 InSequence s; | 2458 InSequence s; |
2459 EXPECT_CALL(*gl_, GetError()) | 2459 EXPECT_CALL(*gl_, GetError()) |
2460 .WillOnce(Return(GL_NO_ERROR)) | 2460 .WillOnce(Return(GL_NO_ERROR)) |
2461 .RetiresOnSaturation(); | 2461 .RetiresOnSaturation(); |
2462 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); | 2462 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
2463 EXPECT_CALL(*image, WillUseTexImage()).Times(1).RetiresOnSaturation(); | 2463 EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation(); |
2464 EXPECT_CALL(*gl_, GetError()) | 2464 EXPECT_CALL(*gl_, GetError()) |
2465 .WillOnce(Return(GL_NO_ERROR)) | 2465 .WillOnce(Return(GL_NO_ERROR)) |
2466 .RetiresOnSaturation(); | 2466 .RetiresOnSaturation(); |
2467 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(1); | 2467 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(1); |
2468 EXPECT_CALL(*gl_, GetError()) | 2468 EXPECT_CALL(*gl_, GetError()) |
2469 .WillOnce(Return(GL_NO_ERROR)) | 2469 .WillOnce(Return(GL_NO_ERROR)) |
2470 .RetiresOnSaturation(); | 2470 .RetiresOnSaturation(); |
2471 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); | 2471 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
2472 EXPECT_CALL(*image, DidUseTexImage()).Times(1).RetiresOnSaturation(); | 2472 EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation(); |
2473 EXPECT_CALL(*gl_, GetError()) | 2473 EXPECT_CALL(*gl_, GetError()) |
2474 .WillOnce(Return(GL_NO_ERROR)) | 2474 .WillOnce(Return(GL_NO_ERROR)) |
2475 .RetiresOnSaturation(); | 2475 .RetiresOnSaturation(); |
2476 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); | 2476 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
2477 DrawElements cmd; | 2477 DrawElements cmd; |
2478 cmd.Init(GL_TRIANGLES, | 2478 cmd.Init(GL_TRIANGLES, |
2479 kValidIndexRangeCount, | 2479 kValidIndexRangeCount, |
2480 GL_UNSIGNED_SHORT, | 2480 GL_UNSIGNED_SHORT, |
2481 kValidIndexRangeStart * 2); | 2481 kValidIndexRangeStart * 2); |
2482 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2482 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 // TODO(gman): CompressedTexSubImage2DImmediate | 2832 // TODO(gman): CompressedTexSubImage2DImmediate |
2833 | 2833 |
2834 // TODO(gman): TexImage2D | 2834 // TODO(gman): TexImage2D |
2835 | 2835 |
2836 // TODO(gman): TexImage2DImmediate | 2836 // TODO(gman): TexImage2DImmediate |
2837 | 2837 |
2838 // TODO(gman): TexSubImage2DImmediate | 2838 // TODO(gman): TexSubImage2DImmediate |
2839 | 2839 |
2840 } // namespace gles2 | 2840 } // namespace gles2 |
2841 } // namespace gpu | 2841 } // namespace gpu |
OLD | NEW |