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

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

Issue 1559203003: Add GLStreamTextureImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed shared context check and removed matrix from copier. Created 4 years, 10 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>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bits.h" 14 #include "base/bits.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "base/trace_event/memory_dump_manager.h" 19 #include "base/trace_event/memory_dump_manager.h"
20 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 20 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
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/gl_stream_texture_image.h"
25 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 26 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
26 #include "gpu/command_buffer/service/mailbox_manager.h" 27 #include "gpu/command_buffer/service/mailbox_manager.h"
27 #include "gpu/command_buffer/service/memory_tracking.h" 28 #include "gpu/command_buffer/service/memory_tracking.h"
28 #include "ui/gl/gl_context.h" 29 #include "ui/gl/gl_context.h"
29 #include "ui/gl/gl_implementation.h" 30 #include "ui/gl/gl_implementation.h"
30 #include "ui/gl/gl_state_restorer.h" 31 #include "ui/gl/gl_state_restorer.h"
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 {
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(GLenum target,
1331 GLint level, 1332 GLint level,
1332 gl::GLImage* image, 1333 gl::GLImage* image,
1333 ImageState state) { 1334 GLStreamTextureImage* stream_texture_image,
1335 ImageState state) {
1334 DCHECK_GE(level, 0); 1336 DCHECK_GE(level, 0);
1335 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); 1337 size_t face_index = GLES2Util::GLTargetToFaceIndex(target);
1336 DCHECK_LT(static_cast<size_t>(face_index), 1338 DCHECK_LT(static_cast<size_t>(face_index),
1337 face_infos_.size()); 1339 face_infos_.size());
1338 DCHECK_LT(static_cast<size_t>(level), 1340 DCHECK_LT(static_cast<size_t>(level),
1339 face_infos_[face_index].level_infos.size()); 1341 face_infos_[face_index].level_infos.size());
1340 Texture::LevelInfo& info = 1342 Texture::LevelInfo& info =
1341 face_infos_[face_index].level_infos[level]; 1343 face_infos_[face_index].level_infos[level];
1342 DCHECK_EQ(info.target, target); 1344 DCHECK_EQ(info.target, target);
1343 DCHECK_EQ(info.level, level); 1345 DCHECK_EQ(info.level, level);
1344 info.image = image; 1346 info.image = image;
1347 info.stream_texture_image = stream_texture_image;
1345 info.image_state = state; 1348 info.image_state = state;
1346 1349
1347 UpdateCanRenderCondition(); 1350 UpdateCanRenderCondition();
1348 UpdateHasImages(); 1351 UpdateHasImages();
1349 } 1352 }
1350 1353
1351 gl::GLImage* Texture::GetLevelImage(GLint target, 1354 void Texture::SetLevelImage(GLenum target,
1352 GLint level, 1355 GLint level,
1353 ImageState* state) const { 1356 gl::GLImage* image,
1357 ImageState state) {
1358 SetLevelImageInternal(target, level, image, nullptr, state);
1359 }
1360
1361 void Texture::SetLevelStreamTextureImage(GLenum target,
1362 GLint level,
1363 GLStreamTextureImage* image,
1364 ImageState state) {
1365 SetLevelImageInternal(target, level, image, image, state);
1366 }
1367
1368 const Texture::LevelInfo* Texture::GetLevelInfo(GLint target,
1369 GLint level) const {
1354 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && 1370 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES &&
1355 target != GL_TEXTURE_RECTANGLE_ARB) { 1371 target != GL_TEXTURE_RECTANGLE_ARB) {
1356 return NULL; 1372 return NULL;
1357 } 1373 }
1358 1374
1359 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); 1375 size_t face_index = GLES2Util::GLTargetToFaceIndex(target);
1360 if (level >= 0 && face_index < face_infos_.size() && 1376 if (level >= 0 && face_index < face_infos_.size() &&
1361 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { 1377 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) {
1362 const LevelInfo& info = face_infos_[face_index].level_infos[level]; 1378 const LevelInfo& info = face_infos_[face_index].level_infos[level];
1363 if (info.target != 0) { 1379 if (info.target != 0)
1364 if (state) 1380 return &info;
1365 *state = info.image_state;
1366 return info.image.get();
1367 }
1368 } 1381 }
1369 return NULL; 1382 return NULL;
1370 } 1383 }
1371 1384
1385 gl::GLImage* Texture::GetLevelImage(GLint target,
1386 GLint level,
1387 ImageState* state) const {
1388 const LevelInfo* info = GetLevelInfo(target, level);
1389 if (!info)
1390 return nullptr;
1391
1392 if (state)
1393 *state = info->image_state;
1394 return info->image.get();
1395 }
1396
1372 gl::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { 1397 gl::GLImage* Texture::GetLevelImage(GLint target, GLint level) const {
1373 return GetLevelImage(target, level, nullptr); 1398 return GetLevelImage(target, level, nullptr);
1374 } 1399 }
1375 1400
1401 GLStreamTextureImage* Texture::GetLevelStreamTextureImage(GLint target,
1402 GLint level) const {
1403 const LevelInfo* info = GetLevelInfo(target, level);
1404 if (!info)
1405 return nullptr;
1406
1407 return info->stream_texture_image.get();
1408 }
1409
1376 void Texture::DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, 1410 void Texture::DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd,
1377 uint64_t client_tracing_id, 1411 uint64_t client_tracing_id,
1378 const std::string& dump_name) const { 1412 const std::string& dump_name) const {
1379 for (uint32_t face_index = 0; face_index < face_infos_.size(); ++face_index) { 1413 for (uint32_t face_index = 0; face_index < face_infos_.size(); ++face_index) {
1380 const auto& level_infos = face_infos_[face_index].level_infos; 1414 const auto& level_infos = face_infos_[face_index].level_infos;
1381 for (uint32_t level_index = 0; level_index < level_infos.size(); 1415 for (uint32_t level_index = 0; level_index < level_infos.size();
1382 ++level_index) { 1416 ++level_index) {
1383 // Skip levels with no size. Textures will have empty levels for all 1417 // Skip levels with no size. Textures will have empty levels for all
1384 // potential mip levels which are not in use. 1418 // potential mip levels which are not in use.
1385 if (!level_infos[level_index].estimated_size) 1419 if (!level_infos[level_index].estimated_size)
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 1895
1862 void TextureManager::SetLevelImage(TextureRef* ref, 1896 void TextureManager::SetLevelImage(TextureRef* ref,
1863 GLenum target, 1897 GLenum target,
1864 GLint level, 1898 GLint level,
1865 gl::GLImage* image, 1899 gl::GLImage* image,
1866 Texture::ImageState state) { 1900 Texture::ImageState state) {
1867 DCHECK(ref); 1901 DCHECK(ref);
1868 ref->texture()->SetLevelImage(target, level, image, state); 1902 ref->texture()->SetLevelImage(target, level, image, state);
1869 } 1903 }
1870 1904
1905 void TextureManager::SetLevelStreamTextureImage(TextureRef* ref,
1906 GLenum target,
1907 GLint level,
1908 GLStreamTextureImage* image,
1909 Texture::ImageState state) {
1910 DCHECK(ref);
1911 ref->texture()->SetLevelStreamTextureImage(target, level, image, state);
1912 }
1913
1871 size_t TextureManager::GetSignatureSize() const { 1914 size_t TextureManager::GetSignatureSize() const {
1872 return sizeof(TextureTag) + sizeof(TextureSignature); 1915 return sizeof(TextureTag) + sizeof(TextureSignature);
1873 } 1916 }
1874 1917
1875 void TextureManager::AddToSignature( 1918 void TextureManager::AddToSignature(
1876 TextureRef* ref, 1919 TextureRef* ref,
1877 GLenum target, 1920 GLenum target,
1878 GLint level, 1921 GLint level,
1879 std::string* signature) const { 1922 std::string* signature) const {
1880 ref->texture()->AddToSignature(feature_info_.get(), target, level, signature); 1923 ref->texture()->AddToSignature(feature_info_.get(), target, level, signature);
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 uint32_t TextureManager::GetServiceIdGeneration() const { 2791 uint32_t TextureManager::GetServiceIdGeneration() const {
2749 return current_service_id_generation_; 2792 return current_service_id_generation_;
2750 } 2793 }
2751 2794
2752 void TextureManager::IncrementServiceIdGeneration() { 2795 void TextureManager::IncrementServiceIdGeneration() {
2753 current_service_id_generation_++; 2796 current_service_id_generation_++;
2754 } 2797 }
2755 2798
2756 } // namespace gles2 2799 } // namespace gles2
2757 } // namespace gpu 2800 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698