Chromium Code Reviews| 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 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1470 UpdateMipCleared(&info, info.width, info.height, | 1470 UpdateMipCleared(&info, info.width, info.height, |
| 1471 gfx::Rect(info.width, info.height)); | 1471 gfx::Rect(info.width, info.height)); |
| 1472 return true; | 1472 return true; |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 void Texture::SetLevelImageInternal(GLenum target, | 1475 void Texture::SetLevelImageInternal(GLenum target, |
| 1476 GLint level, | 1476 GLint level, |
| 1477 gl::GLImage* image, | 1477 gl::GLImage* image, |
| 1478 GLStreamTextureImage* stream_texture_image, | 1478 GLStreamTextureImage* stream_texture_image, |
| 1479 ImageState state) { | 1479 ImageState state) { |
| 1480 DCHECK(!stream_texture_image || stream_texture_image == image); | |
| 1480 DCHECK_GE(level, 0); | 1481 DCHECK_GE(level, 0); |
| 1481 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1482 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 1482 DCHECK_LT(static_cast<size_t>(face_index), | 1483 DCHECK_LT(static_cast<size_t>(face_index), |
| 1483 face_infos_.size()); | 1484 face_infos_.size()); |
| 1484 DCHECK_LT(static_cast<size_t>(level), | 1485 DCHECK_LT(static_cast<size_t>(level), |
| 1485 face_infos_[face_index].level_infos.size()); | 1486 face_infos_[face_index].level_infos.size()); |
| 1486 Texture::LevelInfo& info = | 1487 Texture::LevelInfo& info = |
| 1487 face_infos_[face_index].level_infos[level]; | 1488 face_infos_[face_index].level_infos[level]; |
| 1488 DCHECK_EQ(info.target, target); | 1489 DCHECK_EQ(info.target, target); |
| 1489 DCHECK_EQ(info.level, level); | 1490 DCHECK_EQ(info.level, level); |
| 1490 info.image = image; | 1491 |
| 1491 info.stream_texture_image = stream_texture_image; | 1492 if (info.image != image) { |
|
liberato (no reviews please)
2016/06/02 14:37:02
wow -- this was fragile before, and i just realize
|
liberato (no reviews please)
2016/06/02 14:37:02
please update the tests (texture_manager_unittest.
watk
2016/06/03 01:09:46
Done.
|
| 1493 info.image = image; | |
| 1494 info.stream_texture_image = stream_texture_image; | |
| 1495 // If |image| is different, then |stream_texture_image| must also be | |
| 1496 // different, so clear the stream texture service id because it's no longer | |
|
liberato (no reviews please)
2016/06/02 14:37:02
nit: the comment is a little misleading. we don't
watk
2016/06/03 01:09:46
Done.
| |
| 1497 // valid. | |
| 1498 SetStreamTextureServiceId(0); | |
| 1499 } | |
| 1492 info.image_state = state; | 1500 info.image_state = state; |
| 1493 | 1501 |
| 1494 UpdateCanRenderCondition(); | 1502 UpdateCanRenderCondition(); |
| 1495 UpdateHasImages(); | 1503 UpdateHasImages(); |
| 1496 UpdateEmulatingRGB(); | 1504 UpdateEmulatingRGB(); |
| 1497 } | 1505 } |
| 1498 | 1506 |
| 1499 void Texture::SetLevelImage(GLenum target, | 1507 void Texture::SetLevelImage(GLenum target, |
| 1500 GLint level, | 1508 GLint level, |
| 1501 gl::GLImage* image, | 1509 gl::GLImage* image, |
| 1502 ImageState state) { | 1510 ImageState state) { |
| 1503 SetLevelImageInternal(target, level, image, nullptr, state); | 1511 SetLevelImageInternal(target, level, image, nullptr, state); |
| 1504 } | 1512 } |
| 1505 | 1513 |
| 1506 void Texture::SetLevelStreamTextureImage(GLenum target, | 1514 void Texture::SetLevelStreamTextureImage(GLenum target, |
| 1507 GLint level, | 1515 GLint level, |
| 1508 GLStreamTextureImage* image, | 1516 GLStreamTextureImage* image, |
| 1509 ImageState state) { | 1517 ImageState state, |
| 1518 GLuint service_id) { | |
| 1510 SetLevelImageInternal(target, level, image, image, state); | 1519 SetLevelImageInternal(target, level, image, image, state); |
| 1520 SetStreamTextureServiceId(service_id); | |
| 1511 } | 1521 } |
| 1512 | 1522 |
| 1513 const Texture::LevelInfo* Texture::GetLevelInfo(GLint target, | 1523 const Texture::LevelInfo* Texture::GetLevelInfo(GLint target, |
| 1514 GLint level) const { | 1524 GLint level) const { |
| 1515 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && | 1525 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && |
| 1516 target != GL_TEXTURE_RECTANGLE_ARB) { | 1526 target != GL_TEXTURE_RECTANGLE_ARB) { |
| 1517 return NULL; | 1527 return NULL; |
| 1518 } | 1528 } |
| 1519 | 1529 |
| 1520 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1530 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 feature_info->validators()-> | 1622 feature_info->validators()-> |
| 1613 texture_sized_color_renderable_internal_format.IsValid( | 1623 texture_sized_color_renderable_internal_format.IsValid( |
| 1614 internal_format)); | 1624 internal_format)); |
| 1615 bool depth_renderable = feature_info->validators()-> | 1625 bool depth_renderable = feature_info->validators()-> |
| 1616 texture_depth_renderable_internal_format.IsValid(internal_format); | 1626 texture_depth_renderable_internal_format.IsValid(internal_format); |
| 1617 bool stencil_renderable = feature_info->validators()-> | 1627 bool stencil_renderable = feature_info->validators()-> |
| 1618 texture_stencil_renderable_internal_format.IsValid(internal_format); | 1628 texture_stencil_renderable_internal_format.IsValid(internal_format); |
| 1619 return (color_renderable || depth_renderable || stencil_renderable); | 1629 return (color_renderable || depth_renderable || stencil_renderable); |
| 1620 } | 1630 } |
| 1621 | 1631 |
| 1622 void Texture::SetUnownedServiceId(GLuint service_id) { | 1632 void Texture::SetStreamTextureServiceId(GLuint service_id) { |
| 1623 GLuint new_service_id = service_id; | 1633 GLuint new_service_id = service_id; |
| 1624 | 1634 |
| 1625 // Take no action if this isn't an OES_EXTERNAL texture. | 1635 // Take no action if this isn't an OES_EXTERNAL texture. |
| 1626 if (target_ && target_ != GL_TEXTURE_EXTERNAL_OES) | 1636 if (target_ && target_ != GL_TEXTURE_EXTERNAL_OES) |
| 1627 return; | 1637 return; |
| 1628 | 1638 |
| 1629 if (!service_id) | 1639 if (!service_id) |
| 1630 new_service_id = owned_service_id_; | 1640 new_service_id = owned_service_id_; |
| 1631 | 1641 |
| 1632 if (service_id_ != new_service_id) { | 1642 if (service_id_ != new_service_id) { |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2093 gl::GLImage* image, | 2103 gl::GLImage* image, |
| 2094 Texture::ImageState state) { | 2104 Texture::ImageState state) { |
| 2095 DCHECK(ref); | 2105 DCHECK(ref); |
| 2096 ref->texture()->SetLevelImage(target, level, image, state); | 2106 ref->texture()->SetLevelImage(target, level, image, state); |
| 2097 } | 2107 } |
| 2098 | 2108 |
| 2099 void TextureManager::SetLevelStreamTextureImage(TextureRef* ref, | 2109 void TextureManager::SetLevelStreamTextureImage(TextureRef* ref, |
| 2100 GLenum target, | 2110 GLenum target, |
| 2101 GLint level, | 2111 GLint level, |
| 2102 GLStreamTextureImage* image, | 2112 GLStreamTextureImage* image, |
| 2103 Texture::ImageState state) { | 2113 Texture::ImageState state, |
| 2114 GLuint service_id) { | |
| 2104 DCHECK(ref); | 2115 DCHECK(ref); |
| 2105 ref->texture()->SetLevelStreamTextureImage(target, level, image, state); | 2116 ref->texture()->SetLevelStreamTextureImage(target, level, image, state, |
| 2117 service_id); | |
| 2106 } | 2118 } |
| 2107 | 2119 |
| 2108 size_t TextureManager::GetSignatureSize() const { | 2120 size_t TextureManager::GetSignatureSize() const { |
| 2109 return sizeof(TextureTag) + sizeof(TextureSignature); | 2121 return sizeof(TextureTag) + sizeof(TextureSignature); |
| 2110 } | 2122 } |
| 2111 | 2123 |
| 2112 void TextureManager::AddToSignature( | 2124 void TextureManager::AddToSignature( |
| 2113 TextureRef* ref, | 2125 TextureRef* ref, |
| 2114 GLenum target, | 2126 GLenum target, |
| 2115 GLint level, | 2127 GLint level, |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3309 uint32_t TextureManager::GetServiceIdGeneration() const { | 3321 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3310 return current_service_id_generation_; | 3322 return current_service_id_generation_; |
| 3311 } | 3323 } |
| 3312 | 3324 |
| 3313 void TextureManager::IncrementServiceIdGeneration() { | 3325 void TextureManager::IncrementServiceIdGeneration() { |
| 3314 current_service_id_generation_++; | 3326 current_service_id_generation_++; |
| 3315 } | 3327 } |
| 3316 | 3328 |
| 3317 } // namespace gles2 | 3329 } // namespace gles2 |
| 3318 } // namespace gpu | 3330 } // namespace gpu |
| OLD | NEW |