summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer')
-rw-r--r--gpu/command_buffer/service/context_group.cc14
-rw-r--r--gpu/command_buffer/service/context_group.h6
-rw-r--r--gpu/command_buffer/service/feature_info.h9
-rw-r--r--gpu/command_buffer/service/feature_info_unittest.cc378
-rw-r--r--gpu/command_buffer/service/framebuffer_manager_unittest.cc48
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc85
-rw-r--r--gpu/command_buffer/service/texture_manager.cc119
-rw-r--r--gpu/command_buffer/service/texture_manager.h63
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc459
9 files changed, 604 insertions, 577 deletions
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index 3d580bd..bfe311b 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -29,7 +29,8 @@ ContextGroup::ContextGroup(bool bind_generates_resource)
max_vertex_texture_image_units_(0u),
max_fragment_uniform_vectors_(0u),
max_varying_vectors_(0u),
- max_vertex_uniform_vectors_(0u) {
+ max_vertex_uniform_vectors_(0u),
+ feature_info_(new FeatureInfo()) {
id_namespaces_[id_namespaces::kBuffers].reset(new IdAllocator);
id_namespaces_[id_namespaces::kFramebuffers].reset(new IdAllocator);
id_namespaces_[id_namespaces::kProgramsAndShaders].reset(
@@ -55,7 +56,7 @@ bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features,
return true;
}
- if (!feature_info_.Initialize(disallowed_features, allowed_features)) {
+ if (!feature_info_->Initialize(disallowed_features, allowed_features)) {
LOG(ERROR) << "ContextGroup::Initialize failed because FeatureInfo "
<< "initialization failed.";
return false;
@@ -64,7 +65,7 @@ bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features,
GLint max_renderbuffer_size = 0;
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &max_renderbuffer_size);
GLint max_samples = 0;
- if (feature_info_.feature_flags().chromium_framebuffer_multisample) {
+ if (feature_info_->feature_flags().chromium_framebuffer_multisample) {
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
}
@@ -113,7 +114,8 @@ bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features,
}
#endif
- texture_manager_.reset(new TextureManager(max_texture_size,
+ texture_manager_.reset(new TextureManager(feature_info_.get(),
+ max_texture_size,
max_cube_map_texture_size));
GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_image_units_);
@@ -135,7 +137,7 @@ bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features,
max_vertex_uniform_vectors_ /= 4;
}
- if (!texture_manager_->Initialize(feature_info())) {
+ if (!texture_manager_->Initialize()) {
LOG(ERROR) << "Context::Group::Initialize failed because texture manager "
<< "failed to initialize.";
return false;
diff --git a/gpu/command_buffer/service/context_group.h b/gpu/command_buffer/service/context_group.h
index 48fac44..9a9943b 100644
--- a/gpu/command_buffer/service/context_group.h
+++ b/gpu/command_buffer/service/context_group.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -81,7 +81,7 @@ class ContextGroup : public base::RefCounted<ContextGroup> {
}
FeatureInfo* feature_info() {
- return &feature_info_;
+ return feature_info_.get();
}
BufferManager* buffer_manager() const {
@@ -138,7 +138,7 @@ class ContextGroup : public base::RefCounted<ContextGroup> {
linked_ptr<IdAllocatorInterface>
id_namespaces_[id_namespaces::kNumIdNamespaces];
- FeatureInfo feature_info_;
+ FeatureInfo::Ref feature_info_;
DISALLOW_COPY_AND_ASSIGN(ContextGroup);
};
diff --git a/gpu/command_buffer/service/feature_info.h b/gpu/command_buffer/service/feature_info.h
index c71ab9b..8e47f5e 100644
--- a/gpu/command_buffer/service/feature_info.h
+++ b/gpu/command_buffer/service/feature_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,15 +6,18 @@
#define GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_
#include <string>
+#include "base/memory/ref_counted.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
namespace gpu {
namespace gles2 {
-// FeatureInfo records the features that are available for a particular context.
-class FeatureInfo {
+// FeatureInfo records the features that are available for a ContextGroup.
+class FeatureInfo : public base::RefCounted<FeatureInfo> {
public:
+ typedef scoped_refptr<FeatureInfo> Ref;
+
struct FeatureFlags {
FeatureFlags()
: chromium_framebuffer_multisample(false),
diff --git a/gpu/command_buffer/service/feature_info_unittest.cc b/gpu/command_buffer/service/feature_info_unittest.cc
index 57bc592..12839e6 100644
--- a/gpu/command_buffer/service/feature_info_unittest.cc
+++ b/gpu/command_buffer/service/feature_info_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -40,408 +40,410 @@ class FeatureInfoTest : public testing::Test {
virtual void SetUp() {
gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
::gfx::GLInterface::SetGLInterface(gl_.get());
+ info_ = new FeatureInfo();
}
virtual void TearDown() {
+ info_ = NULL;
::gfx::GLInterface::SetGLInterface(NULL);
gl_.reset();
}
scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
- FeatureInfo info_;
+ FeatureInfo::Ref info_;
};
TEST_F(FeatureInfoTest, Basic) {
// Test it starts off uninitialized.
- EXPECT_FALSE(info_.feature_flags().chromium_framebuffer_multisample);
- EXPECT_FALSE(info_.feature_flags().oes_standard_derivatives);
- EXPECT_FALSE(info_.feature_flags().npot_ok);
- EXPECT_FALSE(info_.feature_flags().enable_texture_float_linear);
- EXPECT_FALSE(info_.feature_flags().enable_texture_half_float_linear);
- EXPECT_FALSE(info_.feature_flags().chromium_webglsl);
- EXPECT_FALSE(info_.feature_flags().oes_egl_image_external);
- EXPECT_FALSE(info_.feature_flags().chromium_stream_texture);
+ EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
+ EXPECT_FALSE(info_->feature_flags().oes_standard_derivatives);
+ EXPECT_FALSE(info_->feature_flags().npot_ok);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
+ EXPECT_FALSE(info_->feature_flags().chromium_webglsl);
+ EXPECT_FALSE(info_->feature_flags().oes_egl_image_external);
+ EXPECT_FALSE(info_->feature_flags().chromium_stream_texture);
}
TEST_F(FeatureInfoTest, InitializeNoExtensions) {
SetupInitExpectations("");
- info_.Initialize(NULL);
+ info_->Initialize(NULL);
// Check default extensions are there
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_CHROMIUM_resource_safe"));
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_CHROMIUM_strict_attribs"));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_resource_safe"));
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_strict_attribs"));
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_ANGLE_translated_shader_source"));
// Check a couple of random extensions that should not be there.
- EXPECT_THAT(info_.extensions(), Not(HasSubstr("GL_CHROMIUM_webglsl")));
- EXPECT_THAT(info_.extensions(), Not(HasSubstr("GL_OES_texture_npot")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_CHROMIUM_webglsl")));
+ EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_npot")));
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_EXT_texture_compression_dxt1")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt3")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt5")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_ANGLE_texture_usage")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_EXT_texture_storage")));
- EXPECT_FALSE(info_.feature_flags().npot_ok);
- EXPECT_FALSE(info_.feature_flags().chromium_webglsl);
- EXPECT_FALSE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_FALSE(info_->feature_flags().npot_ok);
+ EXPECT_FALSE(info_->feature_flags().chromium_webglsl);
+ EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
- EXPECT_FALSE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
- EXPECT_FALSE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
- EXPECT_FALSE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
- EXPECT_FALSE(info_.validators()->read_pixel_format.IsValid(
+ EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(
GL_BGRA_EXT));
- EXPECT_FALSE(info_.validators()->texture_parameter.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
GL_TEXTURE_MAX_ANISOTROPY_EXT));
- EXPECT_FALSE(info_.validators()->g_l_state.IsValid(
+ EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
- EXPECT_FALSE(info_.validators()->frame_buffer_target.IsValid(
+ EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
GL_READ_FRAMEBUFFER_EXT));
- EXPECT_FALSE(info_.validators()->frame_buffer_target.IsValid(
+ EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
GL_DRAW_FRAMEBUFFER_EXT));
- EXPECT_FALSE(info_.validators()->g_l_state.IsValid(
+ EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
GL_READ_FRAMEBUFFER_BINDING_EXT));
- EXPECT_FALSE(info_.validators()->render_buffer_parameter.IsValid(
+ EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
GL_MAX_SAMPLES_EXT));
- EXPECT_FALSE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_COMPONENT));
- EXPECT_FALSE(info_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
- EXPECT_FALSE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+ EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
GL_DEPTH24_STENCIL8));
- EXPECT_FALSE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_STENCIL));
- EXPECT_FALSE(info_.validators()->texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_format.IsValid(
GL_DEPTH_STENCIL));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(
GL_UNSIGNED_INT_24_8));
- EXPECT_FALSE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
GL_DEPTH_COMPONENT24));
- EXPECT_FALSE(info_.validators()->texture_parameter.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
GL_TEXTURE_USAGE_ANGLE));
}
TEST_F(FeatureInfoTest, InitializeNPOTExtensionGLES) {
SetupInitExpectations("GL_OES_texture_npot");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_npot"));
- EXPECT_TRUE(info_.feature_flags().npot_ok);
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
+ EXPECT_TRUE(info_->feature_flags().npot_ok);
}
TEST_F(FeatureInfoTest, InitializeNPOTExtensionGL) {
SetupInitExpectations("GL_ARB_texture_non_power_of_two");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_npot"));
- EXPECT_TRUE(info_.feature_flags().npot_ok);
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
+ EXPECT_TRUE(info_->feature_flags().npot_ok);
}
TEST_F(FeatureInfoTest, InitializeDXTExtensionGLES2) {
SetupInitExpectations("GL_EXT_texture_compression_dxt1");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_texture_compression_dxt1"));
- EXPECT_TRUE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
- EXPECT_TRUE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
- EXPECT_FALSE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
- EXPECT_FALSE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
}
TEST_F(FeatureInfoTest, InitializeDXTExtensionGL) {
SetupInitExpectations("GL_EXT_texture_compression_s3tc");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_texture_compression_dxt1"));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_CHROMIUM_texture_compression_dxt3"));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_CHROMIUM_texture_compression_dxt5"));
- EXPECT_TRUE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
- EXPECT_TRUE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
- EXPECT_TRUE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
- EXPECT_TRUE(info_.validators()->compressed_texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GLES2) {
SetupInitExpectations("GL_EXT_texture_format_BGRA8888");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_texture_format_BGRA8888"));
- EXPECT_TRUE(info_.validators()->texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_format.IsValid(
GL_BGRA_EXT));
- EXPECT_TRUE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
GL_BGRA_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
SetupInitExpectations("GL_EXT_bgra");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_texture_format_BGRA8888"));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_read_format_bgra"));
- EXPECT_TRUE(info_.validators()->texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_format.IsValid(
GL_BGRA_EXT));
- EXPECT_TRUE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
GL_BGRA_EXT));
- EXPECT_TRUE(info_.validators()->read_pixel_format.IsValid(
+ EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
GL_BGRA_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888Apple) {
SetupInitExpectations("GL_APPLE_texture_format_BGRA8888");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_texture_format_BGRA8888"));
- EXPECT_TRUE(info_.validators()->texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_format.IsValid(
GL_BGRA_EXT));
- EXPECT_TRUE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
GL_BGRA_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_read_format_bgra) {
SetupInitExpectations("GL_EXT_read_format_bgra");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_read_format_bgra"));
- EXPECT_FALSE(info_.validators()->texture_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_format.IsValid(
GL_BGRA_EXT));
- EXPECT_FALSE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
GL_BGRA_EXT));
- EXPECT_TRUE(info_.validators()->read_pixel_format.IsValid(
+ EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
GL_BGRA_EXT));
}
TEST_F(FeatureInfoTest, InitializeOES_texture_floatGLES2) {
SetupInitExpectations("GL_OES_texture_float");
- info_.Initialize(NULL);
- EXPECT_FALSE(info_.feature_flags().enable_texture_float_linear);
- EXPECT_FALSE(info_.feature_flags().enable_texture_half_float_linear);
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_float"));
- EXPECT_THAT(info_.extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
+ EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_OES_texture_float_linear")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_OES_texture_half_float_linear")));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_FLOAT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
}
TEST_F(FeatureInfoTest, InitializeOES_texture_float_linearGLES2) {
SetupInitExpectations("GL_OES_texture_float GL_OES_texture_float_linear");
- info_.Initialize(NULL);
- EXPECT_TRUE(info_.feature_flags().enable_texture_float_linear);
- EXPECT_FALSE(info_.feature_flags().enable_texture_half_float_linear);
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_float"));
- EXPECT_THAT(info_.extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_float_linear"));
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_TRUE(info_->feature_flags().enable_texture_float_linear);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
+ EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float_linear"));
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_OES_texture_half_float_linear")));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_FLOAT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
}
TEST_F(FeatureInfoTest, InitializeOES_texture_half_floatGLES2) {
SetupInitExpectations("GL_OES_texture_half_float");
- info_.Initialize(NULL);
- EXPECT_FALSE(info_.feature_flags().enable_texture_float_linear);
- EXPECT_FALSE(info_.feature_flags().enable_texture_half_float_linear);
- EXPECT_THAT(info_.extensions(), Not(HasSubstr("GL_OES_texture_float")));
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_half_float"));
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
+ EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_OES_texture_float_linear")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_OES_texture_half_float_linear")));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_FLOAT));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
}
TEST_F(FeatureInfoTest, InitializeOES_texture_half_float_linearGLES2) {
SetupInitExpectations(
"GL_OES_texture_half_float GL_OES_texture_half_float_linear");
- info_.Initialize(NULL);
- EXPECT_FALSE(info_.feature_flags().enable_texture_float_linear);
- EXPECT_TRUE(info_.feature_flags().enable_texture_half_float_linear);
- EXPECT_THAT(info_.extensions(), Not(HasSubstr("GL_OES_texture_float")));
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_texture_half_float"));
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
+ EXPECT_TRUE(info_->feature_flags().enable_texture_half_float_linear);
+ EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
+ EXPECT_THAT(info_->extensions(),
Not(HasSubstr("GL_OES_texture_float_linear")));
- EXPECT_THAT(info_.extensions(),
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_texture_half_float_linear"));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_FLOAT));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
}
TEST_F(FeatureInfoTest, InitializeEXT_framebuffer_multisample) {
SetupInitExpectations("GL_EXT_framebuffer_multisample");
- info_.Initialize(NULL);
- EXPECT_TRUE(info_.feature_flags().chromium_framebuffer_multisample);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
- EXPECT_TRUE(info_.validators()->frame_buffer_target.IsValid(
+ EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
GL_READ_FRAMEBUFFER_EXT));
- EXPECT_TRUE(info_.validators()->frame_buffer_target.IsValid(
+ EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
GL_DRAW_FRAMEBUFFER_EXT));
- EXPECT_TRUE(info_.validators()->g_l_state.IsValid(
+ EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
GL_READ_FRAMEBUFFER_BINDING_EXT));
- EXPECT_TRUE(info_.validators()->g_l_state.IsValid(
+ EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
GL_MAX_SAMPLES_EXT));
- EXPECT_TRUE(info_.validators()->render_buffer_parameter.IsValid(
+ EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
GL_RENDERBUFFER_SAMPLES_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_texture_filter_anisotropic) {
SetupInitExpectations("GL_EXT_texture_filter_anisotropic");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_texture_filter_anisotropic"));
- EXPECT_TRUE(info_.validators()->texture_parameter.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
GL_TEXTURE_MAX_ANISOTROPY_EXT));
- EXPECT_TRUE(info_.validators()->g_l_state.IsValid(
+ EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_ARB_depth_texture) {
SetupInitExpectations("GL_ARB_depth_texture");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_GOOGLE_depth_texture"));
- EXPECT_TRUE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_COMPONENT));
- EXPECT_TRUE(info_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+ EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
}
TEST_F(FeatureInfoTest, InitializeOES_ARB_depth_texture) {
SetupInitExpectations("GL_OES_depth_texture");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_GOOGLE_depth_texture"));
- EXPECT_TRUE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_COMPONENT));
- EXPECT_TRUE(info_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+ EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
}
TEST_F(FeatureInfoTest, InitializeEXT_packed_depth_stencil) {
SetupInitExpectations("GL_EXT_packed_depth_stencil");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_packed_depth_stencil"));
- EXPECT_TRUE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
GL_DEPTH24_STENCIL8));
- EXPECT_FALSE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_COMPONENT));
- EXPECT_FALSE(info_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+ EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
}
TEST_F(FeatureInfoTest, InitializeOES_packed_depth_stencil) {
SetupInitExpectations("GL_OES_packed_depth_stencil");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_packed_depth_stencil"));
- EXPECT_TRUE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
GL_DEPTH24_STENCIL8));
- EXPECT_FALSE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_COMPONENT));
- EXPECT_FALSE(info_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
- EXPECT_FALSE(info_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+ EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
}
TEST_F(FeatureInfoTest,
InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture) {
SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_packed_depth_stencil"));
- EXPECT_TRUE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
GL_DEPTH24_STENCIL8));
- EXPECT_TRUE(info_.validators()->texture_internal_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
GL_DEPTH_STENCIL));
- EXPECT_TRUE(info_.validators()->texture_format.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_format.IsValid(
GL_DEPTH_STENCIL));
- EXPECT_TRUE(info_.validators()->pixel_type.IsValid(
+ EXPECT_TRUE(info_->validators()->pixel_type.IsValid(
GL_UNSIGNED_INT_24_8));
}
TEST_F(FeatureInfoTest, InitializeOES_depth24) {
SetupInitExpectations("GL_OES_depth24");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_depth24"));
- EXPECT_TRUE(info_.validators()->render_buffer_format.IsValid(
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
GL_DEPTH_COMPONENT24));
}
TEST_F(FeatureInfoTest, InitializeOES_standard_derivatives) {
SetupInitExpectations("GL_OES_standard_derivatives");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_OES_standard_derivatives"));
- EXPECT_TRUE(info_.feature_flags().oes_standard_derivatives);
- EXPECT_TRUE(info_.validators()->hint_target.IsValid(
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_standard_derivatives"));
+ EXPECT_TRUE(info_->feature_flags().oes_standard_derivatives);
+ EXPECT_TRUE(info_->validators()->hint_target.IsValid(
GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
- EXPECT_TRUE(info_.validators()->g_l_state.IsValid(
+ EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
}
TEST_F(FeatureInfoTest, InitializeCHROMIUM_webglsl) {
SetupInitExpectations("");
- info_.Initialize("GL_CHROMIUM_webglsl");
- EXPECT_THAT(info_.extensions(), HasSubstr("GL_CHROMIUM_webglsl"));
- EXPECT_TRUE(info_.feature_flags().chromium_webglsl);
+ info_->Initialize("GL_CHROMIUM_webglsl");
+ EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_webglsl"));
+ EXPECT_TRUE(info_->feature_flags().chromium_webglsl);
}
TEST_F(FeatureInfoTest, InitializeOES_rgb8_rgba8) {
SetupInitExpectations("GL_OES_rgb8_rgba8");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_rgb8_rgba8"));
- EXPECT_TRUE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
GL_RGB8_OES));
- EXPECT_TRUE(info_.validators()->render_buffer_format.IsValid(
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
GL_RGBA8_OES));
}
TEST_F(FeatureInfoTest, InitializeOES_EGL_image_external) {
SetupInitExpectations("GL_OES_EGL_image_external");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_EGL_image_external"));
- EXPECT_TRUE(info_.feature_flags().oes_egl_image_external);
- EXPECT_TRUE(info_.validators()->texture_bind_target.IsValid(
+ EXPECT_TRUE(info_->feature_flags().oes_egl_image_external);
+ EXPECT_TRUE(info_->validators()->texture_bind_target.IsValid(
GL_TEXTURE_EXTERNAL_OES));
- EXPECT_TRUE(info_.validators()->get_tex_param_target.IsValid(
+ EXPECT_TRUE(info_->validators()->get_tex_param_target.IsValid(
GL_TEXTURE_EXTERNAL_OES));
- EXPECT_TRUE(info_.validators()->texture_parameter.IsValid(
+ EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES));
- EXPECT_TRUE(info_.validators()->g_l_state.IsValid(
+ EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
GL_TEXTURE_BINDING_EXTERNAL_OES));
}
TEST_F(FeatureInfoTest, InitializeCHROMIUM_stream_texture) {
SetupInitExpectations("GL_CHROMIUM_stream_texture");
- info_.Initialize(NULL);
- EXPECT_THAT(info_.extensions(),
+ info_->Initialize(NULL);
+ EXPECT_THAT(info_->extensions(),
HasSubstr("GL_CHROMIUM_stream_texture"));
- EXPECT_TRUE(info_.feature_flags().chromium_stream_texture);
+ EXPECT_TRUE(info_->feature_flags().chromium_stream_texture);
}
} // namespace gles2
diff --git a/gpu/command_buffer/service/framebuffer_manager_unittest.cc b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
index f6a8b0d..cbe524a 100644
--- a/gpu/command_buffer/service/framebuffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,7 +19,7 @@ class FramebufferManagerTest : public testing::Test {
public:
FramebufferManagerTest()
- : texture_manager_(kMaxTextureSize, kMaxCubemapSize),
+ : texture_manager_(new FeatureInfo(), kMaxTextureSize, kMaxCubemapSize),
renderbuffer_manager_(kMaxRenderbufferSize, kMaxSamples) {
}
@@ -108,7 +108,7 @@ class FramebufferInfoTest : public testing::Test {
FramebufferInfoTest()
: manager_(),
- texture_manager_(kMaxTextureSize, kMaxCubemapSize),
+ texture_manager_(new FeatureInfo(), kMaxTextureSize, kMaxCubemapSize),
renderbuffer_manager_(kMaxRenderbufferSize, kMaxSamples) {
}
~FramebufferInfoTest() {
@@ -398,10 +398,8 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
info_->IsPossiblyComplete());
- FeatureInfo feature_info;
- texture_manager_.CreateTextureInfo(
- &feature_info, kTextureClient1Id, kTextureService1Id);
- TextureManager::TextureInfo* tex_info1 =
+ texture_manager_.CreateTextureInfo(kTextureClient1Id, kTextureService1Id);
+ TextureManager::TextureInfo::Ref tex_info1 =
texture_manager_.GetTextureInfo(kTextureClient1Id);
ASSERT_TRUE(tex_info1 != NULL);
@@ -413,15 +411,15 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_TRUE(info_->IsCleared());
EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
- texture_manager_.SetInfoTarget(&feature_info, tex_info1, GL_TEXTURE_2D);
+ texture_manager_.SetInfoTarget(tex_info1, GL_TEXTURE_2D);
texture_manager_.SetLevelInfo(
- &feature_info, tex_info1, GL_TEXTURE_2D, kLevel1,
+ tex_info1, GL_TEXTURE_2D, kLevel1,
kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
info_->IsPossiblyComplete());
EXPECT_FALSE(info_->IsCleared());
texture_manager_.SetLevelInfo(
- &feature_info, tex_info1, GL_TEXTURE_2D, kLevel1,
+ tex_info1, GL_TEXTURE_2D, kLevel1,
kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
info_->IsPossiblyComplete());
@@ -438,14 +436,13 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_TRUE(attachment->cleared());
// Check replacing an attachment
- texture_manager_.CreateTextureInfo(
- &feature_info, kTextureClient2Id, kTextureService2Id);
- TextureManager::TextureInfo* tex_info2 =
+ texture_manager_.CreateTextureInfo(kTextureClient2Id, kTextureService2Id);
+ TextureManager::TextureInfo::Ref tex_info2 =
texture_manager_.GetTextureInfo(kTextureClient2Id);
ASSERT_TRUE(tex_info2 != NULL);
- texture_manager_.SetInfoTarget(&feature_info, tex_info2, GL_TEXTURE_2D);
+ texture_manager_.SetInfoTarget(tex_info2, GL_TEXTURE_2D);
texture_manager_.SetLevelInfo(
- &feature_info, tex_info2, GL_TEXTURE_2D, kLevel2,
+ tex_info2, GL_TEXTURE_2D, kLevel2,
kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType, true);
info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget2, kLevel2);
@@ -464,7 +461,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
// Check changing attachment
texture_manager_.SetLevelInfo(
- &feature_info, tex_info2, GL_TEXTURE_2D, kLevel3,
+ tex_info2, GL_TEXTURE_2D, kLevel3,
kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType, false);
attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0);
ASSERT_TRUE(attachment != NULL);
@@ -480,7 +477,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
// Set to size 0
texture_manager_.SetLevelInfo(
- &feature_info, tex_info2, GL_TEXTURE_2D, kLevel3,
+ tex_info2, GL_TEXTURE_2D, kLevel3,
kFormat3, 0, 0, kDepth, kBorder, kFormat3, kType, false);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
info_->IsPossiblyComplete());
@@ -538,15 +535,12 @@ TEST_F(FramebufferInfoTest, UnbindTexture) {
const GLenum kTarget1 = GL_TEXTURE_2D;
const GLint kLevel1 = 0;
- FeatureInfo feature_info;
- texture_manager_.CreateTextureInfo(
- &feature_info, kTextureClient1Id, kTextureService1Id);
- TextureManager::TextureInfo* tex_info1 =
+ texture_manager_.CreateTextureInfo(kTextureClient1Id, kTextureService1Id);
+ TextureManager::TextureInfo::Ref tex_info1 =
texture_manager_.GetTextureInfo(kTextureClient1Id);
ASSERT_TRUE(tex_info1 != NULL);
- texture_manager_.CreateTextureInfo(
- &feature_info, kTextureClient2Id, kTextureService2Id);
- TextureManager::TextureInfo* tex_info2 =
+ texture_manager_.CreateTextureInfo(kTextureClient2Id, kTextureService2Id);
+ TextureManager::TextureInfo::Ref tex_info2 =
texture_manager_.GetTextureInfo(kTextureClient2Id);
ASSERT_TRUE(tex_info2 != NULL);
@@ -576,15 +570,13 @@ TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) {
const GLenum kTarget1 = GL_TEXTURE_2D;
const GLint kLevel1 = 0;
- FeatureInfo feature_info;
renderbuffer_manager_.CreateRenderbufferInfo(
kRenderbufferClient1Id, kRenderbufferService1Id);
RenderbufferManager::RenderbufferInfo* rb_info1 =
renderbuffer_manager_.GetRenderbufferInfo(kRenderbufferClient1Id);
ASSERT_TRUE(rb_info1 != NULL);
- texture_manager_.CreateTextureInfo(
- &feature_info, kTextureClient2Id, kTextureService2Id);
- TextureManager::TextureInfo* tex_info2 =
+ texture_manager_.CreateTextureInfo(kTextureClient2Id, kTextureService2Id);
+ TextureManager::TextureInfo::Ref tex_info2 =
texture_manager_.GetTextureInfo(kTextureClient2Id);
ASSERT_TRUE(tex_info2 != NULL);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 352d044..f544e54 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -507,6 +507,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
public GLES2Decoder {
public:
explicit GLES2DecoderImpl(ContextGroup* group);
+ ~GLES2DecoderImpl();
// Overridden from AsyncAPIInterface.
virtual Error DoCommand(unsigned int command,
@@ -669,8 +670,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Creates a TextureInfo for the given texture.
TextureManager::TextureInfo* CreateTextureInfo(
GLuint client_id, GLuint service_id) {
- return texture_manager()->CreateTextureInfo(
- feature_info_, client_id, service_id);
+ return texture_manager()->CreateTextureInfo(client_id, service_id);
}
// Gets the texture info for the given texture. Returns NULL if none exists.
@@ -682,7 +682,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Deletes the texture info for the given texture.
void RemoveTextureInfo(GLuint client_id) {
- texture_manager()->RemoveTextureInfo(feature_info_, client_id);
+ texture_manager()->RemoveTextureInfo(client_id);
}
// Get the size (in pixels) of the currently bound frame buffer (either FBO
@@ -1476,7 +1476,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Cached from ContextGroup
const Validators* validators_;
- FeatureInfo* feature_info_;
+ FeatureInfo::Ref feature_info_;
// This indicates all the following texSubImage2D calls that are part of the
// failed texImage2D call should be ignored.
@@ -1922,6 +1922,9 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
}
}
+GLES2DecoderImpl::~GLES2DecoderImpl() {
+}
+
bool GLES2DecoderImpl::Initialize(
const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
@@ -2623,7 +2626,6 @@ void GLES2DecoderImpl::UpdateParentTextureInfo() {
DCHECK(info);
parent_texture_manager->SetLevelInfo(
- feature_info_,
info,
GL_TEXTURE_2D,
0, // level
@@ -2636,22 +2638,18 @@ void GLES2DecoderImpl::UpdateParentTextureInfo() {
GL_UNSIGNED_BYTE,
true);
parent_texture_manager->SetParameter(
- feature_info_,
info,
GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
parent_texture_manager->SetParameter(
- feature_info_,
info,
GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
parent_texture_manager->SetParameter(
- feature_info_,
info,
GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
parent_texture_manager->SetParameter(
- feature_info_,
info,
GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
@@ -2691,6 +2689,15 @@ void GLES2DecoderImpl::Destroy() {
SetParent(NULL, 0);
+ // Unbind everything.
+ texture_units_.reset();
+ bound_array_buffer_ = NULL;
+ bound_element_array_buffer_ = NULL;
+ current_program_ = NULL;
+ bound_read_framebuffer_ = NULL;
+ bound_draw_framebuffer_ = NULL;
+ bound_renderbuffer_ = NULL;
+
if (have_context) {
if (current_program_) {
program_manager()->UnuseProgram(shader_manager(), current_program_);
@@ -2786,7 +2793,7 @@ bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
GLuint service_id = offscreen_saved_color_texture_->id();
GLuint client_id = 0;
if (parent_->texture_manager()->GetClientId(service_id, &client_id)) {
- parent_->texture_manager()->RemoveTextureInfo(feature_info_, client_id);
+ parent_->texture_manager()->RemoveTextureInfo(client_id);
}
}
@@ -2799,15 +2806,14 @@ bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
// Replace texture info when ID is already in use by parent.
if (new_parent_impl->texture_manager()->GetTextureInfo(
- new_parent_texture_id))
+ new_parent_texture_id))
new_parent_impl->texture_manager()->RemoveTextureInfo(
- feature_info_, new_parent_texture_id);
+ new_parent_texture_id);
TextureManager::TextureInfo* info =
new_parent_impl->CreateTextureInfo(new_parent_texture_id, service_id);
info->SetNotOwned();
- new_parent_impl->texture_manager()->SetInfoTarget(feature_info_,
- info, GL_TEXTURE_2D);
+ new_parent_impl->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D);
parent_ = new_parent_impl->AsWeakPtr();
@@ -3270,6 +3276,7 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
// It's a new id so make a texture info for it.
glGenTextures(1, &service_id);
+ DCHECK_NE(0u, service_id);
CreateTextureInfo(client_id, service_id);
info = GetTextureInfo(client_id);
IdAllocatorInterface* id_allocator =
@@ -3293,7 +3300,7 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
return;
}
if (info->target() == 0) {
- texture_manager()->SetInfoTarget(feature_info_, info, target);
+ texture_manager()->SetInfoTarget(info, target);
}
glBindTexture(target, info->service_id());
TextureUnit& unit = texture_units_[active_texture_unit_];
@@ -3348,7 +3355,7 @@ void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) {
void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
if (!info ||
- !texture_manager()->MarkMipmapsGenerated(feature_info_, info)) {
+ !texture_manager()->MarkMipmapsGenerated(info)) {
SetGLError(GL_INVALID_OPERATION,
"glGenerateMipmaps: Can not generate mips for npot textures");
return;
@@ -4154,8 +4161,7 @@ void GLES2DecoderImpl::DoFramebufferTexture2D(
service_id = info->service_id();
}
- if (!texture_manager()->ValidForTarget(
- feature_info_, textarget, level, 0, 0, 1)) {
+ if (!texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) {
SetGLError(GL_INVALID_VALUE,
"glFramebufferTexture2D: level out of range");
return;
@@ -4375,7 +4381,7 @@ void GLES2DecoderImpl::DoTexParameterf(
}
if (!texture_manager()->SetParameter(
- feature_info_, info, pname, static_cast<GLint>(param))) {
+ info, pname, static_cast<GLint>(param))) {
SetGLError(GL_INVALID_ENUM, "glTexParameterf: param GL_INVALID_ENUM");
return;
}
@@ -4390,7 +4396,7 @@ void GLES2DecoderImpl::DoTexParameteri(
return;
}
- if (!texture_manager()->SetParameter(feature_info_, info, pname, param)) {
+ if (!texture_manager()->SetParameter(info, pname, param)) {
SetGLError(GL_INVALID_ENUM, "glTexParameteri: param GL_INVALID_ENUM");
return;
}
@@ -4406,7 +4412,7 @@ void GLES2DecoderImpl::DoTexParameterfv(
}
if (!texture_manager()->SetParameter(
- feature_info_, info, pname, static_cast<GLint>(params[0]))) {
+ info, pname, static_cast<GLint>(params[0]))) {
SetGLError(GL_INVALID_ENUM, "glTexParameterfv: param GL_INVALID_ENUM");
return;
}
@@ -4421,7 +4427,7 @@ void GLES2DecoderImpl::DoTexParameteriv(
return;
}
- if (!texture_manager()->SetParameter(feature_info_, info, pname, *params)) {
+ if (!texture_manager()->SetParameter(info, pname, *params)) {
SetGLError(GL_INVALID_ENUM, "glTexParameteriv: param GL_INVALID_ENUM");
return;
}
@@ -4731,7 +4737,7 @@ bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() {
TextureUnit& texture_unit = texture_units_[texture_unit_index];
TextureManager::TextureInfo* texture_info =
texture_unit.GetInfoForSamplerType(uniform_info->type);
- if (!texture_info || !texture_info->CanRender(feature_info_)) {
+ if (!texture_info || !texture_manager()->CanRender(texture_info)) {
textures_set = true;
glActiveTexture(GL_TEXTURE0 + texture_unit_index);
glBindTexture(
@@ -4761,7 +4767,7 @@ void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
uniform_info->type == GL_SAMPLER_2D ?
texture_unit.bound_texture_2d :
texture_unit.bound_texture_cube_map;
- if (!texture_info || !texture_info->CanRender(feature_info_)) {
+ if (!texture_info || !texture_manager()->CanRender(texture_info)) {
glActiveTexture(GL_TEXTURE0 + texture_unit_index);
// Get the texture info that was previously bound here.
texture_info = texture_unit.bind_target == GL_TEXTURE_2D ?
@@ -6312,8 +6318,7 @@ error::Error GLES2DecoderImpl::DoCompressedTexImage2D(
"glCompressedTexImage2D: internal_format GL_INVALID_ENUM");
return error::kNoError;
}
- if (!texture_manager()->ValidForTarget(
- feature_info_, target, level, width, height, 1) ||
+ if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
border != 0) {
SetGLError(GL_INVALID_VALUE,
"glCompressedTexImage2D: dimensions out of range");
@@ -6350,7 +6355,6 @@ error::Error GLES2DecoderImpl::DoCompressedTexImage2D(
GLenum error = PeekGLError();
if (error == GL_NO_ERROR) {
texture_manager()->SetLevelInfo(
- feature_info_,
info, target, level, internal_format, width, height, 1, border, 0, 0,
true);
}
@@ -6500,8 +6504,7 @@ error::Error GLES2DecoderImpl::DoTexImage2D(
SetGLError(GL_INVALID_OPERATION, "glTexImage2D: format != internalFormat");
return error::kNoError;
}
- if (!texture_manager()->ValidForTarget(
- feature_info_, target, level, width, height, 1) ||
+ if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
border != 0) {
SetGLError(GL_INVALID_VALUE, "glTexImage2D: dimensions out of range");
return error::kNoError;
@@ -6532,7 +6535,7 @@ error::Error GLES2DecoderImpl::DoTexImage2D(
if (level_is_same && !pixels) {
// Just set the level info but mark the texture as uncleared.
texture_manager()->SetLevelInfo(
- feature_info_, info,
+ info,
target, level, internal_format, width, height, 1, border, format, type,
false);
tex_image_2d_failed_ = false;
@@ -6559,7 +6562,7 @@ error::Error GLES2DecoderImpl::DoTexImage2D(
GLenum error = PeekGLError();
if (error == GL_NO_ERROR) {
texture_manager()->SetLevelInfo(
- feature_info_, info,
+ info,
target, level, internal_format, width, height, 1, border, format, type,
pixels != NULL);
tex_image_2d_failed_ = false;
@@ -6705,8 +6708,7 @@ void GLES2DecoderImpl::DoCopyTexImage2D(
SetGLError(GL_INVALID_OPERATION,
"glCopyTexImage2D: texture is immutable");
}
- if (!texture_manager()->ValidForTarget(
- feature_info_, target, level, width, height, 1) ||
+ if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
border != 0) {
SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D: dimensions out of range");
return;
@@ -6773,7 +6775,7 @@ void GLES2DecoderImpl::DoCopyTexImage2D(
GLenum error = PeekGLError();
if (error == GL_NO_ERROR) {
texture_manager()->SetLevelInfo(
- feature_info_, info, target, level, internal_format, width, height, 1,
+ info, target, level, internal_format, width, height, 1,
border, internal_format, GL_UNSIGNED_BYTE, true);
}
}
@@ -7510,7 +7512,7 @@ error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM(
uint32 immediate_data_size,
const gles2::GetRequestableExtensionsCHROMIUM& c) {
Bucket* bucket = CreateBucket(c.bucket_id);
- scoped_ptr<FeatureInfo> info(new FeatureInfo());
+ FeatureInfo::Ref info(new FeatureInfo());
info->Initialize(disallowed_features_, NULL);
bucket->SetFromString(info->extensions().c_str());
return error::kNoError;
@@ -7754,7 +7756,7 @@ error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM(
stream_texture_manager_->DestroyStreamTexture(info->service_id());
info->SetStreamTexture(false);
- texture_manager()->SetInfoTarget(feature_info_, info, 0);
+ texture_manager()->SetInfoTarget(info, 0);
} else {
SetGLError(GL_INVALID_VALUE,
"glDestroyStreamTextureCHROMIUM: bad texture id.");
@@ -7858,8 +7860,7 @@ void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM(
}
texture_manager()->SetLevelInfo(
- feature_info_, info,
- target, 0, GL_RGBA, width, height, 1, 0,
+ info, target, 0, GL_RGBA, width, height, 1, 0,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true);
#else
@@ -7964,8 +7965,7 @@ void GLES2DecoderImpl::DoTexStorage2DEXT(
GLenum internal_format,
GLsizei width,
GLsizei height) {
- if (!texture_manager()->ValidForTarget(
- feature_info_, target, 0, width, height, 1) ||
+ if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) ||
TextureManager::ComputeMipMapCount(width, height, 1) < levels) {
SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT: dimensions out of range");
return;
@@ -7995,9 +7995,8 @@ void GLES2DecoderImpl::DoTexStorage2DEXT(
GLsizei level_height = height;
for (int ii = 0; ii < levels; ++ii) {
texture_manager()->SetLevelInfo(
- feature_info_, info,
- target, 0, format, level_width, level_height, 1, 0, format, type,
- false);
+ info, target, 0, format, level_width, level_height, 1, 0, format,
+ type, false);
level_width = std::max(1, level_width >> 1);
level_height = std::max(1, level_height >> 1);
}
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 1ee041f..cb04dd0 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -63,7 +63,6 @@ TextureManager::~TextureManager() {
void TextureManager::Destroy(bool have_context) {
while (!texture_infos_.empty()) {
TextureInfo* info = texture_infos_.begin()->second;
- mem_represented_ -= info->estimated_size();
if (have_context) {
if (!info->IsDeleted() && info->owned_) {
GLuint service_id = info->service_id();
@@ -89,6 +88,13 @@ void TextureManager::Destroy(bool have_context) {
UpdateMemRepresented();
}
+TextureManager::TextureInfo::~TextureInfo() {
+ if (manager_) {
+ manager_->StopTracking(this);
+ manager_ = NULL;
+ }
+}
+
bool TextureManager::TextureInfo::CanRender(
const FeatureInfo* feature_info) const {
if (target_ == 0) {
@@ -544,9 +550,11 @@ bool TextureManager::TextureInfo::ClearLevel(
}
TextureManager::TextureManager(
+ FeatureInfo* feature_info,
GLint max_texture_size,
GLint max_cube_map_texture_size)
- : max_texture_size_(max_texture_size),
+ : feature_info_(feature_info),
+ max_texture_size_(max_texture_size),
max_cube_map_texture_size_(max_cube_map_texture_size),
max_levels_(ComputeMipMapCount(max_texture_size,
max_texture_size,
@@ -572,7 +580,7 @@ void TextureManager::UpdateMemRepresented() {
}
}
-bool TextureManager::Initialize(const FeatureInfo* feature_info) {
+bool TextureManager::Initialize() {
UpdateMemRepresented();
// TODO(gman): The default textures have to be real textures, not the 0
@@ -580,27 +588,24 @@ bool TextureManager::Initialize(const FeatureInfo* feature_info) {
// resources and all contexts that share resource share the same default
// texture.
default_textures_[kTexture2D] = CreateDefaultAndBlackTextures(
- feature_info, GL_TEXTURE_2D, &black_texture_ids_[kTexture2D]);
+ GL_TEXTURE_2D, &black_texture_ids_[kTexture2D]);
default_textures_[kCubeMap] = CreateDefaultAndBlackTextures(
- feature_info, GL_TEXTURE_CUBE_MAP, &black_texture_ids_[kCubeMap]);
+ GL_TEXTURE_CUBE_MAP, &black_texture_ids_[kCubeMap]);
- if (feature_info->feature_flags().oes_egl_image_external) {
+ if (feature_info_->feature_flags().oes_egl_image_external) {
default_textures_[kExternalOES] = CreateDefaultAndBlackTextures(
- feature_info, GL_TEXTURE_EXTERNAL_OES,
- &black_texture_ids_[kExternalOES]);
+ GL_TEXTURE_EXTERNAL_OES, &black_texture_ids_[kExternalOES]);
}
- if (feature_info->feature_flags().arb_texture_rectangle) {
+ if (feature_info_->feature_flags().arb_texture_rectangle) {
default_textures_[kRectangleARB] = CreateDefaultAndBlackTextures(
- feature_info, GL_TEXTURE_RECTANGLE_ARB,
- &black_texture_ids_[kRectangleARB]);
+ GL_TEXTURE_RECTANGLE_ARB, &black_texture_ids_[kRectangleARB]);
}
return true;
}
TextureManager::TextureInfo::Ref TextureManager::CreateDefaultAndBlackTextures(
- const FeatureInfo* feature_info,
GLenum target,
GLuint* black_texture) {
static uint8 black[] = {0, 0, 0, 255};
@@ -632,24 +637,23 @@ TextureManager::TextureInfo::Ref TextureManager::CreateDefaultAndBlackTextures(
// Since we are manually setting up these textures
// we need to manually manipulate some of the their bookkeeping.
++num_unrenderable_textures_;
- TextureInfo::Ref default_texture = TextureInfo::Ref(new TextureInfo(ids[1]));
- SetInfoTarget(feature_info, default_texture, target);
- FeatureInfo temp_feature_info;
+ TextureInfo::Ref default_texture = TextureInfo::Ref(
+ new TextureInfo(NULL, ids[1]));
+ SetInfoTarget(default_texture, target);
if (needs_faces) {
for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) {
SetLevelInfo(
- &temp_feature_info, default_texture,
- GLES2Util::IndexToGLFaceTarget(ii),
+ default_texture, GLES2Util::IndexToGLFaceTarget(ii),
0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
}
} else {
if (needs_initialization) {
- SetLevelInfo(&temp_feature_info, default_texture,
+ SetLevelInfo(default_texture,
GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0,
GL_RGBA, GL_UNSIGNED_BYTE, true);
} else {
SetLevelInfo(
- &temp_feature_info, default_texture, GL_TEXTURE_EXTERNAL_OES, 0,
+ default_texture, GL_TEXTURE_EXTERNAL_OES, 0,
GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
}
}
@@ -659,9 +663,7 @@ TextureManager::TextureInfo::Ref TextureManager::CreateDefaultAndBlackTextures(
}
bool TextureManager::ValidForTarget(
- const FeatureInfo* feature_info,
- GLenum target, GLint level,
- GLsizei width, GLsizei height, GLsizei depth) {
+ GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth) {
GLsizei max_size = MaxSizeForTarget(target);
return level >= 0 &&
width >= 0 &&
@@ -671,7 +673,7 @@ bool TextureManager::ValidForTarget(
width <= max_size &&
height <= max_size &&
depth <= max_size &&
- (level == 0 || feature_info->feature_flags().npot_ok ||
+ (level == 0 || feature_info_->feature_flags().npot_ok ||
(!GLES2Util::IsNPOT(width) &&
!GLES2Util::IsNPOT(height) &&
!GLES2Util::IsNPOT(depth))) &&
@@ -680,15 +682,14 @@ bool TextureManager::ValidForTarget(
}
void TextureManager::SetInfoTarget(
- const FeatureInfo* feature_info,
TextureManager::TextureInfo* info, GLenum target) {
DCHECK(info);
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
DCHECK_NE(0, num_unrenderable_textures_);
--num_unrenderable_textures_;
}
info->SetTarget(target, MaxLevelsForTarget(target));
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
++num_unrenderable_textures_;
}
}
@@ -750,7 +751,6 @@ bool TextureManager::ClearTextureLevel(
}
void TextureManager::SetLevelInfo(
- const FeatureInfo* feature_info,
TextureManager::TextureInfo* info,
GLenum target,
GLint level,
@@ -763,7 +763,7 @@ void TextureManager::SetLevelInfo(
GLenum type,
bool cleared) {
DCHECK(info);
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
DCHECK_NE(0, num_unrenderable_textures_);
--num_unrenderable_textures_;
}
@@ -775,13 +775,13 @@ void TextureManager::SetLevelInfo(
DCHECK_GE(num_uncleared_mips_, 0);
mem_represented_ -= info->estimated_size();
info->SetLevelInfo(
- feature_info, target, level, internal_format, width, height, depth,
+ feature_info_, target, level, internal_format, width, height, depth,
border, format, type, cleared);
mem_represented_ += info->estimated_size();
UpdateMemRepresented();
num_uncleared_mips_ += info->num_uncleared_mips();
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
++num_unrenderable_textures_;
}
if (!info->SafeToRenderFrom()) {
@@ -790,11 +790,9 @@ void TextureManager::SetLevelInfo(
}
bool TextureManager::SetParameter(
- const FeatureInfo* feature_info,
TextureManager::TextureInfo* info, GLenum pname, GLint param) {
- DCHECK(feature_info);
DCHECK(info);
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
DCHECK_NE(0, num_unrenderable_textures_);
--num_unrenderable_textures_;
}
@@ -802,8 +800,8 @@ bool TextureManager::SetParameter(
DCHECK_NE(0, num_unsafe_textures_);
--num_unsafe_textures_;
}
- bool result = info->SetParameter(feature_info, pname, param);
- if (!info->CanRender(feature_info)) {
+ bool result = info->SetParameter(feature_info_, pname, param);
+ if (!info->CanRender(feature_info_)) {
++num_unrenderable_textures_;
}
if (!info->SafeToRenderFrom()) {
@@ -812,11 +810,9 @@ bool TextureManager::SetParameter(
return result;
}
-bool TextureManager::MarkMipmapsGenerated(
- const FeatureInfo* feature_info,
- TextureManager::TextureInfo* info) {
+bool TextureManager::MarkMipmapsGenerated(TextureManager::TextureInfo* info) {
DCHECK(info);
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
DCHECK_NE(0, num_unrenderable_textures_);
--num_unrenderable_textures_;
}
@@ -827,12 +823,12 @@ bool TextureManager::MarkMipmapsGenerated(
num_uncleared_mips_ -= info->num_uncleared_mips();
DCHECK_GE(num_uncleared_mips_, 0);
mem_represented_ -= info->estimated_size();
- bool result = info->MarkMipmapsGenerated(feature_info);
+ bool result = info->MarkMipmapsGenerated(feature_info_);
mem_represented_ += info->estimated_size();
UpdateMemRepresented();
num_uncleared_mips_ += info->num_uncleared_mips();
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
++num_unrenderable_textures_;
}
if (!info->SafeToRenderFrom()) {
@@ -842,13 +838,13 @@ bool TextureManager::MarkMipmapsGenerated(
}
TextureManager::TextureInfo* TextureManager::CreateTextureInfo(
- const FeatureInfo* feature_info,
GLuint client_id, GLuint service_id) {
- TextureInfo::Ref info(new TextureInfo(service_id));
+ DCHECK_NE(0u, service_id);
+ TextureInfo::Ref info(new TextureInfo(this, service_id));
std::pair<TextureInfoMap::iterator, bool> result =
texture_infos_.insert(std::make_pair(client_id, info));
DCHECK(result.second);
- if (!info->CanRender(feature_info)) {
+ if (!info->CanRender(feature_info_)) {
++num_unrenderable_textures_;
}
if (!info->SafeToRenderFrom()) {
@@ -864,31 +860,30 @@ TextureManager::TextureInfo* TextureManager::GetTextureInfo(
return it != texture_infos_.end() ? it->second : NULL;
}
-void TextureManager::RemoveTextureInfo(
- const FeatureInfo* feature_info, GLuint client_id) {
+void TextureManager::RemoveTextureInfo(GLuint client_id) {
TextureInfoMap::iterator it = texture_infos_.find(client_id);
if (it != texture_infos_.end()) {
TextureInfo* info = it->second;
- if (!info->CanRender(feature_info)) {
- DCHECK_NE(0, num_unrenderable_textures_);
- --num_unrenderable_textures_;
- }
- if (!info->SafeToRenderFrom()) {
- DCHECK_NE(0, num_unsafe_textures_);
- --num_unsafe_textures_;
- }
- num_uncleared_mips_ -= info->num_uncleared_mips();
- DCHECK_GE(num_uncleared_mips_, 0);
info->MarkAsDeleted();
- // TODO(gman): Unforunately the memory does not get de-allocated here as
- // resources are ref counted but for now there's no easy way to track this
- // info past this point.
- mem_represented_ -= info->estimated_size();
- UpdateMemRepresented();
texture_infos_.erase(it);
}
}
+void TextureManager::StopTracking(TextureManager::TextureInfo* texture) {
+ if (!texture->CanRender(feature_info_)) {
+ DCHECK_NE(0, num_unrenderable_textures_);
+ --num_unrenderable_textures_;
+ }
+ if (!texture->SafeToRenderFrom()) {
+ DCHECK_NE(0, num_unsafe_textures_);
+ --num_unsafe_textures_;
+ }
+ num_uncleared_mips_ -= texture->num_uncleared_mips();
+ DCHECK_GE(num_uncleared_mips_, 0);
+ mem_represented_ -= texture->estimated_size();
+ UpdateMemRepresented();
+}
+
bool TextureManager::GetClientId(GLuint service_id, GLuint* client_id) const {
// This doesn't need to be fast. It's only used during slow queries.
for (TextureInfoMap::const_iterator it = texture_infos_.begin();
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index b98014e..ddbd7fa 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,12 +10,12 @@
#include "base/hash_tables.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gl_utils.h"
namespace gpu {
namespace gles2 {
-class FeatureInfo;
class GLES2Decoder;
// This class keeps track of the textures and their sizes so we can do NPOT and
@@ -38,8 +38,9 @@ class TextureManager {
public:
typedef scoped_refptr<TextureInfo> Ref;
- explicit TextureInfo(GLuint service_id)
- : service_id_(service_id),
+ TextureInfo(TextureManager* manager, GLuint service_id)
+ : manager_(manager),
+ service_id_(service_id),
deleted_(false),
cleared_(true),
num_uncleared_mips_(0),
@@ -89,10 +90,6 @@ class TextureManager {
return estimated_size_;
}
- // True if this texture meets all the GLES2 criteria for rendering.
- // See section 3.8.2 of the GLES2 spec.
- bool CanRender(const FeatureInfo* feature_info) const;
-
bool CanRenderTo() const {
return !stream_texture_ && target_ != GL_TEXTURE_EXTERNAL_OES;
}
@@ -131,9 +128,6 @@ class TextureManager {
return cleared_;
}
- // Returns true if mipmaps can be generated by GL.
- bool CanGenerateMipmaps(const FeatureInfo* feature_info) const;
-
// Get the width and height for a particular level. Returns false if level
// does not exist.
bool GetLevelSize(
@@ -204,7 +198,7 @@ class TextureManager {
friend class TextureManager;
friend class base::RefCounted<TextureInfo>;
- ~TextureInfo() { }
+ ~TextureInfo();
struct LevelInfo {
LevelInfo()
@@ -269,7 +263,7 @@ class TextureManager {
const FeatureInfo* feature_info, GLenum pname, GLint param);
// Makes each of the mip levels as though they were generated.
- bool MarkMipmapsGenerated( const FeatureInfo* feature_info);
+ bool MarkMipmapsGenerated(const FeatureInfo* feature_info);
void MarkAsDeleted() {
service_id_ = 0;
@@ -280,6 +274,13 @@ class TextureManager {
return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR;
}
+ // True if this texture meets all the GLES2 criteria for rendering.
+ // See section 3.8.2 of the GLES2 spec.
+ bool CanRender(const FeatureInfo* feature_info) const;
+
+ // Returns true if mipmaps can be generated by GL.
+ bool CanGenerateMipmaps(const FeatureInfo* feature_info) const;
+
// Sets the TextureInfo's target
// Parameters:
// target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or
@@ -293,6 +294,9 @@ class TextureManager {
// Info about each face and level of texture.
std::vector<std::vector<LevelInfo> > level_infos_;
+ // The texture manager that manages this TextureInfo.
+ TextureManager* manager_;
+
// The id of the texure
GLuint service_id_;
@@ -349,12 +353,13 @@ class TextureManager {
DISALLOW_COPY_AND_ASSIGN(TextureInfo);
};
- TextureManager(GLsizei max_texture_size,
+ TextureManager(FeatureInfo* feature_info,
+ GLsizei max_texture_size,
GLsizei max_cube_map_texture_size);
~TextureManager();
// Init the texture manager.
- bool Initialize(const FeatureInfo* feature_info);
+ bool Initialize();
// Must call before destruction.
void Destroy(bool have_context);
@@ -388,22 +393,30 @@ class TextureManager {
// Checks if a dimensions are valid for a given target.
bool ValidForTarget(
- const FeatureInfo* feature_info,
GLenum target, GLint level,
GLsizei width, GLsizei height, GLsizei depth);
+ // True if this texture meets all the GLES2 criteria for rendering.
+ // See section 3.8.2 of the GLES2 spec.
+ bool CanRender(const TextureInfo* texture) const {
+ return texture->CanRender(feature_info_);
+ }
+
+ // Returns true if mipmaps can be generated by GL.
+ bool CanGenerateMipmaps(const TextureInfo* texture) const {
+ return texture->CanGenerateMipmaps(feature_info_);
+ }
+
// Sets the TextureInfo's target
// Parameters:
// target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
// max_levels: The maximum levels this type of target can have.
void SetInfoTarget(
- const FeatureInfo* feature_info,
TextureInfo* info,
GLenum target);
// Set the info for a particular level in a TexureInfo.
void SetLevelInfo(
- const FeatureInfo* feature_info,
TextureInfo* info,
GLenum target,
GLint level,
@@ -422,13 +435,11 @@ class TextureManager {
// Sets a texture parameter of a TextureInfo
// TODO(gman): Expand to SetParameteri,f,iv,fv
bool SetParameter(
- const FeatureInfo* feature_info,
TextureInfo* info, GLenum pname, GLint param);
// Makes each of the mip levels as though they were generated.
// Returns false if that's not allowed for the given texture.
- bool MarkMipmapsGenerated(const FeatureInfo* feature_info,
- TextureInfo* info);
+ bool MarkMipmapsGenerated(TextureInfo* info);
// Clears any uncleared renderable levels.
bool ClearRenderableLevels(GLES2Decoder* decoder, TextureInfo* info);
@@ -438,14 +449,13 @@ class TextureManager {
GLES2Decoder* decoder,TextureInfo* info, GLenum target, GLint level);
// Creates a new texture info.
- TextureInfo* CreateTextureInfo(
- const FeatureInfo* feature_info, GLuint client_id, GLuint service_id);
+ TextureInfo* CreateTextureInfo(GLuint client_id, GLuint service_id);
// Gets the texture info for the given texture.
TextureInfo* GetTextureInfo(GLuint client_id);
// Removes a texture info.
- void RemoveTextureInfo(const FeatureInfo* feature_info, GLuint client_id);
+ void RemoveTextureInfo(GLuint client_id);
// Gets a client id for a given service id.
bool GetClientId(GLuint service_id, GLuint* client_id) const;
@@ -497,12 +507,15 @@ class TextureManager {
private:
// Helper for Initialize().
TextureInfo::Ref CreateDefaultAndBlackTextures(
- const FeatureInfo* feature_info,
GLenum target,
GLuint* black_texture);
void UpdateMemRepresented();
+ void StopTracking(TextureInfo* info);
+
+ FeatureInfo::Ref feature_info_;
+
// Info for each texture in the system.
typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap;
TextureInfoMap texture_infos_;
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index 3144665..edde5c5 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -28,7 +28,8 @@ class TextureManagerTest : public testing::Test {
static const GLint kMaxExternalLevels = 1;
TextureManagerTest()
- : manager_(kMaxTextureSize, kMaxCubeMapTextureSize) {
+ : feature_info_(new FeatureInfo()),
+ manager_(feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize) {
}
~TextureManagerTest() {
@@ -41,7 +42,7 @@ class TextureManagerTest : public testing::Test {
::gfx::GLInterface::SetGLInterface(gl_.get());
TestHelper::SetupTextureManagerInitExpectations(gl_.get(), "");
- manager_.Initialize(&feature_info_);
+ manager_.Initialize();
}
virtual void TearDown() {
@@ -51,8 +52,8 @@ class TextureManagerTest : public testing::Test {
// Use StrictMock to make 100% sure we know how GL will be called.
scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
+ FeatureInfo::Ref feature_info_;
TextureManager manager_;
- FeatureInfo feature_info_;
};
// GCC requires these declarations, but MSVC requires they not be present
@@ -73,7 +74,7 @@ TEST_F(TextureManagerTest, Basic) {
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
// Check we can create texture.
- manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
+ manager_.CreateTextureInfo(kClient1Id, kService1Id);
// Check texture got created.
TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info1 != NULL);
@@ -84,9 +85,9 @@ TEST_F(TextureManagerTest, Basic) {
// Check we get nothing for a non-existent texture.
EXPECT_TRUE(manager_.GetTextureInfo(kClient2Id) == NULL);
// Check trying to a remove non-existent textures does not crash.
- manager_.RemoveTextureInfo(&feature_info_, kClient2Id);
+ manager_.RemoveTextureInfo(kClient2Id);
// Check we can't get the texture after we remove it.
- manager_.RemoveTextureInfo(&feature_info_, kClient1Id);
+ manager_.RemoveTextureInfo(kClient1Id);
EXPECT_TRUE(manager_.GetTextureInfo(kClient1Id) == NULL);
}
@@ -94,51 +95,45 @@ TEST_F(TextureManagerTest, SetParameter) {
const GLuint kClient1Id = 1;
const GLuint kService1Id = 11;
// Check we can create texture.
- manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
+ manager_.CreateTextureInfo(kClient1Id, kService1Id);
// Check texture got created.
TextureManager::TextureInfo* info = manager_.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
- EXPECT_TRUE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
+ EXPECT_TRUE(manager_.SetParameter(info, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
EXPECT_EQ(static_cast<GLenum>(GL_NEAREST), info->min_filter());
- EXPECT_TRUE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
+ EXPECT_TRUE(manager_.SetParameter(info, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
EXPECT_EQ(static_cast<GLenum>(GL_NEAREST), info->mag_filter());
- EXPECT_TRUE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
+ EXPECT_TRUE(manager_.SetParameter(info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
EXPECT_EQ(static_cast<GLenum>(GL_CLAMP_TO_EDGE), info->wrap_s());
- EXPECT_TRUE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
+ EXPECT_TRUE(manager_.SetParameter(info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
EXPECT_EQ(static_cast<GLenum>(GL_CLAMP_TO_EDGE), info->wrap_t());
EXPECT_FALSE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_MIN_FILTER, GL_CLAMP_TO_EDGE));
+ info, GL_TEXTURE_MIN_FILTER, GL_CLAMP_TO_EDGE));
EXPECT_EQ(static_cast<GLenum>(GL_NEAREST), info->min_filter());
EXPECT_FALSE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_MAG_FILTER, GL_CLAMP_TO_EDGE));
+ info, GL_TEXTURE_MAG_FILTER, GL_CLAMP_TO_EDGE));
EXPECT_EQ(static_cast<GLenum>(GL_NEAREST), info->min_filter());
- EXPECT_FALSE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_WRAP_S, GL_NEAREST));
+ EXPECT_FALSE(manager_.SetParameter(info, GL_TEXTURE_WRAP_S, GL_NEAREST));
EXPECT_EQ(static_cast<GLenum>(GL_CLAMP_TO_EDGE), info->wrap_s());
- EXPECT_FALSE(manager_.SetParameter(
- &feature_info_, info, GL_TEXTURE_WRAP_T, GL_NEAREST));
+ EXPECT_FALSE(manager_.SetParameter(info, GL_TEXTURE_WRAP_T, GL_NEAREST));
EXPECT_EQ(static_cast<GLenum>(GL_CLAMP_TO_EDGE), info->wrap_t());
}
TEST_F(TextureManagerTest, TextureUsageExt) {
TestHelper::SetupTextureManagerInitExpectations(gl_.get(),
"GL_ANGLE_texture_usage");
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
- manager.Initialize(&feature_info_);
+ TextureManager manager(
+ feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.Initialize();
const GLuint kClient1Id = 1;
const GLuint kService1Id = 11;
// Check we can create texture.
- manager.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
// Check texture got created.
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
EXPECT_TRUE(manager.SetParameter(
- &feature_info_, info, GL_TEXTURE_USAGE_ANGLE,
- GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
+ info, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_ATTACHMENT_ANGLE),
info->usage());
manager.Destroy(false);
@@ -148,10 +143,11 @@ TEST_F(TextureManagerTest, Destroy) {
const GLuint kClient1Id = 1;
const GLuint kService1Id = 11;
TestHelper::SetupTextureManagerInitExpectations(gl_.get(), "");
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
- manager.Initialize(&feature_info_);
+ TextureManager manager(
+ feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.Initialize();
// Check we can create texture.
- manager.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
// Check texture got created.
TextureManager::TextureInfo* info1 = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info1 != NULL);
@@ -171,11 +167,12 @@ TEST_F(TextureManagerTest, DestroyUnowned) {
const GLuint kClient1Id = 1;
const GLuint kService1Id = 11;
TestHelper::SetupTextureManagerInitExpectations(gl_.get(), "");
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
- manager.Initialize(&feature_info_);
+ TextureManager manager(
+ feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.Initialize();
// Check we can create texture.
TextureManager::TextureInfo* created_info =
- manager.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
created_info->SetNotOwned();
// Check texture got created.
@@ -232,73 +229,64 @@ TEST_F(TextureManagerTest, MaxValues) {
TEST_F(TextureManagerTest, ValidForTarget) {
// check 2d
EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, 0,
- kMaxTextureSize, kMaxTextureSize, 1));
+ GL_TEXTURE_2D, 0, kMaxTextureSize, kMaxTextureSize, 1));
EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, kMax2dLevels - 1,
- kMaxTextureSize, kMaxTextureSize, 1));
+ GL_TEXTURE_2D, kMax2dLevels - 1, kMaxTextureSize, kMaxTextureSize, 1));
EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, kMax2dLevels - 1,
- 1, kMaxTextureSize, 1));
+ GL_TEXTURE_2D, kMax2dLevels - 1, 1, kMaxTextureSize, 1));
EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, kMax2dLevels - 1,
- kMaxTextureSize, 1, 1));
+ GL_TEXTURE_2D, kMax2dLevels - 1, kMaxTextureSize, 1, 1));
// check level out of range.
EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, kMax2dLevels,
- kMaxTextureSize, 1, 1));
+ GL_TEXTURE_2D, kMax2dLevels, kMaxTextureSize, 1, 1));
// check has depth.
EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, kMax2dLevels,
- kMaxTextureSize, 1, 2));
+ GL_TEXTURE_2D, kMax2dLevels, kMaxTextureSize, 1, 2));
// Check NPOT width on level 0
- EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, 0, 5, 2, 1));
+ EXPECT_TRUE(manager_.ValidForTarget(GL_TEXTURE_2D, 0, 5, 2, 1));
// Check NPOT height on level 0
- EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, 0, 2, 5, 1));
+ EXPECT_TRUE(manager_.ValidForTarget(GL_TEXTURE_2D, 0, 2, 5, 1));
// Check NPOT width on level 1
- EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, 1, 5, 2, 1));
+ EXPECT_FALSE(manager_.ValidForTarget(GL_TEXTURE_2D, 1, 5, 2, 1));
// Check NPOT height on level 1
- EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_2D, 1, 2, 5, 1));
+ EXPECT_FALSE(manager_.ValidForTarget(GL_TEXTURE_2D, 1, 2, 5, 1));
// check cube
EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_CUBE_MAP, 0,
+ GL_TEXTURE_CUBE_MAP, 0,
kMaxCubeMapTextureSize, kMaxCubeMapTextureSize, 1));
EXPECT_TRUE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels - 1,
+ GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels - 1,
kMaxCubeMapTextureSize, kMaxCubeMapTextureSize, 1));
// check level out of range.
EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels,
+ GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels,
kMaxCubeMapTextureSize, 1, 1));
// check not square.
EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels,
+ GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels,
kMaxCubeMapTextureSize, 1, 1));
// check has depth.
EXPECT_FALSE(manager_.ValidForTarget(
- &feature_info_, GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels,
+ GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels,
kMaxCubeMapTextureSize, 1, 2));
}
TEST_F(TextureManagerTest, ValidForTargetNPOT) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_texture_npot");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
// Check NPOT width on level 0
- EXPECT_TRUE(manager.ValidForTarget(&feature_info, GL_TEXTURE_2D, 0, 5, 2, 1));
+ EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 0, 5, 2, 1));
// Check NPOT height on level 0
- EXPECT_TRUE(manager.ValidForTarget(&feature_info, GL_TEXTURE_2D, 0, 2, 5, 1));
+ EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 0, 2, 5, 1));
// Check NPOT width on level 1
- EXPECT_TRUE(manager.ValidForTarget(&feature_info, GL_TEXTURE_2D, 1, 5, 2, 1));
+ EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 5, 2, 1));
// Check NPOT height on level 1
- EXPECT_TRUE(manager.ValidForTarget(&feature_info, GL_TEXTURE_2D, 1, 2, 5, 1));
+ EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 2, 5, 1));
manager.Destroy(false);
}
@@ -312,9 +300,11 @@ class TextureInfoTest : public testing::Test {
static const GLuint kService1Id = 11;
TextureInfoTest()
- : manager_(kMaxTextureSize, kMaxCubeMapTextureSize) {
+ : feature_info_(new FeatureInfo()),
+ manager_(feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize) {
}
~TextureInfoTest() {
+ info_ = NULL;
manager_.Destroy(false);
}
@@ -322,7 +312,7 @@ class TextureInfoTest : public testing::Test {
virtual void SetUp() {
gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
::gfx::GLInterface::SetGLInterface(gl_.get());
- manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
+ manager_.CreateTextureInfo(kClient1Id, kService1Id);
info_ = manager_.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info_.get() != NULL);
}
@@ -335,19 +325,19 @@ class TextureInfoTest : public testing::Test {
// Use StrictMock to make 100% sure we know how GL will be called.
scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
+ FeatureInfo::Ref feature_info_;
TextureManager manager_;
TextureManager::TextureInfo::Ref info_;
- FeatureInfo feature_info_;
};
TEST_F(TextureInfoTest, Basic) {
EXPECT_EQ(0u, info_->target());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
EXPECT_FALSE(info_->npot());
EXPECT_EQ(0, info_->num_uncleared_mips());
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(info_->SafeToRenderFrom());
EXPECT_FALSE(info_->IsImmutable());
EXPECT_EQ(static_cast<GLenum>(GL_NEAREST_MIPMAP_LINEAR), info_->min_filter());
@@ -360,236 +350,232 @@ TEST_F(TextureInfoTest, Basic) {
}
TEST_F(TextureInfoTest, EstimatedSize) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_EQ(8u * 4u * 4u, info_->estimated_size());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 2, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_EQ(8u * 4u * 4u * 2u, info_->estimated_size());
}
TEST_F(TextureInfoTest, POT2D) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target());
// Check Setting level 0 to POT
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_EQ(0, info_->num_uncleared_mips());
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
// Set filters to something that will work with a single mip.
- manager_.SetParameter(
- &feature_info_, info_, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ manager_.SetParameter(info_, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
// Set them back.
- manager_.SetParameter(
- &feature_info_, info_, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ manager_.SetParameter(info_, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
// Make mips.
- EXPECT_TRUE(manager_.MarkMipmapsGenerated(&feature_info_, info_));
+ EXPECT_TRUE(manager_.MarkMipmapsGenerated(info_));
EXPECT_TRUE(info_->texture_complete());
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
// Change a mip.
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
// Set a level past the number of mips that would get generated.
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
// Make mips.
- EXPECT_TRUE(manager_.MarkMipmapsGenerated(&feature_info_, info_));
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.MarkMipmapsGenerated(info_));
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_TRUE(info_->texture_complete());
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
}
TEST_F(TextureInfoTest, UnusedMips) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target());
// Set level zero to large size.
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_.MarkMipmapsGenerated(&feature_info_, info_));
+ EXPECT_TRUE(manager_.MarkMipmapsGenerated(info_));
EXPECT_FALSE(info_->npot());
EXPECT_TRUE(info_->texture_complete());
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
// Set level zero to large smaller (levels unused mips)
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_.MarkMipmapsGenerated(&feature_info_, info_));
+ EXPECT_TRUE(manager_.MarkMipmapsGenerated(info_));
EXPECT_FALSE(info_->npot());
EXPECT_TRUE(info_->texture_complete());
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
// Set an unused level to some size
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 4, GL_RGBA, 16, 16, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_TRUE(info_->texture_complete());
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
}
TEST_F(TextureInfoTest, NPOT2D) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target());
// Check Setting level 0 to NPOT
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_TRUE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetParameter(
- &feature_info_, info_, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ manager_.SetParameter(info_, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetParameter(
- &feature_info_, info_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ manager_.SetParameter(info_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetParameter(
- &feature_info_, info_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ manager_.SetParameter(info_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
// Change it to POT.
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
}
TEST_F(TextureInfoTest, NPOT2DNPOTOK) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_texture_npot");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
- manager.CreateTextureInfo(&feature_info, kClient1Id, kService1Id);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info_ != NULL);
- manager.SetInfoTarget(&feature_info_, info, GL_TEXTURE_2D);
+ manager.SetInfoTarget(info, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info->target());
// Check Setting level 0 to NPOT
- manager.SetLevelInfo(&feature_info, info,
+ manager.SetLevelInfo(info,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_TRUE(info->npot());
EXPECT_FALSE(info->texture_complete());
- EXPECT_TRUE(info->CanGenerateMipmaps(&feature_info));
- EXPECT_FALSE(info->CanRender(&feature_info));
+ EXPECT_TRUE(manager.CanGenerateMipmaps(info));
+ EXPECT_FALSE(manager.CanRender(info));
EXPECT_TRUE(manager.HaveUnrenderableTextures());
- EXPECT_TRUE(manager.MarkMipmapsGenerated(&feature_info, info));
+ EXPECT_TRUE(manager.MarkMipmapsGenerated(info));
EXPECT_TRUE(info->texture_complete());
- EXPECT_TRUE(info->CanRender(&feature_info));
+ EXPECT_TRUE(manager.CanRender(info));
EXPECT_FALSE(manager.HaveUnrenderableTextures());
manager.Destroy(false);
}
TEST_F(TextureInfoTest, POTCubeMap) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_CUBE_MAP);
+ manager_.SetInfoTarget(info_, GL_TEXTURE_CUBE_MAP);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), info_->target());
// Check Setting level 0 each face to POT
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
- EXPECT_FALSE(info_->CanRender(&feature_info_));
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
- EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_FALSE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
- EXPECT_FALSE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
+ EXPECT_FALSE(manager_.CanRender(info_));
EXPECT_TRUE(manager_.HaveUnrenderableTextures());
// Make mips.
- EXPECT_TRUE(manager_.MarkMipmapsGenerated(&feature_info_, info_));
+ EXPECT_TRUE(manager_.MarkMipmapsGenerated(info_));
EXPECT_TRUE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
- EXPECT_TRUE(info_->CanRender(&feature_info_));
+ EXPECT_TRUE(manager_.CanRender(info_));
EXPECT_FALSE(manager_.HaveUnrenderableTextures());
// Change a mip.
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
// Set a level past the number of mips that would get generated.
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
3, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(info_->CanGenerateMipmaps(&feature_info_));
+ EXPECT_TRUE(manager_.CanGenerateMipmaps(info_));
// Make mips.
- EXPECT_TRUE(manager_.MarkMipmapsGenerated(&feature_info_, info_));
+ EXPECT_TRUE(manager_.MarkMipmapsGenerated(info_));
EXPECT_TRUE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
}
TEST_F(TextureInfoTest, GetLevelSize) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
GLsizei width = -1;
GLsizei height = -1;
@@ -599,15 +585,15 @@ TEST_F(TextureInfoTest, GetLevelSize) {
EXPECT_TRUE(info_->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
EXPECT_EQ(4, width);
EXPECT_EQ(5, height);
- manager_.RemoveTextureInfo(&feature_info_, kClient1Id);
+ manager_.RemoveTextureInfo(kClient1Id);
EXPECT_TRUE(info_->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
EXPECT_EQ(4, width);
EXPECT_EQ(5, height);
}
TEST_F(TextureInfoTest, GetLevelType) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
GLenum type = -1;
GLenum format = -1;
@@ -617,15 +603,15 @@ TEST_F(TextureInfoTest, GetLevelType) {
EXPECT_TRUE(info_->GetLevelType(GL_TEXTURE_2D, 1, &type, &format));
EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
EXPECT_EQ(static_cast<GLenum>(GL_RGBA), format);
- manager_.RemoveTextureInfo(&feature_info_, kClient1Id);
+ manager_.RemoveTextureInfo(kClient1Id);
EXPECT_TRUE(info_->GetLevelType(GL_TEXTURE_2D, 1, &type, &format));
EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
EXPECT_EQ(static_cast<GLenum>(GL_RGBA), format);
}
TEST_F(TextureInfoTest, ValidForTexture) {
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
// Check bad face.
EXPECT_FALSE(info_->ValidForTexture(
@@ -664,101 +650,104 @@ TEST_F(TextureInfoTest, ValidForTexture) {
// Check valid particial size.
EXPECT_TRUE(info_->ValidForTexture(
GL_TEXTURE_2D, 1, 1, 1, 2, 3, GL_RGBA, GL_UNSIGNED_BYTE));
- manager_.RemoveTextureInfo(&feature_info_, kClient1Id);
+ manager_.RemoveTextureInfo(kClient1Id);
EXPECT_TRUE(info_->ValidForTexture(
GL_TEXTURE_2D, 1, 0, 0, 4, 5, GL_RGBA, GL_UNSIGNED_BYTE));
}
TEST_F(TextureInfoTest, FloatNotLinear) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_texture_float");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
- manager.CreateTextureInfo(&feature_info, kClient1Id, kService1Id);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
- manager.SetInfoTarget(&feature_info_, info, GL_TEXTURE_2D);
+ manager.SetInfoTarget(info, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info->target());
- manager.SetLevelInfo(&feature_info, info,
+ manager.SetLevelInfo(info,
GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_FLOAT, true);
EXPECT_FALSE(info->texture_complete());
- manager.SetParameter(&feature_info, info, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ manager.SetParameter(info, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
EXPECT_FALSE(info->texture_complete());
- manager.SetParameter(
- &feature_info, info, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
+ manager.SetParameter(info, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
EXPECT_TRUE(info->texture_complete());
manager.Destroy(false);
}
TEST_F(TextureInfoTest, FloatLinear) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_texture_float GL_OES_texture_float_linear");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
- manager.CreateTextureInfo(&feature_info, kClient1Id, kService1Id);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
- manager.SetInfoTarget(&feature_info_, info, GL_TEXTURE_2D);
+ manager.SetInfoTarget(info, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info->target());
- manager.SetLevelInfo(&feature_info, info,
+ manager.SetLevelInfo(info,
GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_FLOAT, true);
EXPECT_TRUE(info->texture_complete());
manager.Destroy(false);
}
TEST_F(TextureInfoTest, HalfFloatNotLinear) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_texture_half_float");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
- manager.CreateTextureInfo(&feature_info, kClient1Id, kService1Id);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
- manager.SetInfoTarget(&feature_info_, info, GL_TEXTURE_2D);
+ manager.SetInfoTarget(info, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info->target());
- manager.SetLevelInfo(&feature_info, info,
+ manager.SetLevelInfo(info,
GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES, true);
EXPECT_FALSE(info->texture_complete());
- manager.SetParameter(&feature_info, info, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ manager.SetParameter(info, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
EXPECT_FALSE(info->texture_complete());
- manager.SetParameter(
- &feature_info, info, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
+ manager.SetParameter(info, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
EXPECT_TRUE(info->texture_complete());
manager.Destroy(false);
}
TEST_F(TextureInfoTest, HalfFloatLinear) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_texture_half_float GL_OES_texture_half_float_linear");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
- manager.CreateTextureInfo(&feature_info, kClient1Id, kService1Id);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
- manager.SetInfoTarget(&feature_info_, info, GL_TEXTURE_2D);
+ manager.SetInfoTarget(info, GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info->target());
- manager.SetLevelInfo(&feature_info, info,
+ manager.SetLevelInfo(info,
GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES, true);
EXPECT_TRUE(info->texture_complete());
manager.Destroy(false);
}
TEST_F(TextureInfoTest, EGLImageExternal) {
- TextureManager manager(kMaxTextureSize, kMaxCubeMapTextureSize);
TestHelper::SetupFeatureInfoInitExpectations(
gl_.get(), "GL_OES_EGL_image_external");
- FeatureInfo feature_info;
- feature_info.Initialize(NULL);
- manager.CreateTextureInfo(&feature_info, kClient1Id, kService1Id);
+ FeatureInfo::Ref feature_info(new FeatureInfo());
+ feature_info->Initialize(NULL);
+ TextureManager manager(
+ feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
+ manager.CreateTextureInfo(kClient1Id, kService1Id);
TextureManager::TextureInfo* info = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info != NULL);
- manager.SetInfoTarget(&feature_info_, info, GL_TEXTURE_EXTERNAL_OES);
+ manager.SetInfoTarget(info, GL_TEXTURE_EXTERNAL_OES);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), info->target());
- EXPECT_FALSE(info->CanGenerateMipmaps(&feature_info));
+ EXPECT_FALSE(manager.CanGenerateMipmaps(info));
manager.Destroy(false);
}
@@ -769,8 +758,8 @@ TEST_F(TextureInfoTest, SafeUnsafe) {
static const GLuint kService3Id = 13;
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info_->num_uncleared_mips());
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_FALSE(info_->SafeToRenderFrom());
EXPECT_TRUE(manager_.HaveUnsafeTextures());
@@ -781,7 +770,7 @@ TEST_F(TextureInfoTest, SafeUnsafe) {
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info_->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_FALSE(info_->SafeToRenderFrom());
EXPECT_TRUE(manager_.HaveUnsafeTextures());
@@ -792,9 +781,9 @@ TEST_F(TextureInfoTest, SafeUnsafe) {
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info_->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_FALSE(info_->SafeToRenderFrom());
EXPECT_TRUE(manager_.HaveUnsafeTextures());
@@ -810,41 +799,41 @@ TEST_F(TextureInfoTest, SafeUnsafe) {
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info_->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_FALSE(info_->SafeToRenderFrom());
EXPECT_TRUE(manager_.HaveUnsafeTextures());
EXPECT_TRUE(manager_.HaveUnclearedMips());
EXPECT_EQ(1, info_->num_uncleared_mips());
- manager_.MarkMipmapsGenerated(&feature_info_, info_);
+ manager_.MarkMipmapsGenerated(info_);
EXPECT_TRUE(info_->SafeToRenderFrom());
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info_->num_uncleared_mips());
- manager_.CreateTextureInfo(&feature_info_, kClient2Id, kService2Id);
+ manager_.CreateTextureInfo(kClient2Id, kService2Id);
TextureManager::TextureInfo::Ref info2 = manager_.GetTextureInfo(kClient2Id);
ASSERT_TRUE(info2.get() != NULL);
- manager_.SetInfoTarget(&feature_info_, info2, GL_TEXTURE_2D);
+ manager_.SetInfoTarget(info2, GL_TEXTURE_2D);
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info2->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info2,
+ manager_.SetLevelInfo(info2,
GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info2->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info2,
+ manager_.SetLevelInfo(info2,
GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_TRUE(manager_.HaveUnsafeTextures());
EXPECT_TRUE(manager_.HaveUnclearedMips());
EXPECT_EQ(1, info2->num_uncleared_mips());
- manager_.CreateTextureInfo(&feature_info_, kClient3Id, kService3Id);
+ manager_.CreateTextureInfo(kClient3Id, kService3Id);
TextureManager::TextureInfo::Ref info3 = manager_.GetTextureInfo(kClient3Id);
ASSERT_TRUE(info3.get() != NULL);
- manager_.SetInfoTarget(&feature_info_, info3, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info3,
+ manager_.SetInfoTarget(info3, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info3,
GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_TRUE(manager_.HaveUnsafeTextures());
EXPECT_TRUE(manager_.HaveUnclearedMips());
@@ -858,18 +847,24 @@ TEST_F(TextureInfoTest, SafeUnsafe) {
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info3->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info2,
+ manager_.SetLevelInfo(info2,
GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_.SetLevelInfo(&feature_info_, info3,
+ manager_.SetLevelInfo(info3,
GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_TRUE(manager_.HaveUnsafeTextures());
EXPECT_TRUE(manager_.HaveUnclearedMips());
EXPECT_EQ(1, info2->num_uncleared_mips());
EXPECT_EQ(1, info3->num_uncleared_mips());
- manager_.RemoveTextureInfo(&feature_info_, kClient3Id);
+ manager_.RemoveTextureInfo(kClient3Id);
EXPECT_TRUE(manager_.HaveUnsafeTextures());
EXPECT_TRUE(manager_.HaveUnclearedMips());
- manager_.RemoveTextureInfo(&feature_info_, kClient2Id);
+ manager_.RemoveTextureInfo(kClient2Id);
+ EXPECT_TRUE(manager_.HaveUnsafeTextures());
+ EXPECT_TRUE(manager_.HaveUnclearedMips());
+ info2 = NULL;
+ EXPECT_TRUE(manager_.HaveUnsafeTextures());
+ EXPECT_TRUE(manager_.HaveUnclearedMips());
+ info3 = NULL;
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
}
@@ -878,10 +873,10 @@ TEST_F(TextureInfoTest, ClearTexture) {
scoped_ptr<MockGLES2Decoder> decoder(new gles2::MockGLES2Decoder());
EXPECT_CALL(*decoder, ClearLevel(_, _, _, _, _, _, _, _, _))
.WillRepeatedly(Return(true));
- manager_.SetInfoTarget(&feature_info_, info_, GL_TEXTURE_2D);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_FALSE(info_->SafeToRenderFrom());
EXPECT_TRUE(manager_.HaveUnsafeTextures());
@@ -892,9 +887,9 @@ TEST_F(TextureInfoTest, ClearTexture) {
EXPECT_FALSE(manager_.HaveUnsafeTextures());
EXPECT_FALSE(manager_.HaveUnclearedMips());
EXPECT_EQ(0, info_->num_uncleared_mips());
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_.SetLevelInfo(&feature_info_, info_,
+ manager_.SetLevelInfo(info_,
GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
EXPECT_FALSE(info_->SafeToRenderFrom());
EXPECT_TRUE(manager_.HaveUnsafeTextures());
@@ -912,6 +907,32 @@ TEST_F(TextureInfoTest, ClearTexture) {
EXPECT_EQ(0, info_->num_uncleared_mips());
}
+TEST_F(TextureInfoTest, UseDeletedTexture) {
+ static const GLuint kClient2Id = 2;
+ static const GLuint kService2Id = 12;
+ // Make the default texture renderable
+ manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
+ manager_.SetLevelInfo(info_,
+ GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ EXPECT_FALSE(manager_.HaveUnrenderableTextures());
+ // Make a new texture
+ manager_.CreateTextureInfo(kClient2Id, kService2Id);
+ TextureManager::TextureInfo::Ref info(manager_.GetTextureInfo(kClient2Id));
+ manager_.SetInfoTarget(info, GL_TEXTURE_2D);
+ EXPECT_FALSE(manager_.CanRender(info));
+ EXPECT_TRUE(manager_.HaveUnrenderableTextures());
+ // Remove it.
+ manager_.RemoveTextureInfo(kClient2Id);
+ EXPECT_FALSE(manager_.CanRender(info));
+ EXPECT_TRUE(manager_.HaveUnrenderableTextures());
+ // Check that we can still manipulate it and it effects the manager.
+ manager_.SetLevelInfo(info,
+ GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ EXPECT_TRUE(manager_.CanRender(info));
+ EXPECT_FALSE(manager_.HaveUnrenderableTextures());
+ info = NULL;
+}
+
} // namespace gles2
} // namespace gpu