OLD | NEW |
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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 if (info.target == 0 || | 1440 if (info.target == 0 || |
1441 info.cleared_rect == gfx::Rect(info.width, info.height) || | 1441 info.cleared_rect == gfx::Rect(info.width, info.height) || |
1442 info.width == 0 || info.height == 0 || info.depth == 0) { | 1442 info.width == 0 || info.height == 0 || info.depth == 0) { |
1443 return true; | 1443 return true; |
1444 } | 1444 } |
1445 | 1445 |
1446 if (info.target == GL_TEXTURE_3D || info.target == GL_TEXTURE_2D_ARRAY) { | 1446 if (info.target == GL_TEXTURE_3D || info.target == GL_TEXTURE_2D_ARRAY) { |
1447 // For 3D textures, we always clear the entire texture. | 1447 // For 3D textures, we always clear the entire texture. |
1448 DCHECK(info.cleared_rect == gfx::Rect()); | 1448 DCHECK(info.cleared_rect == gfx::Rect()); |
1449 bool cleared = decoder->ClearLevel3D( | 1449 bool cleared = decoder->ClearLevel3D( |
1450 this, info.target, info.level, info.format, info.type, | 1450 this, info.target, info.level, |
1451 info.width, info.height, info.depth); | 1451 TextureManager::AdjustTexFormat(decoder->GetFeatureInfo(), info.format), |
| 1452 info.type, info.width, info.height, info.depth); |
1452 if (!cleared) | 1453 if (!cleared) |
1453 return false; | 1454 return false; |
1454 } else { | 1455 } else { |
1455 if (decoder->IsCompressedTextureFormat(info.internal_format)) { | 1456 if (decoder->IsCompressedTextureFormat(info.internal_format)) { |
1456 // An uncleared level of a compressed texture can only occur when | 1457 // An uncleared level of a compressed texture can only occur when |
1457 // allocating the texture with TexStorage2D. In this case the level | 1458 // allocating the texture with TexStorage2D. In this case the level |
1458 // is cleared just before a call to CompressedTexSubImage2D, to avoid | 1459 // is cleared just before a call to CompressedTexSubImage2D, to avoid |
1459 // having to clear a sub-rectangle of a compressed texture, which | 1460 // having to clear a sub-rectangle of a compressed texture, which |
1460 // would be problematic. | 1461 // would be problematic. |
1461 DCHECK(IsImmutable()); | 1462 DCHECK(IsImmutable()); |
(...skipping 17 matching lines...) Expand all Loading... |
1479 continue; | 1480 continue; |
1480 | 1481 |
1481 gfx::Rect rect(x[i], y[j], x[i + 1] - x[i], y[j + 1] - y[j]); | 1482 gfx::Rect rect(x[i], y[j], x[i + 1] - x[i], y[j + 1] - y[j]); |
1482 if (rect.IsEmpty()) | 1483 if (rect.IsEmpty()) |
1483 continue; | 1484 continue; |
1484 | 1485 |
1485 // NOTE: It seems kind of gross to call back into the decoder for this | 1486 // NOTE: It seems kind of gross to call back into the decoder for this |
1486 // but only the decoder knows all the state (like unpack_alignment_) | 1487 // but only the decoder knows all the state (like unpack_alignment_) |
1487 // that's needed to be able to call GL correctly. | 1488 // that's needed to be able to call GL correctly. |
1488 bool cleared = decoder->ClearLevel( | 1489 bool cleared = decoder->ClearLevel( |
1489 this, info.target, info.level, info.format, info.type, | 1490 this, info.target, info.level, |
1490 rect.x(), rect.y(), rect.width(), rect.height()); | 1491 TextureManager::AdjustTexFormat(decoder->GetFeatureInfo(), |
| 1492 info.format), |
| 1493 info.type, rect.x(), rect.y(), rect.width(), rect.height()); |
1491 if (!cleared) | 1494 if (!cleared) |
1492 return false; | 1495 return false; |
1493 } | 1496 } |
1494 } | 1497 } |
1495 } | 1498 } |
1496 } | 1499 } |
1497 | 1500 |
1498 UpdateMipCleared(&info, info.width, info.height, | 1501 UpdateMipCleared(&info, info.width, info.height, |
1499 gfx::Rect(info.width, info.height)); | 1502 gfx::Rect(info.width, info.height)); |
1500 return true; | 1503 return true; |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3379 uint32_t TextureManager::GetServiceIdGeneration() const { | 3382 uint32_t TextureManager::GetServiceIdGeneration() const { |
3380 return current_service_id_generation_; | 3383 return current_service_id_generation_; |
3381 } | 3384 } |
3382 | 3385 |
3383 void TextureManager::IncrementServiceIdGeneration() { | 3386 void TextureManager::IncrementServiceIdGeneration() { |
3384 current_service_id_generation_++; | 3387 current_service_id_generation_++; |
3385 } | 3388 } |
3386 | 3389 |
3387 } // namespace gles2 | 3390 } // namespace gles2 |
3388 } // namespace gpu | 3391 } // namespace gpu |
OLD | NEW |