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

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

Issue 1559203003: Add GLStreamTextureImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/GL_EXPORT/GPU_EXPORT for windows Created 4 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
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | mojo/gpu/mojo_gles2_impl_autogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "gpu/command_buffer/service/error_state_mock.h" 15 #include "gpu/command_buffer/service/error_state_mock.h"
16 #include "gpu/command_buffer/service/feature_info.h" 16 #include "gpu/command_buffer/service/feature_info.h"
17 #include "gpu/command_buffer/service/framebuffer_manager.h" 17 #include "gpu/command_buffer/service/framebuffer_manager.h"
18 #include "gpu/command_buffer/service/gl_stream_texture_image.h"
18 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" 19 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
19 #include "gpu/command_buffer/service/gpu_service_test.h" 20 #include "gpu/command_buffer/service/gpu_service_test.h"
20 #include "gpu/command_buffer/service/mailbox_manager.h" 21 #include "gpu/command_buffer/service/mailbox_manager.h"
21 #include "gpu/command_buffer/service/memory_tracking.h" 22 #include "gpu/command_buffer/service/memory_tracking.h"
22 #include "gpu/command_buffer/service/mocks.h" 23 #include "gpu/command_buffer/service/mocks.h"
23 #include "gpu/command_buffer/service/test_helper.h" 24 #include "gpu/command_buffer/service/test_helper.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/gl/gl_image_stub.h" 26 #include "ui/gl/gl_image_stub.h"
26 #include "ui/gl/gl_mock.h" 27 #include "ui/gl/gl_mock.h"
27 #include "ui/gl/gl_switches.h" 28 #include "ui/gl/gl_switches.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const GLint TextureManagerTest::kMaxCubeMapTextureSize; 133 const GLint TextureManagerTest::kMaxCubeMapTextureSize;
133 const GLint TextureManagerTest::kMaxRectangleTextureSize; 134 const GLint TextureManagerTest::kMaxRectangleTextureSize;
134 const GLint TextureManagerTest::kMaxExternalTextureSize; 135 const GLint TextureManagerTest::kMaxExternalTextureSize;
135 const GLint TextureManagerTest::kMax3DTextureSize; 136 const GLint TextureManagerTest::kMax3DTextureSize;
136 const GLint TextureManagerTest::kMax2dLevels; 137 const GLint TextureManagerTest::kMax2dLevels;
137 const GLint TextureManagerTest::kMaxCubeMapLevels; 138 const GLint TextureManagerTest::kMaxCubeMapLevels;
138 const GLint TextureManagerTest::kMaxExternalLevels; 139 const GLint TextureManagerTest::kMaxExternalLevels;
139 const GLint TextureManagerTest::kMax3dLevels; 140 const GLint TextureManagerTest::kMax3dLevels;
140 #endif 141 #endif
141 142
143 class GLStreamTextureImageStub : public GLStreamTextureImage {
144 public:
145 GLStreamTextureImageStub() {}
146
147 // Overridden from GLImage:
148 void Destroy(bool have_context) override {}
149 gfx::Size GetSize() override { return gfx::Size(); }
150 unsigned GetInternalFormat() override { return 0; }
151 bool BindTexImage(unsigned target) override { return false; }
152 void ReleaseTexImage(unsigned target) override {}
153 bool CopyTexImage(unsigned target) override { return false; }
154 bool CopyTexSubImage(unsigned target,
155 const gfx::Point& offset,
156 const gfx::Rect& rect) override {
157 return false;
158 }
159 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
160 int z_order,
161 gfx::OverlayTransform transform,
162 const gfx::Rect& bounds_rect,
163 const gfx::RectF& crop_rect) override {
164 return false;
165 }
166 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
167 uint64_t process_tracing_id,
168 const std::string& dump_name) override {}
169 void GetTextureMatrix(float matrix[16]) override {}
170
171 protected:
172 ~GLStreamTextureImageStub() override {}
173 };
174
142 TEST_F(TextureManagerTest, Basic) { 175 TEST_F(TextureManagerTest, Basic) {
143 const GLuint kClient1Id = 1; 176 const GLuint kClient1Id = 1;
144 const GLuint kService1Id = 11; 177 const GLuint kService1Id = 11;
145 const GLuint kClient2Id = 2; 178 const GLuint kClient2Id = 2;
146 EXPECT_FALSE(manager_->HaveUnsafeTextures()); 179 EXPECT_FALSE(manager_->HaveUnsafeTextures());
147 EXPECT_FALSE(manager_->HaveUnclearedMips()); 180 EXPECT_FALSE(manager_->HaveUnclearedMips());
148 // Check we can create texture. 181 // Check we can create texture.
149 manager_->CreateTexture(kClient1Id, kService1Id); 182 manager_->CreateTexture(kClient1Id, kService1Id);
150 // Check texture got created. 183 // Check texture got created.
151 scoped_refptr<TextureRef> texture = manager_->GetTexture(kClient1Id); 184 scoped_refptr<TextureRef> texture = manager_->GetTexture(kClient1Id);
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); 1534 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
1502 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 1535 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1,
1503 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); 1536 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2));
1504 Texture* texture = texture_ref_->texture(); 1537 Texture* texture = texture_ref_->texture();
1505 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1538 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1506 // Set image. 1539 // Set image.
1507 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); 1540 scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
1508 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get(), 1541 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get(),
1509 Texture::BOUND); 1542 Texture::BOUND);
1510 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1543 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1544 EXPECT_TRUE(texture->GetLevelStreamTextureImage(GL_TEXTURE_2D, 1) == NULL);
1511 // Remove it. 1545 // Remove it.
1512 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, nullptr, 1546 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, nullptr,
1513 Texture::UNBOUND); 1547 Texture::UNBOUND);
1514 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1548 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1515 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get(), 1549 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get(),
1516 Texture::UNBOUND); 1550 Texture::UNBOUND);
1517 // Image should be reset when SetLevelInfo is called. 1551 // Image should be reset when SetLevelInfo is called.
1518 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 1552 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1,
1519 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); 1553 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2));
1520 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1554 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
1555 EXPECT_TRUE(texture->GetLevelStreamTextureImage(GL_TEXTURE_2D, 1) == NULL);
1556 }
1557
1558 TEST_F(TextureTest, GetLevelStreamTextureImage) {
1559 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
1560 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES, 0,
1561 GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1562 gfx::Rect(2, 2));
1563 Texture* texture = texture_ref_->texture();
1564
1565 // Set image.
1566 scoped_refptr<GLStreamTextureImage> image(new GLStreamTextureImageStub);
1567 manager_->SetLevelStreamTextureImage(texture_ref_.get(),
1568 GL_TEXTURE_EXTERNAL_OES, 0, image.get(),
1569 Texture::BOUND);
1570 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0) == NULL);
1571 EXPECT_FALSE(
1572 texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 0) == NULL);
1573 // Replace it as a normal image.
1574 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES, 0,
1575 image.get(), Texture::BOUND);
1576 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0) == NULL);
1577 EXPECT_TRUE(texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 0) ==
1578 NULL);
1579
1580 // Image should be reset when SetLevelInfo is called.
1581 manager_->SetLevelStreamTextureImage(texture_ref_.get(),
1582 GL_TEXTURE_EXTERNAL_OES, 0, image.get(),
1583 Texture::UNBOUND);
1584 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES, 0,
1585 GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1586 gfx::Rect(2, 2));
1587 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0) == NULL);
1588 EXPECT_TRUE(texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 0) ==
1589 NULL);
1521 } 1590 }
1522 1591
1523 namespace { 1592 namespace {
1524 1593
1525 bool InSet(std::set<std::string>* string_set, const std::string& str) { 1594 bool InSet(std::set<std::string>* string_set, const std::string& str) {
1526 std::pair<std::set<std::string>::iterator, bool> result = 1595 std::pair<std::set<std::string>::iterator, bool> result =
1527 string_set->insert(str); 1596 string_set->insert(str);
1528 return !result.second; 1597 return !result.second;
1529 } 1598 }
1530 1599
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); 2511 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F);
2443 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); 2512 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8);
2444 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 2513 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
2445 GL_DEPTH32F_STENCIL8); 2514 GL_DEPTH32F_STENCIL8);
2446 2515
2447 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8); 2516 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8);
2448 } 2517 }
2449 2518
2450 } // namespace gles2 2519 } // namespace gles2
2451 } // namespace gpu 2520 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | mojo/gpu/mojo_gles2_impl_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698