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

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

Issue 10543125: gpu: Add support for GLX_EXT_texture_from_pixmap extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove .gitmodules change. Created 8 years, 5 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 | Annotate | Revision Log
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 #include "base/bits.h" 6 #include "base/bits.h"
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/service/feature_info.h" 9 #include "gpu/command_buffer/service/feature_info.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { 217 for (size_t ii = 0; ii < level_infos_.size(); ++ii) {
218 const LevelInfo& info = level_infos_[ii][0]; 218 const LevelInfo& info = level_infos_[ii][0];
219 if ((info.target == 0) || 219 if ((info.target == 0) ||
220 (info.width != first.width) || 220 (info.width != first.width) ||
221 (info.height != first.height) || 221 (info.height != first.height) ||
222 (info.depth != 1) || 222 (info.depth != 1) ||
223 (info.format != first.format) || 223 (info.format != first.format) ||
224 (info.internal_format != first.internal_format) || 224 (info.internal_format != first.internal_format) ||
225 (info.type != first.type) || 225 (info.type != first.type) ||
226 feature_info->validators()->compressed_texture_format.IsValid( 226 feature_info->validators()->compressed_texture_format.IsValid(
227 info.internal_format)) { 227 info.internal_format) ||
228 info.image) {
228 return false; 229 return false;
229 } 230 }
230 } 231 }
231 return true; 232 return true;
232 } 233 }
233 234
234 void TextureManager::TextureInfo::SetLevelCleared(GLenum target, GLint level) { 235 void TextureManager::TextureInfo::SetLevelCleared(GLenum target, GLint level) {
235 DCHECK_GE(level, 0); 236 DCHECK_GE(level, 0);
236 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)), 237 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)),
237 level_infos_.size()); 238 level_infos_.size());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 level_infos_[GLTargetToFaceIndex(target)][level]; 293 level_infos_[GLTargetToFaceIndex(target)][level];
293 info.target = target; 294 info.target = target;
294 info.level = level; 295 info.level = level;
295 info.internal_format = internal_format; 296 info.internal_format = internal_format;
296 info.width = width; 297 info.width = width;
297 info.height = height; 298 info.height = height;
298 info.depth = depth; 299 info.depth = depth;
299 info.border = border; 300 info.border = border;
300 info.format = format; 301 info.format = format;
301 info.type = type; 302 info.type = type;
303 info.image = 0;
302 304
303 estimated_size_ -= info.estimated_size; 305 estimated_size_ -= info.estimated_size;
304 GLES2Util::ComputeImageDataSizes( 306 GLES2Util::ComputeImageDataSizes(
305 width, height, format, type, 4, &info.estimated_size, NULL, NULL); 307 width, height, format, type, 4, &info.estimated_size, NULL, NULL);
306 estimated_size_ += info.estimated_size; 308 estimated_size_ += info.estimated_size;
307 309
308 if (!info.cleared) { 310 if (!info.cleared) {
309 DCHECK_NE(0, num_uncleared_mips_); 311 DCHECK_NE(0, num_uncleared_mips_);
310 --num_uncleared_mips_; 312 --num_uncleared_mips_;
311 } 313 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // needed to be able to call GL correctly. 583 // needed to be able to call GL correctly.
582 info.cleared = decoder->ClearLevel( 584 info.cleared = decoder->ClearLevel(
583 service_id_, target_, info.target, info.level, info.format, info.type, 585 service_id_, target_, info.target, info.level, info.format, info.type,
584 info.width, info.height, immutable_); 586 info.width, info.height, immutable_);
585 if (!info.cleared) { 587 if (!info.cleared) {
586 ++num_uncleared_mips_; 588 ++num_uncleared_mips_;
587 } 589 }
588 return info.cleared; 590 return info.cleared;
589 } 591 }
590 592
593 void TextureManager::TextureInfo::SetLevelImage(
594 const FeatureInfo* feature_info,
595 GLenum target,
596 GLint level,
597 scoped_refptr<gfx::GLImage> image) {
598 DCHECK_GE(level, 0);
apatrick_chromium 2012/10/11 23:09:57 Should these range checks be stronger than DCHECKs
reveman 2012/10/12 03:29:11 I think it should be consistent with SetLevelInfo.
599 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)),
600 level_infos_.size());
601 DCHECK_LT(static_cast<size_t>(level),
602 level_infos_[GLTargetToFaceIndex(target)].size());
603 TextureInfo::LevelInfo& info =
604 level_infos_[GLTargetToFaceIndex(target)][level];
605 DCHECK_EQ(info.target, target);
606 DCHECK_EQ(info.level, level);
607 info.image = image;
608 }
609
610 scoped_refptr<gfx::GLImage> TextureManager::TextureInfo::GetLevelImage(
611 GLint face, GLint level) const {
612 size_t face_index = GLTargetToFaceIndex(face);
613 if (level >= 0 && face_index < level_infos_.size() &&
614 static_cast<size_t>(level) < level_infos_[face_index].size()) {
615 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(face)][level];
616 if (info.target != 0) {
617 return info.image;
618 }
619 }
620 return 0;
621 }
622
591 TextureManager::TextureManager( 623 TextureManager::TextureManager(
592 FeatureInfo* feature_info, 624 FeatureInfo* feature_info,
593 GLint max_texture_size, 625 GLint max_texture_size,
594 GLint max_cube_map_texture_size) 626 GLint max_cube_map_texture_size)
595 : feature_info_(feature_info), 627 : feature_info_(feature_info),
596 max_texture_size_(max_texture_size), 628 max_texture_size_(max_texture_size),
597 max_cube_map_texture_size_(max_cube_map_texture_size), 629 max_cube_map_texture_size_(max_cube_map_texture_size),
598 max_levels_(ComputeMipMapCount(max_texture_size, 630 max_levels_(ComputeMipMapCount(max_texture_size,
599 max_texture_size, 631 max_texture_size,
600 max_texture_size)), 632 max_texture_size)),
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } 1072 }
1041 } 1073 }
1042 return false; 1074 return false;
1043 } 1075 }
1044 1076
1045 GLsizei TextureManager::ComputeMipMapCount( 1077 GLsizei TextureManager::ComputeMipMapCount(
1046 GLsizei width, GLsizei height, GLsizei depth) { 1078 GLsizei width, GLsizei height, GLsizei depth) {
1047 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); 1079 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth));
1048 } 1080 }
1049 1081
1082 void TextureManager::SetLevelImage(
1083 TextureManager::TextureInfo* info,
1084 GLenum target,
1085 GLint level,
1086 scoped_refptr<gfx::GLImage> image) {
1087 DCHECK(info);
1088 if (!info->CanRender(feature_info_)) {
1089 DCHECK_NE(0, num_unrenderable_textures_);
1090 --num_unrenderable_textures_;
1091 }
1092 if (!info->SafeToRenderFrom()) {
1093 DCHECK_NE(0, num_unsafe_textures_);
1094 --num_unsafe_textures_;
1095 }
1096 info->SetLevelImage(feature_info_, target, level, image);
1097 if (!info->CanRender(feature_info_)) {
1098 ++num_unrenderable_textures_;
1099 }
1100 if (!info->SafeToRenderFrom()) {
1101 ++num_unsafe_textures_;
1102 }
1103 }
1104
1050 } // namespace gles2 1105 } // namespace gles2
1051 } // namespace gpu 1106 } // namespace gpu
1052 1107
1053 1108
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698