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

Side by Side Diff: gpu/command_buffer/service/texture_manager_unittest.cc

Issue 331723003: gpu: Remove Create/DeleteImage IPC by adding an X11_PIXMAP_BUFFER GpuMemoryBuffer type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "gpu/command_buffer/service/error_state_mock.h" 10 #include "gpu/command_buffer/service/error_state_mock.h"
11 #include "gpu/command_buffer/service/feature_info.h" 11 #include "gpu/command_buffer/service/feature_info.h"
12 #include "gpu/command_buffer/service/framebuffer_manager.h" 12 #include "gpu/command_buffer/service/framebuffer_manager.h"
13 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" 13 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
14 #include "gpu/command_buffer/service/gpu_service_test.h" 14 #include "gpu/command_buffer/service/gpu_service_test.h"
15 #include "gpu/command_buffer/service/mailbox_manager.h" 15 #include "gpu/command_buffer/service/mailbox_manager.h"
16 #include "gpu/command_buffer/service/memory_tracking.h" 16 #include "gpu/command_buffer/service/memory_tracking.h"
17 #include "gpu/command_buffer/service/mocks.h" 17 #include "gpu/command_buffer/service/mocks.h"
18 #include "gpu/command_buffer/service/test_helper.h" 18 #include "gpu/command_buffer/service/test_helper.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gl/gl_image_stub.h"
20 #include "ui/gl/gl_mock.h" 21 #include "ui/gl/gl_mock.h"
21 22
22 using ::testing::AtLeast; 23 using ::testing::AtLeast;
23 using ::testing::Pointee; 24 using ::testing::Pointee;
24 using ::testing::Return; 25 using ::testing::Return;
25 using ::testing::SetArgumentPointee; 26 using ::testing::SetArgumentPointee;
26 using ::testing::StrictMock; 27 using ::testing::StrictMock;
27 using ::testing::_; 28 using ::testing::_;
28 29
29 namespace gpu { 30 namespace gpu {
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 2, 1628 2,
1628 2, 1629 2,
1629 1, 1630 1,
1630 0, 1631 0,
1631 GL_RGBA, 1632 GL_RGBA,
1632 GL_UNSIGNED_BYTE, 1633 GL_UNSIGNED_BYTE,
1633 true); 1634 true);
1634 Texture* texture = texture_ref_->texture(); 1635 Texture* texture = texture_ref_->texture();
1635 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1636 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1636 // Set image. 1637 // Set image.
1637 manager_->SetLevelImage(texture_ref_.get(), 1638 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
1638 GL_TEXTURE_2D, 1639 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get());
1639 1,
1640 gfx::GLImage::CreateGLImage(0).get());
1641 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1640 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1642 // Remove it. 1641 // Remove it.
1643 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, NULL); 1642 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, NULL);
1644 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1643 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1645 manager_->SetLevelImage(texture_ref_.get(), 1644 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get());
1646 GL_TEXTURE_2D,
1647 1,
1648 gfx::GLImage::CreateGLImage(0).get());
1649 // Image should be reset when SetLevelInfo is called. 1645 // Image should be reset when SetLevelInfo is called.
1650 manager_->SetLevelInfo(texture_ref_.get(), 1646 manager_->SetLevelInfo(texture_ref_.get(),
1651 GL_TEXTURE_2D, 1647 GL_TEXTURE_2D,
1652 1, 1648 1,
1653 GL_RGBA, 1649 GL_RGBA,
1654 2, 1650 2,
1655 2, 1651 2,
1656 1, 1652 1,
1657 0, 1653 0,
1658 GL_RGBA, 1654 GL_RGBA,
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 EXPECT_EQ(produced_texture, restored_texture->texture()); 2082 EXPECT_EQ(produced_texture, restored_texture->texture());
2087 EXPECT_EQ(level0, 2083 EXPECT_EQ(level0,
2088 GetLevelInfo(restored_texture.get(), GL_TEXTURE_EXTERNAL_OES, 0)); 2084 GetLevelInfo(restored_texture.get(), GL_TEXTURE_EXTERNAL_OES, 0));
2089 } 2085 }
2090 2086
2091 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) { 2087 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) {
2092 GLenum target = GetParam(); 2088 GLenum target = GetParam();
2093 manager_->SetTarget(texture_ref_.get(), target); 2089 manager_->SetTarget(texture_ref_.get(), target);
2094 Texture* texture = texture_ref_->texture(); 2090 Texture* texture = texture_ref_->texture();
2095 EXPECT_EQ(static_cast<GLenum>(target), texture->target()); 2091 EXPECT_EQ(static_cast<GLenum>(target), texture->target());
2096 scoped_refptr<gfx::GLImage> image(gfx::GLImage::CreateGLImage(0)); 2092 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
2097 manager_->SetLevelInfo(texture_ref_.get(), 2093 manager_->SetLevelInfo(texture_ref_.get(),
2098 target, 2094 target,
2099 0, 2095 0,
2100 GL_RGBA, 2096 GL_RGBA,
2101 0, 2097 0,
2102 0, 2098 0,
2103 1, 2099 1,
2104 0, 2100 0,
2105 GL_RGBA, 2101 GL_RGBA,
2106 GL_UNSIGNED_BYTE, 2102 GL_UNSIGNED_BYTE,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 2, 2463 2,
2468 1, 2464 1,
2469 0, 2465 0,
2470 GL_RGBA, 2466 GL_RGBA,
2471 GL_UNSIGNED_BYTE, 2467 GL_UNSIGNED_BYTE,
2472 true); 2468 true);
2473 EXPECT_FALSE(ref1->texture()->HasImages()); 2469 EXPECT_FALSE(ref1->texture()->HasImages());
2474 EXPECT_FALSE(ref2->texture()->HasImages()); 2470 EXPECT_FALSE(ref2->texture()->HasImages());
2475 EXPECT_FALSE(texture_manager1_->HaveImages()); 2471 EXPECT_FALSE(texture_manager1_->HaveImages());
2476 EXPECT_FALSE(texture_manager2_->HaveImages()); 2472 EXPECT_FALSE(texture_manager2_->HaveImages());
2477 texture_manager1_->SetLevelImage(ref1.get(), 2473 scoped_refptr<gfx::GLImage> image1(new gfx::GLImageStub);
2478 GL_TEXTURE_2D, 2474 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image1.get());
2479 1,
2480 gfx::GLImage::CreateGLImage(0).get());
2481 EXPECT_TRUE(ref1->texture()->HasImages()); 2475 EXPECT_TRUE(ref1->texture()->HasImages());
2482 EXPECT_TRUE(ref2->texture()->HasImages()); 2476 EXPECT_TRUE(ref2->texture()->HasImages());
2483 EXPECT_TRUE(texture_manager1_->HaveImages()); 2477 EXPECT_TRUE(texture_manager1_->HaveImages());
2484 EXPECT_TRUE(texture_manager2_->HaveImages()); 2478 EXPECT_TRUE(texture_manager2_->HaveImages());
2485 texture_manager1_->SetLevelImage(ref1.get(), 2479 scoped_refptr<gfx::GLImage> image2(new gfx::GLImageStub);
2486 GL_TEXTURE_2D, 2480 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image2.get());
2487 1,
2488 gfx::GLImage::CreateGLImage(0).get());
2489 EXPECT_TRUE(ref1->texture()->HasImages()); 2481 EXPECT_TRUE(ref1->texture()->HasImages());
2490 EXPECT_TRUE(ref2->texture()->HasImages()); 2482 EXPECT_TRUE(ref2->texture()->HasImages());
2491 EXPECT_TRUE(texture_manager1_->HaveImages()); 2483 EXPECT_TRUE(texture_manager1_->HaveImages());
2492 EXPECT_TRUE(texture_manager2_->HaveImages()); 2484 EXPECT_TRUE(texture_manager2_->HaveImages());
2493 texture_manager1_->SetLevelInfo(ref1.get(), 2485 texture_manager1_->SetLevelInfo(ref1.get(),
2494 GL_TEXTURE_2D, 2486 GL_TEXTURE_2D,
2495 1, 2487 1,
2496 GL_RGBA, 2488 GL_RGBA,
2497 2, 2489 2,
2498 2, 2490 2,
2499 1, 2491 1,
2500 0, 2492 0,
2501 GL_RGBA, 2493 GL_RGBA,
2502 GL_UNSIGNED_BYTE, 2494 GL_UNSIGNED_BYTE,
2503 true); 2495 true);
2504 EXPECT_FALSE(ref1->texture()->HasImages()); 2496 EXPECT_FALSE(ref1->texture()->HasImages());
2505 EXPECT_FALSE(ref2->texture()->HasImages()); 2497 EXPECT_FALSE(ref2->texture()->HasImages());
2506 EXPECT_FALSE(texture_manager1_->HaveImages()); 2498 EXPECT_FALSE(texture_manager1_->HaveImages());
2507 EXPECT_FALSE(texture_manager1_->HaveImages()); 2499 EXPECT_FALSE(texture_manager1_->HaveImages());
2508 2500
2509 EXPECT_CALL(*gl_, DeleteTextures(1, _)) 2501 EXPECT_CALL(*gl_, DeleteTextures(1, _))
2510 .Times(1) 2502 .Times(1)
2511 .RetiresOnSaturation(); 2503 .RetiresOnSaturation();
2512 texture_manager1_->RemoveTexture(10); 2504 texture_manager1_->RemoveTexture(10);
2513 texture_manager2_->RemoveTexture(20); 2505 texture_manager2_->RemoveTexture(20);
2514 } 2506 }
2515 2507
2516 } // namespace gles2 2508 } // namespace gles2
2517 } // namespace gpu 2509 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.h ('k') | gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698