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 10 matching lines...) Expand all Loading... | |
21 #include "gpu/command_buffer/service/context_state.h" | 21 #include "gpu/command_buffer/service/context_state.h" |
22 #include "gpu/command_buffer/service/error_state.h" | 22 #include "gpu/command_buffer/service/error_state.h" |
23 #include "gpu/command_buffer/service/feature_info.h" | 23 #include "gpu/command_buffer/service/feature_info.h" |
24 #include "gpu/command_buffer/service/framebuffer_manager.h" | 24 #include "gpu/command_buffer/service/framebuffer_manager.h" |
25 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 25 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
26 #include "gpu/command_buffer/service/mailbox_manager.h" | 26 #include "gpu/command_buffer/service/mailbox_manager.h" |
27 #include "gpu/command_buffer/service/memory_tracking.h" | 27 #include "gpu/command_buffer/service/memory_tracking.h" |
28 #include "ui/gl/gl_context.h" | 28 #include "ui/gl/gl_context.h" |
29 #include "ui/gl/gl_implementation.h" | 29 #include "ui/gl/gl_implementation.h" |
30 #include "ui/gl/gl_state_restorer.h" | 30 #include "ui/gl/gl_state_restorer.h" |
31 #include "ui/gl/gl_stream_texture_image.h" | |
reveman
2016/02/18 20:20:57
Did you forget to add this file? Btw, can this cla
liberato (no reviews please)
2016/02/19 18:39:56
Done.
| |
31 #include "ui/gl/gl_version_info.h" | 32 #include "ui/gl/gl_version_info.h" |
32 #include "ui/gl/trace_util.h" | 33 #include "ui/gl/trace_util.h" |
33 | 34 |
34 namespace gpu { | 35 namespace gpu { |
35 namespace gles2 { | 36 namespace gles2 { |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 // This should contain everything to uniquely identify a Texture. | 40 // This should contain everything to uniquely identify a Texture. |
40 const char TextureTag[] = "|Texture|"; | 41 const char TextureTag[] = "|Texture|"; |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1320 if (!cleared) | 1321 if (!cleared) |
1321 return false; | 1322 return false; |
1322 } | 1323 } |
1323 } | 1324 } |
1324 | 1325 |
1325 UpdateMipCleared(&info, info.width, info.height, | 1326 UpdateMipCleared(&info, info.width, info.height, |
1326 gfx::Rect(info.width, info.height)); | 1327 gfx::Rect(info.width, info.height)); |
1327 return true; | 1328 return true; |
1328 } | 1329 } |
1329 | 1330 |
1330 void Texture::SetLevelImage(GLenum target, | 1331 void Texture::SetLevelImageInternal( |
1331 GLint level, | 1332 GLenum target, |
1332 gl::GLImage* image, | 1333 GLint level, |
1333 ImageState state) { | 1334 gl::GLImage* image, |
1335 gl::GLStreamTextureImage* stream_texture_image, | |
1336 ImageState state) { | |
1334 DCHECK_GE(level, 0); | 1337 DCHECK_GE(level, 0); |
1335 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1338 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1336 DCHECK_LT(static_cast<size_t>(face_index), | 1339 DCHECK_LT(static_cast<size_t>(face_index), |
1337 face_infos_.size()); | 1340 face_infos_.size()); |
1338 DCHECK_LT(static_cast<size_t>(level), | 1341 DCHECK_LT(static_cast<size_t>(level), |
1339 face_infos_[face_index].level_infos.size()); | 1342 face_infos_[face_index].level_infos.size()); |
1340 Texture::LevelInfo& info = | 1343 Texture::LevelInfo& info = |
1341 face_infos_[face_index].level_infos[level]; | 1344 face_infos_[face_index].level_infos[level]; |
1342 DCHECK_EQ(info.target, target); | 1345 DCHECK_EQ(info.target, target); |
1343 DCHECK_EQ(info.level, level); | 1346 DCHECK_EQ(info.level, level); |
1344 info.image = image; | 1347 info.image = image; |
1348 info.stream_texture_image = stream_texture_image; | |
1345 info.image_state = state; | 1349 info.image_state = state; |
1346 | 1350 |
1347 UpdateCanRenderCondition(); | 1351 UpdateCanRenderCondition(); |
1348 UpdateHasImages(); | 1352 UpdateHasImages(); |
1349 } | 1353 } |
1350 | 1354 |
1351 gl::GLImage* Texture::GetLevelImage(GLint target, | 1355 void Texture::SetLevelImage(GLenum target, |
1352 GLint level, | 1356 GLint level, |
1353 ImageState* state) const { | 1357 gl::GLImage* image, |
1358 ImageState state) { | |
1359 SetLevelImageInternal(target, level, image, nullptr, state); | |
1360 } | |
1361 | |
1362 void Texture::SetLevelStreamTextureImage(GLenum target, | |
1363 GLint level, | |
1364 gl::GLStreamTextureImage* image, | |
1365 ImageState state) { | |
1366 SetLevelImageInternal(target, level, image, image, state); | |
1367 } | |
1368 | |
1369 const Texture::LevelInfo* Texture::GetLevelInfo(GLint target, | |
1370 GLint level) const { | |
1354 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && | 1371 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && |
1355 target != GL_TEXTURE_RECTANGLE_ARB) { | 1372 target != GL_TEXTURE_RECTANGLE_ARB) { |
1356 return NULL; | 1373 return NULL; |
1357 } | 1374 } |
1358 | 1375 |
1359 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1376 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1360 if (level >= 0 && face_index < face_infos_.size() && | 1377 if (level >= 0 && face_index < face_infos_.size() && |
1361 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { | 1378 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { |
1362 const LevelInfo& info = face_infos_[face_index].level_infos[level]; | 1379 const LevelInfo& info = face_infos_[face_index].level_infos[level]; |
1363 if (info.target != 0) { | 1380 if (info.target != 0) |
1364 if (state) | 1381 return &info; |
1365 *state = info.image_state; | |
1366 return info.image.get(); | |
1367 } | |
1368 } | 1382 } |
1369 return NULL; | 1383 return NULL; |
1370 } | 1384 } |
1371 | 1385 |
1386 gl::GLImage* Texture::GetLevelImage(GLint target, | |
1387 GLint level, | |
1388 ImageState* state) const { | |
1389 const LevelInfo* info = GetLevelInfo(target, level); | |
1390 if (!info) | |
1391 return NULL; | |
reveman
2016/02/18 20:20:56
nit: nullptr
liberato (no reviews please)
2016/02/19 18:39:56
Done.
| |
1392 | |
1393 if (state) | |
1394 *state = info->image_state; | |
1395 return info->image.get(); | |
1396 } | |
1397 | |
1372 gl::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { | 1398 gl::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { |
1373 return GetLevelImage(target, level, nullptr); | 1399 return GetLevelImage(target, level, nullptr); |
1374 } | 1400 } |
1375 | 1401 |
1402 gl::GLStreamTextureImage* Texture::GetLevelStreamTextureImage( | |
1403 GLint target, | |
1404 GLint level) const { | |
1405 const LevelInfo* info = GetLevelInfo(target, level); | |
1406 if (!info) | |
1407 return NULL; | |
reveman
2016/02/18 20:20:57
nit: nullptr
liberato (no reviews please)
2016/02/19 18:39:56
Done.
| |
1408 | |
1409 return info->stream_texture_image.get(); | |
1410 } | |
1411 | |
1376 void Texture::DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, | 1412 void Texture::DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, |
1377 uint64_t client_tracing_id, | 1413 uint64_t client_tracing_id, |
1378 const std::string& dump_name) const { | 1414 const std::string& dump_name) const { |
1379 for (uint32_t face_index = 0; face_index < face_infos_.size(); ++face_index) { | 1415 for (uint32_t face_index = 0; face_index < face_infos_.size(); ++face_index) { |
1380 const auto& level_infos = face_infos_[face_index].level_infos; | 1416 const auto& level_infos = face_infos_[face_index].level_infos; |
1381 for (uint32_t level_index = 0; level_index < level_infos.size(); | 1417 for (uint32_t level_index = 0; level_index < level_infos.size(); |
1382 ++level_index) { | 1418 ++level_index) { |
1383 // Skip levels with no size. Textures will have empty levels for all | 1419 // Skip levels with no size. Textures will have empty levels for all |
1384 // potential mip levels which are not in use. | 1420 // potential mip levels which are not in use. |
1385 if (!level_infos[level_index].estimated_size) | 1421 if (!level_infos[level_index].estimated_size) |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1861 | 1897 |
1862 void TextureManager::SetLevelImage(TextureRef* ref, | 1898 void TextureManager::SetLevelImage(TextureRef* ref, |
1863 GLenum target, | 1899 GLenum target, |
1864 GLint level, | 1900 GLint level, |
1865 gl::GLImage* image, | 1901 gl::GLImage* image, |
1866 Texture::ImageState state) { | 1902 Texture::ImageState state) { |
1867 DCHECK(ref); | 1903 DCHECK(ref); |
1868 ref->texture()->SetLevelImage(target, level, image, state); | 1904 ref->texture()->SetLevelImage(target, level, image, state); |
1869 } | 1905 } |
1870 | 1906 |
1907 void TextureManager::SetLevelStreamTextureImage(TextureRef* ref, | |
1908 GLenum target, | |
1909 GLint level, | |
1910 gl::GLStreamTextureImage* image, | |
1911 Texture::ImageState state) { | |
1912 DCHECK(ref); | |
1913 ref->texture()->SetLevelStreamTextureImage(target, level, image, state); | |
1914 } | |
1915 | |
1871 size_t TextureManager::GetSignatureSize() const { | 1916 size_t TextureManager::GetSignatureSize() const { |
1872 return sizeof(TextureTag) + sizeof(TextureSignature); | 1917 return sizeof(TextureTag) + sizeof(TextureSignature); |
1873 } | 1918 } |
1874 | 1919 |
1875 void TextureManager::AddToSignature( | 1920 void TextureManager::AddToSignature( |
1876 TextureRef* ref, | 1921 TextureRef* ref, |
1877 GLenum target, | 1922 GLenum target, |
1878 GLint level, | 1923 GLint level, |
1879 std::string* signature) const { | 1924 std::string* signature) const { |
1880 ref->texture()->AddToSignature(feature_info_.get(), target, level, signature); | 1925 ref->texture()->AddToSignature(feature_info_.get(), target, level, signature); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2748 uint32_t TextureManager::GetServiceIdGeneration() const { | 2793 uint32_t TextureManager::GetServiceIdGeneration() const { |
2749 return current_service_id_generation_; | 2794 return current_service_id_generation_; |
2750 } | 2795 } |
2751 | 2796 |
2752 void TextureManager::IncrementServiceIdGeneration() { | 2797 void TextureManager::IncrementServiceIdGeneration() { |
2753 current_service_id_generation_++; | 2798 current_service_id_generation_++; |
2754 } | 2799 } |
2755 | 2800 |
2756 } // namespace gles2 | 2801 } // namespace gles2 |
2757 } // namespace gpu | 2802 } // namespace gpu |
OLD | NEW |