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

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

Issue 1154053002: gpu: Use a rectangle to keep track of the cleared area of each texture level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restore scissor state in GLES2DecoderImpl::ClearLevel and update GLES2DecoderManualInitTest.DrawCle… Created 5 years, 6 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
OLDNEW
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 "gpu/command_buffer/service/feature_info.h" 5 #include "gpu/command_buffer/service/feature_info.h"
6 #include "gpu/command_buffer/service/gpu_service_test.h" 6 #include "gpu/command_buffer/service/gpu_service_test.h"
7 #include "gpu/command_buffer/service/mailbox_manager_impl.h" 7 #include "gpu/command_buffer/service/mailbox_manager_impl.h"
8 #include "gpu/command_buffer/service/mailbox_manager_sync.h" 8 #include "gpu/command_buffer/service/mailbox_manager_sync.h"
9 #include "gpu/command_buffer/service/texture_manager.h" 9 #include "gpu/command_buffer/service/texture_manager.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 29 matching lines...) Expand all
40 void TearDown() override { GpuServiceTest::TearDown(); } 40 void TearDown() override { GpuServiceTest::TearDown(); }
41 41
42 Texture* CreateTexture() { 42 Texture* CreateTexture() {
43 return new Texture(1); 43 return new Texture(1);
44 } 44 }
45 45
46 void SetTarget(Texture* texture, GLenum target, GLuint max_level) { 46 void SetTarget(Texture* texture, GLenum target, GLuint max_level) {
47 texture->SetTarget(NULL, target, max_level); 47 texture->SetTarget(NULL, target, max_level);
48 } 48 }
49 49
50 void SetLevelInfo( 50 void SetLevelInfo(Texture* texture,
51 Texture* texture, 51 GLenum target,
52 GLenum target, 52 GLint level,
53 GLint level, 53 GLenum internal_format,
54 GLenum internal_format, 54 GLsizei width,
55 GLsizei width, 55 GLsizei height,
56 GLsizei height, 56 GLsizei depth,
57 GLsizei depth, 57 GLint border,
58 GLint border, 58 GLenum format,
59 GLenum format, 59 GLenum type,
60 GLenum type, 60 const gfx::Rect& cleared_rect) {
61 bool cleared) { 61 texture->SetLevelInfo(NULL, target, level, internal_format, width, height,
62 texture->SetLevelInfo(NULL, 62 depth, border, format, type, cleared_rect);
63 target,
64 level,
65 internal_format,
66 width,
67 height,
68 depth,
69 border,
70 format,
71 type,
72 cleared);
73 } 63 }
74 64
75 void SetLevelCleared(Texture* texture, 65 void SetLevelCleared(Texture* texture,
76 GLenum target, 66 GLenum target,
77 GLint level, 67 GLint level,
78 bool cleared) { 68 bool cleared) {
79 texture->SetLevelCleared(target, level, cleared); 69 texture->SetLevelCleared(target, level, cleared);
80 } 70 }
81 71
82 GLenum SetParameter(Texture* texture, GLenum pname, GLint param) { 72 GLenum SetParameter(Texture* texture, GLenum pname, GLint param) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 context_ = new gfx::GLContextStub(); 194 context_ = new gfx::GLContextStub();
205 surface_ = new gfx::GLSurfaceStub(); 195 surface_ = new gfx::GLSurfaceStub();
206 context_->MakeCurrent(surface_.get()); 196 context_->MakeCurrent(surface_.get());
207 } 197 }
208 198
209 Texture* DefineTexture() { 199 Texture* DefineTexture() {
210 Texture* texture = CreateTexture(); 200 Texture* texture = CreateTexture();
211 const GLsizei levels_needed = TextureManager::ComputeMipMapCount( 201 const GLsizei levels_needed = TextureManager::ComputeMipMapCount(
212 GL_TEXTURE_2D, kMaxTextureWidth, kMaxTextureHeight, kMaxTextureDepth); 202 GL_TEXTURE_2D, kMaxTextureWidth, kMaxTextureHeight, kMaxTextureDepth);
213 SetTarget(texture, GL_TEXTURE_2D, levels_needed); 203 SetTarget(texture, GL_TEXTURE_2D, levels_needed);
214 SetLevelInfo(texture, 204 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA,
215 GL_TEXTURE_2D, 205 GL_UNSIGNED_BYTE, gfx::Rect(1, 1));
216 0,
217 GL_RGBA,
218 1,
219 1,
220 1,
221 0,
222 GL_RGBA,
223 GL_UNSIGNED_BYTE,
224 true);
225 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 206 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
226 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 207 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
227 return texture; 208 return texture;
228 } 209 }
229 210
230 void SetupUpdateTexParamExpectations(GLuint texture_id, 211 void SetupUpdateTexParamExpectations(GLuint texture_id,
231 GLenum min, 212 GLenum min,
232 GLenum mag, 213 GLenum mag,
233 GLenum wrap_s, 214 GLenum wrap_s,
234 GLenum wrap_t) { 215 GLenum wrap_t) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 EXPECT_CALL(*gl_, GenTextures(1, _)) 326 EXPECT_CALL(*gl_, GenTextures(1, _))
346 .WillOnce(SetArgPointee<1>(kNewTextureId)); 327 .WillOnce(SetArgPointee<1>(kNewTextureId));
347 SetupUpdateTexParamExpectations( 328 SetupUpdateTexParamExpectations(
348 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 329 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
349 Texture* new_texture = manager2_->ConsumeTexture(name); 330 Texture* new_texture = manager2_->ConsumeTexture(name);
350 EXPECT_FALSE(new_texture == NULL); 331 EXPECT_FALSE(new_texture == NULL);
351 EXPECT_NE(texture, new_texture); 332 EXPECT_NE(texture, new_texture);
352 EXPECT_EQ(kNewTextureId, new_texture->service_id()); 333 EXPECT_EQ(kNewTextureId, new_texture->service_id());
353 334
354 // Resize original texture 335 // Resize original texture
355 SetLevelInfo(texture, 336 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 16, 32, 1, 0, GL_RGBA,
356 GL_TEXTURE_2D, 337 GL_UNSIGNED_BYTE, gfx::Rect(16, 32));
357 0,
358 GL_RGBA,
359 16,
360 32,
361 1,
362 0,
363 GL_RGBA,
364 GL_UNSIGNED_BYTE,
365 true);
366 // Should have been orphaned 338 // Should have been orphaned
367 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 339 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
368 340
369 // Synchronize again 341 // Synchronize again
370 manager_->PushTextureUpdates(0); 342 manager_->PushTextureUpdates(0);
371 SetupUpdateTexParamExpectations( 343 SetupUpdateTexParamExpectations(
372 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 344 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
373 manager2_->PullTextureUpdates(0); 345 manager2_->PullTextureUpdates(0);
374 GLsizei width, height; 346 GLsizei width, height;
375 new_texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr); 347 new_texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr);
376 EXPECT_EQ(16, width); 348 EXPECT_EQ(16, width);
377 EXPECT_EQ(32, height); 349 EXPECT_EQ(32, height);
378 350
379 // Should have gotten a new attachment 351 // Should have gotten a new attachment
380 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) != NULL); 352 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) != NULL);
381 // Resize original texture again.... 353 // Resize original texture again....
382 SetLevelInfo(texture, 354 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 1, 0, GL_RGBA,
383 GL_TEXTURE_2D, 355 GL_UNSIGNED_BYTE, gfx::Rect(64, 64));
384 0,
385 GL_RGBA,
386 64,
387 64,
388 1,
389 0,
390 GL_RGBA,
391 GL_UNSIGNED_BYTE,
392 true);
393 // ...and immediately delete the texture which should save the changes. 356 // ...and immediately delete the texture which should save the changes.
394 SetupUpdateTexParamExpectations( 357 SetupUpdateTexParamExpectations(
395 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 358 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
396 DestroyTexture(texture); 359 DestroyTexture(texture);
397 360
398 // Should be still around since there is a ref from manager2 361 // Should be still around since there is a ref from manager2
399 EXPECT_EQ(new_texture, manager2_->ConsumeTexture(name)); 362 EXPECT_EQ(new_texture, manager2_->ConsumeTexture(name));
400 363
401 // The last change to the texture should be visible without a sync point (i.e. 364 // The last change to the texture should be visible without a sync point (i.e.
402 // push). 365 // push).
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 SetupUpdateTexParamExpectations(kNewTextureId, texture->min_filter(), 580 SetupUpdateTexParamExpectations(kNewTextureId, texture->min_filter(),
618 texture->mag_filter(), texture->wrap_s(), 581 texture->mag_filter(), texture->wrap_s(),
619 texture->wrap_t()); 582 texture->wrap_t());
620 Texture* new_texture = manager2_->ConsumeTexture(name); 583 Texture* new_texture = manager2_->ConsumeTexture(name);
621 ASSERT_TRUE(new_texture); 584 ASSERT_TRUE(new_texture);
622 EXPECT_NE(texture, new_texture); 585 EXPECT_NE(texture, new_texture);
623 EXPECT_EQ(kNewTextureId, new_texture->service_id()); 586 EXPECT_EQ(kNewTextureId, new_texture->service_id());
624 EXPECT_FALSE(new_texture->IsDefined()); 587 EXPECT_FALSE(new_texture->IsDefined());
625 588
626 // Change cleared to false. 589 // Change cleared to false.
627 SetLevelInfo(texture, 590 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA,
628 GL_TEXTURE_2D, 591 GL_UNSIGNED_BYTE, gfx::Rect(1, 1));
629 0,
630 GL_RGBA,
631 1,
632 1,
633 1,
634 0,
635 GL_RGBA,
636 GL_UNSIGNED_BYTE,
637 true);
638 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 592 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
639 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 593 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
640 EXPECT_TRUE(texture->IsDefined()); 594 EXPECT_TRUE(texture->IsDefined());
641 595
642 // Synchronize 596 // Synchronize
643 manager_->PushTextureUpdates(0); 597 manager_->PushTextureUpdates(0);
644 SetupUpdateTexParamExpectations( 598 SetupUpdateTexParamExpectations(
645 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 599 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
646 manager2_->PullTextureUpdates(0); 600 manager2_->PullTextureUpdates(0);
647 601
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 DestroyTexture(texture2); 684 DestroyTexture(texture2);
731 DestroyTexture(new_texture); 685 DestroyTexture(new_texture);
732 } 686 }
733 687
734 // TODO: Texture::level_infos_[][].size() 688 // TODO: Texture::level_infos_[][].size()
735 689
736 // TODO: unsupported targets and formats 690 // TODO: unsupported targets and formats
737 691
738 } // namespace gles2 692 } // namespace gles2
739 } // namespace gpu 693 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698