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

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

Issue 1925093002: Handle compressed textures allocated via TexStorage2D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed gpu_unittests after last refactor. Created 4 years, 7 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 (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 <algorithm> 10 #include <algorithm>
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 1417
1418 if (info.target == GL_TEXTURE_3D || info.target == GL_TEXTURE_2D_ARRAY) { 1418 if (info.target == GL_TEXTURE_3D || info.target == GL_TEXTURE_2D_ARRAY) {
1419 // For 3D textures, we always clear the entire texture. 1419 // For 3D textures, we always clear the entire texture.
1420 DCHECK(info.cleared_rect == gfx::Rect()); 1420 DCHECK(info.cleared_rect == gfx::Rect());
1421 bool cleared = decoder->ClearLevel3D( 1421 bool cleared = decoder->ClearLevel3D(
1422 this, info.target, info.level, info.format, info.type, 1422 this, info.target, info.level, info.format, info.type,
1423 info.width, info.height, info.depth); 1423 info.width, info.height, info.depth);
1424 if (!cleared) 1424 if (!cleared)
1425 return false; 1425 return false;
1426 } else { 1426 } else {
1427 // Clear all remaining sub regions. 1427 if (decoder->IsCompressedTextureFormat(info.internal_format)) {
1428 const int x[] = { 1428 // An uncleared level of a compressed texture can only occur when
1429 // allocating the texture with TexStorage2D. In this case the level
1430 // is cleared just before a call to CompressedTexSubImage2D, to avoid
1431 // having to clear a sub-rectangle of a compressed texture, which
1432 // would be problematic.
1433 DCHECK(IsImmutable());
1434 DCHECK(info.cleared_rect == gfx::Rect());
1435 bool cleared = decoder->ClearCompressedTextureLevel(
1436 this, info.target, info.level, info.internal_format,
1437 info.width, info.height);
1438 if (!cleared)
1439 return false;
1440 } else {
1441 // Clear all remaining sub regions.
1442 const int x[] = {
1429 0, info.cleared_rect.x(), info.cleared_rect.right(), info.width}; 1443 0, info.cleared_rect.x(), info.cleared_rect.right(), info.width};
1430 const int y[] = { 1444 const int y[] = {
1431 0, info.cleared_rect.y(), info.cleared_rect.bottom(), info.height}; 1445 0, info.cleared_rect.y(), info.cleared_rect.bottom(), info.height};
1432 1446
1433 for (size_t j = 0; j < 3; ++j) { 1447 for (size_t j = 0; j < 3; ++j) {
1434 for (size_t i = 0; i < 3; ++i) { 1448 for (size_t i = 0; i < 3; ++i) {
1435 // Center of nine patch is already cleared. 1449 // Center of nine patch is already cleared.
1436 if (j == 1 && i == 1) 1450 if (j == 1 && i == 1)
1437 continue; 1451 continue;
1438 1452
1439 gfx::Rect rect(x[i], y[j], x[i + 1] - x[i], y[j + 1] - y[j]); 1453 gfx::Rect rect(x[i], y[j], x[i + 1] - x[i], y[j + 1] - y[j]);
1440 if (rect.IsEmpty()) 1454 if (rect.IsEmpty())
1441 continue; 1455 continue;
1442 1456
1443 // NOTE: It seems kind of gross to call back into the decoder for this 1457 // NOTE: It seems kind of gross to call back into the decoder for this
1444 // but only the decoder knows all the state (like unpack_alignment_) 1458 // but only the decoder knows all the state (like unpack_alignment_)
1445 // that's needed to be able to call GL correctly. 1459 // that's needed to be able to call GL correctly.
1446 bool cleared = decoder->ClearLevel( 1460 bool cleared = decoder->ClearLevel(
1447 this, info.target, info.level, info.format, info.type, 1461 this, info.target, info.level, info.format, info.type,
1448 rect.x(), rect.y(), rect.width(), rect.height()); 1462 rect.x(), rect.y(), rect.width(), rect.height());
1449 if (!cleared) 1463 if (!cleared)
1450 return false; 1464 return false;
1465 }
1451 } 1466 }
1452 } 1467 }
1453 } 1468 }
1454 1469
1455 UpdateMipCleared(&info, info.width, info.height, 1470 UpdateMipCleared(&info, info.width, info.height,
1456 gfx::Rect(info.width, info.height)); 1471 gfx::Rect(info.width, info.height));
1457 return true; 1472 return true;
1458 } 1473 }
1459 1474
1460 void Texture::SetLevelImageInternal(GLenum target, 1475 void Texture::SetLevelImageInternal(GLenum target,
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
3172 uint32_t TextureManager::GetServiceIdGeneration() const { 3187 uint32_t TextureManager::GetServiceIdGeneration() const {
3173 return current_service_id_generation_; 3188 return current_service_id_generation_;
3174 } 3189 }
3175 3190
3176 void TextureManager::IncrementServiceIdGeneration() { 3191 void TextureManager::IncrementServiceIdGeneration() {
3177 current_service_id_generation_++; 3192 current_service_id_generation_++;
3178 } 3193 }
3179 3194
3180 } // namespace gles2 3195 } // namespace gles2
3181 } // namespace gpu 3196 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698