summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-02 21:11:11 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-02 21:11:11 +0000
commit7cd76fded67d66fb8ea4f5abce5241ad71d749a9 (patch)
treed7be48ee983fdd925b126b4c8aa96cb862e203f6
parente78b292f9d23695274caabc41516e2ba670ff68d (diff)
downloadchromium_src-7cd76fded67d66fb8ea4f5abce5241ad71d749a9.zip
chromium_src-7cd76fded67d66fb8ea4f5abce5241ad71d749a9.tar.gz
chromium_src-7cd76fded67d66fb8ea4f5abce5241ad71d749a9.tar.bz2
Update gpu/ to use scoped_refptr<T>::get() rather than implicit "operator T*"
Linux fixes BUG=110610 TBR=darin Review URL: https://chromiumcodereview.appspot.com/16293004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203623 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc29
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_delegate_share_group.cc20
-rw-r--r--gpu/command_buffer/service/buffer_manager.cc2
-rw-r--r--gpu/command_buffer/service/buffer_manager_unittest.cc15
-rw-r--r--gpu/command_buffer/service/context_group.cc11
-rw-r--r--gpu/command_buffer/service/context_state.cc33
-rw-r--r--gpu/command_buffer/service/context_state.h6
-rw-r--r--gpu/command_buffer/service/framebuffer_manager.cc38
-rw-r--r--gpu/command_buffer/service/framebuffer_manager_unittest.cc144
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc260
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc50
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc2
-rw-r--r--gpu/command_buffer/service/gpu_tracer.cc6
-rw-r--r--gpu/command_buffer/service/image_manager.cc2
-rw-r--r--gpu/command_buffer/service/memory_program_cache.cc2
-rw-r--r--gpu/command_buffer/service/program_manager.cc34
-rw-r--r--gpu/command_buffer/service/program_manager_unittest.cc14
-rw-r--r--gpu/command_buffer/service/query_manager.cc4
-rw-r--r--gpu/command_buffer/service/renderbuffer_manager.cc2
-rw-r--r--gpu/command_buffer/service/renderbuffer_manager_unittest.cc35
-rw-r--r--gpu/command_buffer/service/shader_manager.cc4
-rw-r--r--gpu/command_buffer/service/shader_manager_unittest.cc14
-rw-r--r--gpu/command_buffer/service/texture_manager.cc83
-rw-r--r--gpu/command_buffer/service/texture_manager.h12
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc1152
-rw-r--r--gpu/command_buffer/service/vertex_array_manager.cc2
-rw-r--r--gpu/command_buffer/service/vertex_attrib_manager.cc6
-rw-r--r--gpu/command_buffer/service/vertex_attrib_manager.h8
-rw-r--r--gpu/command_buffer/tests/gl_gpu_memory_buffer_unittests.cc10
-rw-r--r--gpu/config/gpu_control_list.cc6
-rw-r--r--gpu/config/gpu_control_list_entry_unittest.cc61
-rw-r--r--gpu/config/gpu_info_collector.cc8
-rw-r--r--gpu/gles2_conform_support/egl/display.cc2
33 files changed, 1348 insertions, 729 deletions
diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc b/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc
index 246acb4..b1d3f12 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc
@@ -93,16 +93,15 @@ class TransferThread : public base::Thread {
bool software = false;
surface_ = new gfx::PbufferGLSurfaceEGL(software, gfx::Size(1,1));
surface_->Initialize();
- context_ = gfx::GLContext::CreateGLContext(share_group,
- surface_,
- gfx::PreferDiscreteGpu);
- bool is_current = context_->MakeCurrent(surface_);
+ context_ = gfx::GLContext::CreateGLContext(
+ share_group, surface_.get(), gfx::PreferDiscreteGpu);
+ bool is_current = context_->MakeCurrent(surface_.get());
DCHECK(is_current);
}
virtual void CleanUp() OVERRIDE {
surface_ = NULL;
- context_->ReleaseCurrent(surface_);
+ context_->ReleaseCurrent(surface_.get());
context_ = NULL;
}
@@ -304,7 +303,7 @@ class TransferStateInternal
AsyncPixelTransferDelegate::GetAddress(safe_shared_memory, mem_params);
base::TimeTicks begin_time;
- if (texture_upload_stats)
+ if (texture_upload_stats.get())
begin_time = base::TimeTicks::HighResNow();
if (!thread_texture_id_) {
@@ -325,7 +324,7 @@ class TransferStateInternal
MarkAsCompleted();
DCHECK(CHECK_GL());
- if (texture_upload_stats) {
+ if (texture_upload_stats.get()) {
texture_upload_stats->AddUpload(base::TimeTicks::HighResNow() -
begin_time);
}
@@ -495,7 +494,7 @@ void AsyncPixelTransferDelegateEGL::WaitForTransferCompletion(
AsyncPixelTransferState* transfer_state) {
scoped_refptr<TransferStateInternal> state =
static_cast<AsyncTransferStateImpl*>(transfer_state)->internal_.get();
- DCHECK(state);
+ DCHECK(state.get());
DCHECK(state->texture_id_);
if (state->TransferIsInProgress()) {
@@ -526,7 +525,7 @@ void AsyncPixelTransferDelegateEGL::AsyncTexImage2D(
DCHECK(mem_params.shared_memory);
DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
mem_params.shm_size);
- DCHECK(state);
+ DCHECK(state.get());
DCHECK(state->texture_id_);
DCHECK(!state->TransferIsInProgress());
DCHECK_EQ(state->egl_image_, EGL_NO_IMAGE_KHR);
@@ -601,12 +600,12 @@ void AsyncPixelTransferDelegateEGL::AsyncTexSubImage2D(
}
uint32 AsyncPixelTransferDelegateEGL::GetTextureUploadCount() {
- CHECK(texture_upload_stats_);
+ CHECK(texture_upload_stats_.get());
return texture_upload_stats_->GetStats(NULL);
}
base::TimeDelta AsyncPixelTransferDelegateEGL::GetTotalTextureUploadTime() {
- CHECK(texture_upload_stats_);
+ CHECK(texture_upload_stats_.get());
base::TimeDelta total_texture_upload_time;
texture_upload_stats_->GetStats(&total_texture_upload_time);
return total_texture_upload_time;
@@ -731,7 +730,7 @@ bool AsyncPixelTransferDelegateEGL::WorkAroundAsyncTexSubImage2D(
void* data = GetAddress(mem_params);
base::TimeTicks begin_time;
- if (texture_upload_stats_)
+ if (texture_upload_stats_.get())
begin_time = base::TimeTicks::HighResNow();
{
TRACE_EVENT0("gpu", "glTexSubImage2D");
@@ -739,9 +738,9 @@ bool AsyncPixelTransferDelegateEGL::WorkAroundAsyncTexSubImage2D(
// The DCHECKs above verify this is always the same.
DoTexImage2D(state->define_params_, data);
}
- if (texture_upload_stats_) {
- texture_upload_stats_->AddUpload(
- base::TimeTicks::HighResNow() - begin_time);
+ if (texture_upload_stats_.get()) {
+ texture_upload_stats_->AddUpload(base::TimeTicks::HighResNow() -
+ begin_time);
}
DCHECK(CHECK_GL());
diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate_share_group.cc b/gpu/command_buffer/service/async_pixel_transfer_delegate_share_group.cc
index 7a9c1a9..38064d0 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_delegate_share_group.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_delegate_share_group.cc
@@ -86,7 +86,7 @@ class TransferThread : public base::Thread {
}
surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1));
- if (!surface_) {
+ if (!surface_.get()) {
LOG(ERROR) << "Unable to create GLSurface";
caller_wait->Signal();
return;
@@ -97,15 +97,15 @@ class TransferThread : public base::Thread {
// upload (that would hopefully be optimized as a DMA transfer by the
// driver).
context_ = gfx::GLContext::CreateGLContext(parent_context->share_group(),
- surface_,
+ surface_.get(),
gfx::PreferIntegratedGpu);
- if (!context_) {
+ if (!context_.get()) {
LOG(ERROR) << "Unable to create GLContext.";
caller_wait->Signal();
return;
}
- context_->MakeCurrent(surface_);
+ context_->MakeCurrent(surface_.get());
initialized_ = true;
caller_wait->Signal();
}
@@ -229,7 +229,7 @@ class TransferStateInternal
DCHECK_EQ(0, tex_params.level);
base::TimeTicks begin_time;
- if (texture_upload_stats)
+ if (texture_upload_stats.get())
begin_time = base::TimeTicks::HighResNow();
void* data =
@@ -252,7 +252,7 @@ class TransferStateInternal
MarkAsCompleted();
- if (texture_upload_stats) {
+ if (texture_upload_stats.get()) {
texture_upload_stats->AddUpload(base::TimeTicks::HighResNow() -
begin_time);
}
@@ -390,7 +390,7 @@ void AsyncPixelTransferDelegateShareGroup::WaitForTransferCompletion(
AsyncPixelTransferState* transfer_state) {
scoped_refptr<TransferStateInternal> state =
static_cast<AsyncTransferStateImpl*>(transfer_state)->internal();
- DCHECK(state);
+ DCHECK(state.get());
DCHECK(state->texture_id());
if (state->TransferIsInProgress()) {
@@ -417,7 +417,7 @@ void AsyncPixelTransferDelegateShareGroup::AsyncTexImage2D(
DCHECK(mem_params.shared_memory);
DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
mem_params.shm_size);
- DCHECK(state);
+ DCHECK(state.get());
DCHECK(state->texture_id());
DCHECK(!state->TransferIsInProgress());
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), tex_params.target);
@@ -482,13 +482,13 @@ void AsyncPixelTransferDelegateShareGroup::AsyncTexSubImage2D(
}
uint32 AsyncPixelTransferDelegateShareGroup::GetTextureUploadCount() {
- DCHECK(texture_upload_stats_);
+ DCHECK(texture_upload_stats_.get());
return texture_upload_stats_->GetStats(NULL);
}
base::TimeDelta
AsyncPixelTransferDelegateShareGroup::GetTotalTextureUploadTime() {
- DCHECK(texture_upload_stats_);
+ DCHECK(texture_upload_stats_.get());
base::TimeDelta total_texture_upload_time;
texture_upload_stats_->GetStats(&total_texture_upload_time);
return total_texture_upload_time;
diff --git a/gpu/command_buffer/service/buffer_manager.cc b/gpu/command_buffer/service/buffer_manager.cc
index 298b78b..ed4c1f1 100644
--- a/gpu/command_buffer/service/buffer_manager.cc
+++ b/gpu/command_buffer/service/buffer_manager.cc
@@ -56,7 +56,7 @@ Buffer* BufferManager::GetBuffer(
void BufferManager::RemoveBuffer(GLuint client_id) {
BufferMap::iterator it = buffers_.find(client_id);
if (it != buffers_.end()) {
- Buffer* buffer = it->second;
+ Buffer* buffer = it->second.get();
buffer->MarkAsDeleted();
buffers_.erase(it);
}
diff --git a/gpu/command_buffer/service/buffer_manager_unittest.cc b/gpu/command_buffer/service/buffer_manager_unittest.cc
index 72c9175..f6fb838 100644
--- a/gpu/command_buffer/service/buffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/buffer_manager_unittest.cc
@@ -108,11 +108,10 @@ class BufferManagerClientSideArraysTest : public BufferManagerTestBase {
scoped_refptr<FeatureInfo> feature_info_;
};
-#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size, pool) \
- EXPECT_CALL(*mock_memory_tracker_, \
- TrackMemoryAllocatedChange(old_size, new_size, pool)) \
- .Times(1) \
- .RetiresOnSaturation() \
+#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size, pool) \
+ EXPECT_CALL(*mock_memory_tracker_.get(), \
+ TrackMemoryAllocatedChange(old_size, new_size, pool)) \
+ .Times(1).RetiresOnSaturation()
TEST_F(BufferManagerTest, Basic) {
const GLuint kClientBuffer1Id = 1;
@@ -359,12 +358,12 @@ TEST_F(BufferManagerTest, UseDeletedBuffer) {
const uint32 data[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
manager_->CreateBuffer(kClientBufferId, kServiceBufferId);
scoped_refptr<Buffer> buffer = manager_->GetBuffer(kClientBufferId);
- ASSERT_TRUE(buffer != NULL);
- manager_->SetTarget(buffer, GL_ARRAY_BUFFER);
+ ASSERT_TRUE(buffer.get() != NULL);
+ manager_->SetTarget(buffer.get(), GL_ARRAY_BUFFER);
// Remove buffer
manager_->RemoveBuffer(kClientBufferId);
// Use it after removing
- DoBufferData(buffer, sizeof(data), GL_STATIC_DRAW, NULL, GL_NO_ERROR);
+ DoBufferData(buffer.get(), sizeof(data), GL_STATIC_DRAW, NULL, GL_NO_ERROR);
// Check that it gets deleted when the last reference is released.
EXPECT_CALL(*gl_, DeleteBuffersARB(1, ::testing::Pointee(kServiceBufferId)))
.Times(1)
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index 3924465..1b325ef 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -113,13 +113,12 @@ bool ContextGroup::Initialize(
draw_buffer_ = GL_BACK;
}
- buffer_manager_.reset(new BufferManager(
- memory_tracker_, feature_info_.get()));
+ buffer_manager_.reset(
+ new BufferManager(memory_tracker_.get(), feature_info_.get()));
framebuffer_manager_.reset(
new FramebufferManager(max_draw_buffers_, max_color_attachments_));
- renderbuffer_manager_.reset(new RenderbufferManager(memory_tracker_,
- max_renderbuffer_size,
- max_samples));
+ renderbuffer_manager_.reset(new RenderbufferManager(
+ memory_tracker_.get(), max_renderbuffer_size, max_samples));
shader_manager_.reset(new ShaderManager());
program_manager_.reset(new ProgramManager(program_cache_));
@@ -166,7 +165,7 @@ bool ContextGroup::Initialize(
feature_info_->workarounds().max_cube_map_texture_size);
}
- texture_manager_.reset(new TextureManager(memory_tracker_,
+ texture_manager_.reset(new TextureManager(memory_tracker_.get(),
feature_info_.get(),
max_texture_size,
max_cube_map_texture_size));
diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc
index 09f2e1d..7c09786 100644
--- a/gpu/command_buffer/service/context_state.cc
+++ b/gpu/command_buffer/service/context_state.cc
@@ -53,47 +53,50 @@ void ContextState::RestoreTextureUnitBindings(GLuint unit) const {
DCHECK_LT(unit, texture_units.size());
const TextureUnit& texture_unit = texture_units[unit];
glActiveTexture(GL_TEXTURE0 + unit);
- GLuint service_id = texture_unit.bound_texture_2d ?
- texture_unit.bound_texture_2d->service_id() : 0;
+ GLuint service_id = texture_unit.bound_texture_2d.get()
+ ? texture_unit.bound_texture_2d->service_id()
+ : 0;
glBindTexture(GL_TEXTURE_2D, service_id);
- service_id = texture_unit.bound_texture_cube_map ?
- texture_unit.bound_texture_cube_map->service_id() : 0;
+ service_id = texture_unit.bound_texture_cube_map.get()
+ ? texture_unit.bound_texture_cube_map->service_id()
+ : 0;
glBindTexture(GL_TEXTURE_CUBE_MAP, service_id);
if (feature_info_->feature_flags().oes_egl_image_external) {
- service_id = texture_unit.bound_texture_external_oes ?
- texture_unit.bound_texture_external_oes->service_id() : 0;
+ service_id = texture_unit.bound_texture_external_oes.get()
+ ? texture_unit.bound_texture_external_oes->service_id()
+ : 0;
glBindTexture(GL_TEXTURE_EXTERNAL_OES, service_id);
}
if (feature_info_->feature_flags().arb_texture_rectangle) {
- service_id = texture_unit.bound_texture_rectangle_arb ?
- texture_unit.bound_texture_rectangle_arb->service_id() : 0;
+ service_id = texture_unit.bound_texture_rectangle_arb.get()
+ ? texture_unit.bound_texture_rectangle_arb->service_id()
+ : 0;
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, service_id);
}
}
void ContextState::RestoreBufferBindings() const {
- if (vertex_attrib_manager) {
+ if (vertex_attrib_manager.get()) {
Buffer* element_array_buffer =
vertex_attrib_manager->element_array_buffer();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
element_array_buffer ? element_array_buffer->service_id() : 0);
}
- glBindBuffer(
- GL_ARRAY_BUFFER,
- bound_array_buffer ? bound_array_buffer->service_id() : 0);
+ glBindBuffer(GL_ARRAY_BUFFER,
+ bound_array_buffer.get() ? bound_array_buffer->service_id() : 0);
}
void ContextState::RestoreRenderbufferBindings() const {
// Restore Bindings
glBindRenderbufferEXT(
GL_RENDERBUFFER,
- bound_renderbuffer ? bound_renderbuffer->service_id() : 0);
+ bound_renderbuffer.get() ? bound_renderbuffer->service_id() : 0);
}
void ContextState::RestoreProgramBindings() const {
- glUseProgram(current_program ? current_program->service_id() : 0);
+ glUseProgram(current_program.get() ? current_program->service_id() : 0);
}
void ContextState::RestoreActiveTexture() const {
@@ -147,7 +150,7 @@ void ContextState::RestoreState() const {
// Restore Attrib State
// TODO: This if should not be needed. RestoreState is getting called
// before GLES2Decoder::Initialize which is a bug.
- if (vertex_attrib_manager) {
+ if (vertex_attrib_manager.get()) {
// TODO(gman): Move this restoration to VertexAttribManager.
for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();
++attrib) {
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h
index 47f180a..14a6d41 100644
--- a/gpu/command_buffer/service/context_state.h
+++ b/gpu/command_buffer/service/context_state.h
@@ -70,13 +70,13 @@ struct GPU_EXPORT TextureUnit {
}
void Unbind(TextureRef* texture) {
- if (bound_texture_2d == texture) {
+ if (bound_texture_2d.get() == texture) {
bound_texture_2d = NULL;
}
- if (bound_texture_cube_map == texture) {
+ if (bound_texture_cube_map.get() == texture) {
bound_texture_cube_map = NULL;
}
- if (bound_texture_external_oes == texture) {
+ if (bound_texture_external_oes.get() == texture) {
bound_texture_external_oes = NULL;
}
}
diff --git a/gpu/command_buffer/service/framebuffer_manager.cc b/gpu/command_buffer/service/framebuffer_manager.cc
index ce08830..466becc 100644
--- a/gpu/command_buffer/service/framebuffer_manager.cc
+++ b/gpu/command_buffer/service/framebuffer_manager.cc
@@ -67,7 +67,7 @@ class RenderbufferAttachment
RenderbufferManager* renderbuffer_manager,
TextureManager* /* texture_manager */,
bool cleared) OVERRIDE {
- renderbuffer_manager->SetCleared(renderbuffer_, cleared);
+ renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared);
}
virtual bool IsTexture(
@@ -77,7 +77,7 @@ class RenderbufferAttachment
virtual bool IsRenderbuffer(
Renderbuffer* renderbuffer) const OVERRIDE {
- return renderbuffer_ == renderbuffer;
+ return renderbuffer_.get() == renderbuffer;
}
virtual bool CanRenderTo() const OVERRIDE {
@@ -165,7 +165,8 @@ class TextureAttachment
RenderbufferManager* /* renderbuffer_manager */,
TextureManager* texture_manager,
bool cleared) OVERRIDE {
- texture_manager->SetLevelCleared(texture_ref_, target_, level_, cleared);
+ texture_manager->SetLevelCleared(
+ texture_ref_.get(), target_, level_, cleared);
}
virtual bool IsTexture(TextureRef* texture) const OVERRIDE {
@@ -207,7 +208,8 @@ class TextureAttachment
virtual void AddToSignature(
TextureManager* texture_manager, std::string* signature) const OVERRIDE {
DCHECK(signature);
- texture_manager->AddToSignature(texture_ref_, target_, level_, signature);
+ texture_manager->AddToSignature(
+ texture_ref_.get(), target_, level_, signature);
}
protected:
@@ -305,7 +307,7 @@ bool Framebuffer::HasUnclearedAttachment(
AttachmentMap::const_iterator it =
attachments_.find(attachment);
if (it != attachments_.end()) {
- const Attachment* attachment = it->second;
+ const Attachment* attachment = it->second.get();
return !attachment->cleared();
}
return false;
@@ -318,7 +320,7 @@ void Framebuffer::MarkAttachmentAsCleared(
bool cleared) {
AttachmentMap::iterator it = attachments_.find(attachment);
if (it != attachments_.end()) {
- Attachment* a = it->second;
+ Attachment* a = it->second.get();
if (a->cleared() != cleared) {
a->SetCleared(renderbuffer_manager,
texture_manager,
@@ -333,7 +335,7 @@ void Framebuffer::MarkAttachmentsAsCleared(
bool cleared) {
for (AttachmentMap::iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- Attachment* attachment = it->second;
+ Attachment* attachment = it->second.get();
if (attachment->cleared() != cleared) {
attachment->SetCleared(renderbuffer_manager, texture_manager, cleared);
}
@@ -355,7 +357,7 @@ GLenum Framebuffer::GetColorAttachmentFormat() const {
if (it == attachments_.end()) {
return 0;
}
- const Attachment* attachment = it->second;
+ const Attachment* attachment = it->second.get();
return attachment->internal_format();
}
@@ -369,9 +371,9 @@ GLenum Framebuffer::IsPossiblyComplete() const {
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
GLenum attachment_type = it->first;
- Attachment* attachment = it->second;
- if (!attachment->ValidForAttachmentType(
- attachment_type, manager_->max_color_attachments_)) {
+ Attachment* attachment = it->second.get();
+ if (!attachment->ValidForAttachmentType(attachment_type,
+ manager_->max_color_attachments_)) {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (width < 0) {
@@ -404,9 +406,9 @@ GLenum Framebuffer::GetStatus(
signature = base::StringPrintf("|FBO|target=%04x", target);
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- Attachment* attachment = it->second;
- signature += base::StringPrintf(
- "|Attachment|attachmentpoint=%04x", it->first);
+ Attachment* attachment = it->second.get();
+ signature +=
+ base::StringPrintf("|Attachment|attachmentpoint=%04x", it->first);
attachment->AddToSignature(texture_manager, &signature);
}
@@ -436,7 +438,7 @@ bool Framebuffer::IsCleared() const {
// are all the attachments cleaared?
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- Attachment* attachment = it->second;
+ Attachment* attachment = it->second.get();
if (!attachment->cleared()) {
return false;
}
@@ -465,7 +467,7 @@ void Framebuffer::UnbindRenderbuffer(
done = true;
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- Attachment* attachment = it->second;
+ Attachment* attachment = it->second.get();
if (attachment->IsRenderbuffer(renderbuffer)) {
// TODO(gman): manually detach renderbuffer.
// glFramebufferRenderbufferEXT(target, it->first, GL_RENDERBUFFER, 0);
@@ -484,7 +486,7 @@ void Framebuffer::UnbindTexture(
done = true;
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- Attachment* attachment = it->second;
+ Attachment* attachment = it->second.get();
if (attachment->IsTexture(texture_ref)) {
// TODO(gman): manually detach texture.
// glFramebufferTexture2DEXT(target, it->first, GL_TEXTURE_2D, 0, 0);
@@ -545,7 +547,7 @@ const Framebuffer::Attachment*
GLenum attachment) const {
AttachmentMap::const_iterator it = attachments_.find(attachment);
if (it != attachments_.end()) {
- return it->second;
+ return it->second.get();
}
return NULL;
}
diff --git a/gpu/command_buffer/service/framebuffer_manager_unittest.cc b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
index 9a7f15b..8f9fcbb 100644
--- a/gpu/command_buffer/service/framebuffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
@@ -431,11 +431,11 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id);
scoped_refptr<TextureRef> texture1(
texture_manager_.GetTexture(kTextureClient1Id));
- ASSERT_TRUE(texture1 != NULL);
+ ASSERT_TRUE(texture1.get() != NULL);
// check adding one attachment
framebuffer_->AttachTexture(
- GL_COLOR_ATTACHMENT0, texture1, kTarget1, kLevel1);
+ GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1);
EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
framebuffer_->IsPossiblyComplete());
@@ -443,24 +443,47 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
// Try format that doesn't work with COLOR_ATTACHMENT0
- texture_manager_.SetTarget(texture1, GL_TEXTURE_2D);
- texture_manager_.SetLevelInfo(
- texture1, GL_TEXTURE_2D, kLevel1,
- kBadFormat1, kWidth1, kHeight1, kDepth, kBorder, kBadFormat1, kType,
- true);
+ texture_manager_.SetTarget(texture1.get(), GL_TEXTURE_2D);
+ texture_manager_.SetLevelInfo(texture1.get(),
+ GL_TEXTURE_2D,
+ kLevel1,
+ kBadFormat1,
+ kWidth1,
+ kHeight1,
+ kDepth,
+ kBorder,
+ kBadFormat1,
+ kType,
+ true);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
framebuffer_->IsPossiblyComplete());
// Try a good format.
- texture_manager_.SetLevelInfo(
- texture1, GL_TEXTURE_2D, kLevel1,
- kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false);
+ texture_manager_.SetLevelInfo(texture1.get(),
+ GL_TEXTURE_2D,
+ kLevel1,
+ kFormat1,
+ kWidth1,
+ kHeight1,
+ kDepth,
+ kBorder,
+ kFormat1,
+ kType,
+ false);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
framebuffer_->IsPossiblyComplete());
EXPECT_FALSE(framebuffer_->IsCleared());
- texture_manager_.SetLevelInfo(
- texture1, GL_TEXTURE_2D, kLevel1,
- kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true);
+ texture_manager_.SetLevelInfo(texture1.get(),
+ GL_TEXTURE_2D,
+ kLevel1,
+ kFormat1,
+ kWidth1,
+ kHeight1,
+ kDepth,
+ kBorder,
+ kFormat1,
+ kType,
+ true);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
framebuffer_->IsPossiblyComplete());
EXPECT_TRUE(framebuffer_->IsCleared());
@@ -480,14 +503,22 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
scoped_refptr<TextureRef> texture2(
texture_manager_.GetTexture(kTextureClient2Id));
- ASSERT_TRUE(texture2 != NULL);
- texture_manager_.SetTarget(texture2, GL_TEXTURE_2D);
- texture_manager_.SetLevelInfo(
- texture2, GL_TEXTURE_2D, kLevel2,
- kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType, true);
+ ASSERT_TRUE(texture2.get() != NULL);
+ texture_manager_.SetTarget(texture2.get(), GL_TEXTURE_2D);
+ texture_manager_.SetLevelInfo(texture2.get(),
+ GL_TEXTURE_2D,
+ kLevel2,
+ kFormat2,
+ kWidth2,
+ kHeight2,
+ kDepth,
+ kBorder,
+ kFormat2,
+ kType,
+ true);
framebuffer_->AttachTexture(
- GL_COLOR_ATTACHMENT0, texture2, kTarget2, kLevel2);
+ GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2);
EXPECT_EQ(static_cast<GLenum>(kFormat2),
framebuffer_->GetColorAttachmentFormat());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
@@ -503,9 +534,17 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_TRUE(attachment->cleared());
// Check changing attachment
- texture_manager_.SetLevelInfo(
- texture2, GL_TEXTURE_2D, kLevel3,
- kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType, false);
+ texture_manager_.SetLevelInfo(texture2.get(),
+ GL_TEXTURE_2D,
+ kLevel3,
+ kFormat3,
+ kWidth3,
+ kHeight3,
+ kDepth,
+ kBorder,
+ kFormat3,
+ kType,
+ false);
attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
ASSERT_TRUE(attachment != NULL);
EXPECT_EQ(kWidth3, attachment->width());
@@ -520,9 +559,17 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_FALSE(framebuffer_->IsCleared());
// Set to size 0
- texture_manager_.SetLevelInfo(
- texture2, GL_TEXTURE_2D, kLevel3,
- kFormat3, 0, 0, kDepth, kBorder, kFormat3, kType, false);
+ texture_manager_.SetLevelInfo(texture2.get(),
+ GL_TEXTURE_2D,
+ kLevel3,
+ kFormat3,
+ 0,
+ 0,
+ kDepth,
+ kBorder,
+ kFormat3,
+ kType,
+ false);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
framebuffer_->IsPossiblyComplete());
@@ -582,27 +629,27 @@ TEST_F(FramebufferInfoTest, UnbindTexture) {
texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id);
scoped_refptr<TextureRef> texture1(
texture_manager_.GetTexture(kTextureClient1Id));
- ASSERT_TRUE(texture1 != NULL);
+ ASSERT_TRUE(texture1.get() != NULL);
texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
scoped_refptr<TextureRef> texture2(
texture_manager_.GetTexture(kTextureClient2Id));
- ASSERT_TRUE(texture2 != NULL);
+ ASSERT_TRUE(texture2.get() != NULL);
// Attach to 2 attachment points.
framebuffer_->AttachTexture(
- GL_COLOR_ATTACHMENT0, texture1, kTarget1, kLevel1);
+ GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1);
framebuffer_->AttachTexture(
- GL_DEPTH_ATTACHMENT, texture1, kTarget1, kLevel1);
+ GL_DEPTH_ATTACHMENT, texture1.get(), kTarget1, kLevel1);
// Check they were attached.
EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL);
EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL);
// Unbind unattached texture.
- framebuffer_->UnbindTexture(kTarget1, texture2);
+ framebuffer_->UnbindTexture(kTarget1, texture2.get());
// Should be no-op.
EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL);
EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL);
// Unbind texture.
- framebuffer_->UnbindTexture(kTarget1, texture1);
+ framebuffer_->UnbindTexture(kTarget1, texture1.get());
// Check they were detached
EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL);
@@ -624,7 +671,7 @@ TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) {
texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
scoped_refptr<TextureRef> texture2(
texture_manager_.GetTexture(kTextureClient2Id));
- ASSERT_TRUE(texture2 != NULL);
+ ASSERT_TRUE(texture2.get() != NULL);
// Check MarkAsComlete marks as complete.
manager_.MarkAsComplete(framebuffer_);
@@ -632,7 +679,7 @@ TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) {
// Check at attaching marks as not complete.
framebuffer_->AttachTexture(
- GL_COLOR_ATTACHMENT0, texture2, kTarget1, kLevel1);
+ GL_COLOR_ATTACHMENT0, texture2.get(), kTarget1, kLevel1);
EXPECT_FALSE(manager_.IsComplete(framebuffer_));
manager_.MarkAsComplete(framebuffer_);
EXPECT_TRUE(manager_.IsComplete(framebuffer_));
@@ -649,7 +696,7 @@ TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) {
EXPECT_FALSE(manager_.IsComplete(framebuffer_));
manager_.MarkAsComplete(framebuffer_);
EXPECT_TRUE(manager_.IsComplete(framebuffer_));
- framebuffer_->UnbindTexture(kTarget1, texture2);
+ framebuffer_->UnbindTexture(kTarget1, texture2.get());
EXPECT_FALSE(manager_.IsComplete(framebuffer_));
}
@@ -669,8 +716,8 @@ TEST_F(FramebufferInfoTest, GetStatus) {
texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
scoped_refptr<TextureRef> texture2(
texture_manager_.GetTexture(kTextureClient2Id));
- ASSERT_TRUE(texture2 != NULL);
- texture_manager_.SetTarget(texture2, GL_TEXTURE_2D);
+ ASSERT_TRUE(texture2.get() != NULL);
+ texture_manager_.SetTarget(texture2.get(), GL_TEXTURE_2D);
EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
.WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
@@ -687,10 +734,9 @@ TEST_F(FramebufferInfoTest, GetStatus) {
// Check changing the attachments calls CheckFramebufferStatus.
framebuffer_->AttachTexture(
- GL_COLOR_ATTACHMENT0, texture2, kTarget1, kLevel1);
+ GL_COLOR_ATTACHMENT0, texture2.get(), kTarget1, kLevel1);
EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
- .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
- .RetiresOnSaturation();
+ .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)).RetiresOnSaturation();
framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER);
// Check a second call for the same type does not call anything.
@@ -731,9 +777,13 @@ TEST_F(FramebufferInfoTest, GetStatus) {
framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
// Check changing the format calls CheckFramebuffferStatus.
- TestHelper::SetTexParameterWithExpectations(
- gl_.get(), error_state_.get(), &texture_manager_,
- texture2, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
+ TestHelper::SetTexParameterWithExpectations(gl_.get(),
+ error_state_.get(),
+ &texture_manager_,
+ texture2.get(),
+ GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE,
+ GL_NO_ERROR);
EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER))
.WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
@@ -751,9 +801,13 @@ TEST_F(FramebufferInfoTest, GetStatus) {
.WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
.RetiresOnSaturation();
}
- TestHelper::SetTexParameterWithExpectations(
- gl_.get(), error_state_.get(), &texture_manager_,
- texture2, GL_TEXTURE_WRAP_S, GL_REPEAT, GL_NO_ERROR);
+ TestHelper::SetTexParameterWithExpectations(gl_.get(),
+ error_state_.get(),
+ &texture_manager_,
+ texture2.get(),
+ GL_TEXTURE_WRAP_S,
+ GL_REPEAT,
+ GL_NO_ERROR);
framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
// Check Unbinding does not call CheckFramebufferStatus
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 20f059e..1642fe9 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1371,7 +1371,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
Buffer* GetBufferInfoForTarget(GLenum target) {
DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER);
if (target == GL_ARRAY_BUFFER) {
- return state_.bound_array_buffer;
+ return state_.bound_array_buffer.get();
} else {
return state_.vertex_attrib_manager->element_array_buffer();
}
@@ -1383,7 +1383,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
TextureRef* texture = NULL;
switch (target) {
case GL_TEXTURE_2D:
- texture = unit.bound_texture_2d;
+ texture = unit.bound_texture_2d.get();
break;
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
@@ -1392,13 +1392,13 @@ class GLES2DecoderImpl : public GLES2Decoder {
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- texture = unit.bound_texture_cube_map;
+ texture = unit.bound_texture_cube_map.get();
break;
case GL_TEXTURE_EXTERNAL_OES:
- texture = unit.bound_texture_external_oes;
+ texture = unit.bound_texture_external_oes.get();
break;
case GL_TEXTURE_RECTANGLE_ARB:
- texture = unit.bound_texture_rectangle_arb;
+ texture = unit.bound_texture_rectangle_arb.get();
break;
default:
NOTREACHED();
@@ -1441,10 +1441,10 @@ class GLES2DecoderImpl : public GLES2Decoder {
switch (target) {
case GL_FRAMEBUFFER:
case GL_DRAW_FRAMEBUFFER_EXT:
- framebuffer = state_.bound_draw_framebuffer;
+ framebuffer = state_.bound_draw_framebuffer.get();
break;
case GL_READ_FRAMEBUFFER_EXT:
- framebuffer = state_.bound_read_framebuffer;
+ framebuffer = state_.bound_read_framebuffer.get();
break;
default:
NOTREACHED();
@@ -1458,7 +1458,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
Renderbuffer* renderbuffer = NULL;
switch (target) {
case GL_RENDERBUFFER:
- renderbuffer = state_.bound_renderbuffer;
+ renderbuffer = state_.bound_renderbuffer.get();
break;
default:
NOTREACHED();
@@ -1520,13 +1520,13 @@ class GLES2DecoderImpl : public GLES2Decoder {
bool ShouldDeferDraws() {
return !offscreen_target_frame_buffer_.get() &&
- state_.bound_draw_framebuffer == NULL &&
+ state_.bound_draw_framebuffer.get() == NULL &&
surface_->DeferDraws();
}
bool ShouldDeferReads() {
return !offscreen_target_frame_buffer_.get() &&
- state_.bound_read_framebuffer == NULL &&
+ state_.bound_read_framebuffer.get() == NULL &&
surface_->DeferDraws();
}
@@ -2215,7 +2215,7 @@ bool GLES2DecoderImpl::Initialize(
// vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call
DoBindVertexArrayOES(0);
- query_manager_.reset(new QueryManager(this, feature_info_));
+ query_manager_.reset(new QueryManager(this, feature_info_.get()));
vertex_array_manager_.reset(new VertexArrayManager());
util_.set_num_compressed_texture_formats(
@@ -2635,7 +2635,7 @@ void GLES2DecoderImpl::DeleteBuffersHelper(
Buffer* buffer = GetBuffer(client_ids[ii]);
if (buffer && !buffer->IsDeleted()) {
state_.vertex_attrib_manager->Unbind(buffer);
- if (state_.bound_array_buffer == buffer) {
+ if (state_.bound_array_buffer.get() == buffer) {
state_.bound_array_buffer = NULL;
}
RemoveBuffer(client_ids[ii]);
@@ -2652,14 +2652,14 @@ void GLES2DecoderImpl::DeleteFramebuffersHelper(
Framebuffer* framebuffer =
GetFramebuffer(client_ids[ii]);
if (framebuffer && !framebuffer->IsDeleted()) {
- if (framebuffer == state_.bound_draw_framebuffer) {
+ if (framebuffer == state_.bound_draw_framebuffer.get()) {
state_.bound_draw_framebuffer = NULL;
clear_state_dirty_ = true;
GLenum target = supports_separate_framebuffer_binds ?
GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
glBindFramebufferEXT(target, GetBackbufferServiceId());
}
- if (framebuffer == state_.bound_read_framebuffer) {
+ if (framebuffer == state_.bound_read_framebuffer.get()) {
state_.bound_read_framebuffer = NULL;
GLenum target = supports_separate_framebuffer_binds ?
GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
@@ -2679,23 +2679,23 @@ void GLES2DecoderImpl::DeleteRenderbuffersHelper(
Renderbuffer* renderbuffer =
GetRenderbuffer(client_ids[ii]);
if (renderbuffer && !renderbuffer->IsDeleted()) {
- if (state_.bound_renderbuffer == renderbuffer) {
+ if (state_.bound_renderbuffer.get() == renderbuffer) {
state_.bound_renderbuffer = NULL;
}
// Unbind from current framebuffers.
if (supports_separate_framebuffer_binds) {
- if (state_.bound_read_framebuffer) {
- state_.bound_read_framebuffer->UnbindRenderbuffer(
- GL_READ_FRAMEBUFFER_EXT, renderbuffer);
+ if (state_.bound_read_framebuffer.get()) {
+ state_.bound_read_framebuffer
+ ->UnbindRenderbuffer(GL_READ_FRAMEBUFFER_EXT, renderbuffer);
}
- if (state_.bound_draw_framebuffer) {
- state_.bound_draw_framebuffer->UnbindRenderbuffer(
- GL_DRAW_FRAMEBUFFER_EXT, renderbuffer);
+ if (state_.bound_draw_framebuffer.get()) {
+ state_.bound_draw_framebuffer
+ ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer);
}
} else {
- if (state_.bound_draw_framebuffer) {
- state_.bound_draw_framebuffer->UnbindRenderbuffer(
- GL_FRAMEBUFFER, renderbuffer);
+ if (state_.bound_draw_framebuffer.get()) {
+ state_.bound_draw_framebuffer
+ ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer);
}
}
clear_state_dirty_ = true;
@@ -2721,18 +2721,18 @@ void GLES2DecoderImpl::DeleteTexturesHelper(
}
// Unbind from current framebuffers.
if (supports_separate_framebuffer_binds) {
- if (state_.bound_read_framebuffer) {
- state_.bound_read_framebuffer->UnbindTexture(
- GL_READ_FRAMEBUFFER_EXT, texture_ref);
+ if (state_.bound_read_framebuffer.get()) {
+ state_.bound_read_framebuffer
+ ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref);
}
- if (state_.bound_draw_framebuffer) {
- state_.bound_draw_framebuffer->UnbindTexture(
- GL_DRAW_FRAMEBUFFER_EXT, texture_ref);
+ if (state_.bound_draw_framebuffer.get()) {
+ state_.bound_draw_framebuffer
+ ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref);
}
} else {
- if (state_.bound_draw_framebuffer) {
- state_.bound_draw_framebuffer->UnbindTexture(GL_FRAMEBUFFER,
- texture_ref);
+ if (state_.bound_draw_framebuffer.get()) {
+ state_.bound_draw_framebuffer
+ ->UnbindTexture(GL_FRAMEBUFFER, texture_ref);
}
}
GLuint service_id = texture->service_id();
@@ -2843,7 +2843,7 @@ void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() {
void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() {
TextureUnit& info = state_.texture_units[0];
GLuint last_id;
- if (info.bound_texture_2d) {
+ if (info.bound_texture_2d.get()) {
last_id = info.bound_texture_2d->service_id();
} else {
last_id = 0;
@@ -2919,19 +2919,19 @@ bool GLES2DecoderImpl::CheckFramebufferValid(
bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) {
if (!features().chromium_framebuffer_multisample) {
bool valid = CheckFramebufferValid(
- state_.bound_draw_framebuffer, GL_FRAMEBUFFER_EXT, func_name);
+ state_.bound_draw_framebuffer.get(), GL_FRAMEBUFFER_EXT, func_name);
if (valid)
OnUseFramebuffer();
return valid;
}
- return CheckFramebufferValid(
- state_.bound_draw_framebuffer,
- GL_DRAW_FRAMEBUFFER_EXT, func_name) &&
- CheckFramebufferValid(
- state_.bound_read_framebuffer,
- GL_READ_FRAMEBUFFER_EXT, func_name);
+ return CheckFramebufferValid(state_.bound_draw_framebuffer.get(),
+ GL_DRAW_FRAMEBUFFER_EXT,
+ func_name) &&
+ CheckFramebufferValid(state_.bound_read_framebuffer.get(),
+ GL_READ_FRAMEBUFFER_EXT,
+ func_name);
}
gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() {
@@ -2984,7 +2984,7 @@ void GLES2DecoderImpl::UpdateParentTextureInfo() {
TextureManager* parent_texture_manager = parent_->texture_manager();
glBindTexture(target, offscreen_saved_color_texture_info_->service_id());
parent_texture_manager->SetLevelInfo(
- offscreen_saved_color_texture_info_,
+ offscreen_saved_color_texture_info_.get(),
GL_TEXTURE_2D,
0, // level
GL_RGBA,
@@ -2998,25 +2998,25 @@ void GLES2DecoderImpl::UpdateParentTextureInfo() {
parent_texture_manager->SetParameter(
"UpdateParentTextureInfo",
GetErrorState(),
- offscreen_saved_color_texture_info_,
+ offscreen_saved_color_texture_info_.get(),
GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
parent_texture_manager->SetParameter(
"UpdateParentTextureInfo",
GetErrorState(),
- offscreen_saved_color_texture_info_,
+ offscreen_saved_color_texture_info_.get(),
GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
parent_texture_manager->SetParameter(
"UpdateParentTextureInfo",
GetErrorState(),
- offscreen_saved_color_texture_info_,
+ offscreen_saved_color_texture_info_.get(),
GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
parent_texture_manager->SetParameter(
"UpdateParentTextureInfo",
GetErrorState(),
- offscreen_saved_color_texture_info_,
+ offscreen_saved_color_texture_info_.get(),
GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
TextureRef* texture_ref = GetTextureInfoForTarget(target);
@@ -3129,8 +3129,9 @@ void GLES2DecoderImpl::Destroy(bool have_context) {
copy_texture_CHROMIUM_.reset();
}
- if (state_.current_program) {
- program_manager()->UnuseProgram(shader_manager(), state_.current_program);
+ if (state_.current_program.get()) {
+ program_manager()->UnuseProgram(shader_manager(),
+ state_.current_program.get());
state_.current_program = NULL;
}
@@ -3205,7 +3206,7 @@ void GLES2DecoderImpl::Destroy(bool have_context) {
// by the context group.
async_pixel_transfer_manager_.reset();
- if (group_) {
+ if (group_.get()) {
group_->Destroy(this, have_context);
group_ = NULL;
}
@@ -3249,7 +3250,7 @@ bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
parent_->children_.erase(it);
// First check the texture has been mapped into the parent. This might not
// be the case if initialization failed midway through.
- if (offscreen_saved_color_texture_info_ &&
+ if (offscreen_saved_color_texture_info_.get() &&
offscreen_saved_color_texture_info_->client_id()) {
parent_->texture_manager()->RemoveTexture(
offscreen_saved_color_texture_info_->client_id());
@@ -3280,8 +3281,8 @@ bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
offscreen_saved_color_texture_info_ =
new_parent_impl->CreateTexture(new_parent_texture_id, service_id);
offscreen_saved_color_texture_info_->texture()->SetNotOwned();
- new_parent_impl->texture_manager()->
- SetTarget(offscreen_saved_color_texture_info_, GL_TEXTURE_2D);
+ new_parent_impl->texture_manager()
+ ->SetTarget(offscreen_saved_color_texture_info_.get(), GL_TEXTURE_2D);
parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl);
@@ -3687,9 +3688,9 @@ void GLES2DecoderImpl::ApplyDirtyState() {
}
GLuint GLES2DecoderImpl::GetBackbufferServiceId() const {
- return (offscreen_target_frame_buffer_.get()) ?
- offscreen_target_frame_buffer_->id() :
- (surface_ ? surface_->GetBackingFrameBufferObject() : 0);
+ return (offscreen_target_frame_buffer_.get())
+ ? offscreen_target_frame_buffer_->id()
+ : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0);
}
void GLES2DecoderImpl::RestoreState() const {
@@ -3703,16 +3704,16 @@ void GLES2DecoderImpl::RestoreState() const {
}
void GLES2DecoderImpl::RestoreFramebufferBindings() const {
- GLuint service_id = state_.bound_draw_framebuffer ?
- state_.bound_draw_framebuffer->service_id() :
- GetBackbufferServiceId();
+ GLuint service_id = state_.bound_draw_framebuffer.get()
+ ? state_.bound_draw_framebuffer->service_id()
+ : GetBackbufferServiceId();
if (!features().chromium_framebuffer_multisample) {
glBindFramebufferEXT(GL_FRAMEBUFFER, service_id);
} else {
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id);
- service_id = state_.bound_read_framebuffer ?
- state_.bound_read_framebuffer->service_id() :
- GetBackbufferServiceId();
+ service_id = state_.bound_read_framebuffer.get()
+ ? state_.bound_read_framebuffer->service_id()
+ : GetBackbufferServiceId();
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id);
}
OnFboChanged();
@@ -4166,7 +4167,7 @@ bool GLES2DecoderImpl::GetHelper(
case GL_ARRAY_BUFFER_BINDING:
*num_written = 1;
if (params) {
- if (state_.bound_array_buffer) {
+ if (state_.bound_array_buffer.get()) {
GLuint client_id = 0;
buffer_manager()->GetClientId(state_.bound_array_buffer->service_id(),
&client_id);
@@ -4236,7 +4237,7 @@ bool GLES2DecoderImpl::GetHelper(
case GL_CURRENT_PROGRAM:
*num_written = 1;
if (params) {
- if (state_.current_program) {
+ if (state_.current_program.get()) {
GLuint client_id = 0;
program_manager()->GetClientId(
state_.current_program->service_id(), &client_id);
@@ -4249,7 +4250,8 @@ bool GLES2DecoderImpl::GetHelper(
case GL_VERTEX_ARRAY_BINDING_OES:
*num_written = 1;
if (params) {
- if (state_.vertex_attrib_manager != default_vertex_attrib_manager_) {
+ if (state_.vertex_attrib_manager.get() !=
+ default_vertex_attrib_manager_.get()) {
GLuint client_id = 0;
vertex_array_manager_->GetClientId(
state_.vertex_attrib_manager->service_id(), &client_id);
@@ -4263,7 +4265,7 @@ bool GLES2DecoderImpl::GetHelper(
*num_written = 1;
if (params) {
TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
- if (unit.bound_texture_2d) {
+ if (unit.bound_texture_2d.get()) {
*params = unit.bound_texture_2d->client_id();
} else {
*params = 0;
@@ -4274,7 +4276,7 @@ bool GLES2DecoderImpl::GetHelper(
*num_written = 1;
if (params) {
TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
- if (unit.bound_texture_cube_map) {
+ if (unit.bound_texture_cube_map.get()) {
*params = unit.bound_texture_cube_map->client_id();
} else {
*params = 0;
@@ -4285,7 +4287,7 @@ bool GLES2DecoderImpl::GetHelper(
*num_written = 1;
if (params) {
TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
- if (unit.bound_texture_external_oes) {
+ if (unit.bound_texture_external_oes.get()) {
*params = unit.bound_texture_external_oes->client_id();
} else {
*params = 0;
@@ -4296,7 +4298,7 @@ bool GLES2DecoderImpl::GetHelper(
*num_written = 1;
if (params) {
TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
- if (unit.bound_texture_rectangle_arb) {
+ if (unit.bound_texture_rectangle_arb.get()) {
*params = unit.bound_texture_rectangle_arb->client_id();
} else {
*params = 0;
@@ -4757,7 +4759,7 @@ void GLES2DecoderImpl::DoFramebufferRenderbuffer(
if (error == GL_NO_ERROR) {
framebuffer->AttachRenderbuffer(attachment, renderbuffer);
}
- if (framebuffer == state_.bound_draw_framebuffer) {
+ if (framebuffer == state_.bound_draw_framebuffer.get()) {
clear_state_dirty_ = true;
}
OnFboChanged();
@@ -4902,7 +4904,7 @@ void GLES2DecoderImpl::DoFramebufferTexture2D(
if (error == GL_NO_ERROR) {
framebuffer->AttachTexture(attachment, texture_ref, textarget, level);
}
- if (framebuffer == state_.bound_draw_framebuffer) {
+ if (framebuffer == state_.bound_draw_framebuffer.get()) {
clear_state_dirty_ = true;
}
OnFboChanged();
@@ -5109,14 +5111,14 @@ void GLES2DecoderImpl::DoLinkProgram(GLuint program_id) {
ShaderTranslator* vertex_translator = NULL;
ShaderTranslator* fragment_translator = NULL;
if (use_shader_translator_) {
- vertex_translator = vertex_translator_;
- fragment_translator = fragment_translator_;
+ vertex_translator = vertex_translator_.get();
+ fragment_translator = fragment_translator_.get();
}
if (program->Link(shader_manager(),
- vertex_translator,
- fragment_translator,
- feature_info_,
- shader_cache_callback_)) {
+ vertex_translator,
+ fragment_translator,
+ feature_info_.get(),
+ shader_cache_callback_)) {
if (program == state_.current_program.get()) {
if (workarounds().use_current_program_after_successful_link) {
glUseProgram(program->service_id());
@@ -5178,7 +5180,7 @@ void GLES2DecoderImpl::DoTexParameteriv(
}
bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) {
- if (!state_.current_program) {
+ if (!state_.current_program.get()) {
// The program does not exist.
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION, function_name, "no program in use");
@@ -5574,14 +5576,15 @@ void GLES2DecoderImpl::DoUseProgram(GLuint program_id) {
}
service_id = program->service_id();
}
- if (state_.current_program) {
- program_manager()->UnuseProgram(shader_manager(), state_.current_program);
+ if (state_.current_program.get()) {
+ program_manager()->UnuseProgram(shader_manager(),
+ state_.current_program.get());
}
state_.current_program = program;
LogClientServiceMapping("glUseProgram", program_id, service_id);
glUseProgram(service_id);
- if (state_.current_program) {
- program_manager()->UseProgram(state_.current_program);
+ if (state_.current_program.get()) {
+ program_manager()->UseProgram(state_.current_program.get());
}
}
@@ -5609,12 +5612,12 @@ void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) {
program_manager()->ForceCompileShader(shader->deferred_compilation_source(),
shader,
translator,
- feature_info_);
+ feature_info_.get());
}
}
bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() {
- DCHECK(state_.current_program);
+ DCHECK(state_.current_program.get());
// Only check if there are some unrenderable textures.
if (!texture_manager()->HaveUnrenderableTextures()) {
return false;
@@ -5654,9 +5657,9 @@ bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() {
}
void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
- DCHECK(state_.current_program);
+ DCHECK(state_.current_program.get());
const Program::SamplerIndices& sampler_indices =
- state_.current_program->sampler_indices();
+ state_.current_program->sampler_indices();
for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
const Program::UniformInfo* uniform_info =
state_.current_program->GetUniformInfo(sampler_indices[ii]);
@@ -5665,15 +5668,16 @@ void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
GLuint texture_unit_index = uniform_info->texture_units[jj];
if (texture_unit_index < state_.texture_units.size()) {
TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
- TextureRef* texture_ref = uniform_info->type == GL_SAMPLER_2D ?
- texture_unit.bound_texture_2d :
- texture_unit.bound_texture_cube_map;
+ TextureRef* texture_ref =
+ uniform_info->type == GL_SAMPLER_2D
+ ? texture_unit.bound_texture_2d.get()
+ : texture_unit.bound_texture_cube_map.get();
if (!texture_ref || !texture_manager()->CanRender(texture_ref)) {
glActiveTexture(GL_TEXTURE0 + texture_unit_index);
// Get the texture_ref info that was previously bound here.
- texture_ref = texture_unit.bind_target == GL_TEXTURE_2D ?
- texture_unit.bound_texture_2d :
- texture_unit.bound_texture_cube_map;
+ texture_ref = texture_unit.bind_target == GL_TEXTURE_2D
+ ? texture_unit.bound_texture_2d.get()
+ : texture_unit.bound_texture_cube_map.get();
glBindTexture(texture_unit.bind_target,
texture_ref ? texture_ref->service_id() : 0);
}
@@ -5691,9 +5695,9 @@ bool GLES2DecoderImpl::ClearUnclearedTextures() {
}
// 1: Check all textures we are about to render with.
- if (state_.current_program) {
+ if (state_.current_program.get()) {
const Program::SamplerIndices& sampler_indices =
- state_.current_program->sampler_indices();
+ state_.current_program->sampler_indices();
for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
const Program::UniformInfo* uniform_info =
state_.current_program->GetUniformInfo(sampler_indices[ii]);
@@ -5722,20 +5726,20 @@ bool GLES2DecoderImpl::IsDrawValid(
// it could never be invalid since glUseProgram would have failed. While
// glLinkProgram could later mark the program as invalid the previous
// valid program will still function if it is still the current program.
- if (!state_.current_program) {
+ if (!state_.current_program.get()) {
// The program does not exist.
// But GL says no ERROR.
LOCAL_RENDER_WARNING("Drawing with no current shader program.");
return false;
}
- return state_.vertex_attrib_manager->ValidateBindings(
- function_name,
- this,
- feature_info_.get(),
- state_.current_program,
- max_vertex_accessed,
- primcount);
+ return state_.vertex_attrib_manager
+ ->ValidateBindings(function_name,
+ this,
+ feature_info_.get(),
+ state_.current_program.get(),
+ max_vertex_accessed,
+ primcount);
}
bool GLES2DecoderImpl::SimulateAttrib0(
@@ -5822,7 +5826,8 @@ void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib_index) {
glVertexAttribDivisorANGLE(attrib_index, attrib->divisor());
glBindBuffer(
GL_ARRAY_BUFFER,
- state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0);
+ state_.bound_array_buffer.get() ? state_.bound_array_buffer->service_id()
+ : 0);
// Never touch vertex attribute 0's state (in particular, never
// disable it) when running on desktop GL because it will never be
@@ -5953,7 +5958,8 @@ void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() {
// settings and passing GL_FIXED to it will not work.
glBindBuffer(
GL_ARRAY_BUFFER,
- state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0);
+ state_.bound_array_buffer.get() ? state_.bound_array_buffer->service_id()
+ : 0);
}
error::Error GLES2DecoderImpl::DoDrawArrays(
@@ -6273,7 +6279,7 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
vertex_translator_.get() : fragment_translator_.get();
}
- program_manager()->DoCompileShader(shader, translator, feature_info_);
+ program_manager()->DoCompileShader(shader, translator, feature_info_.get());
};
void GLES2DecoderImpl::DoGetShaderiv(
@@ -6614,8 +6620,10 @@ void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) {
error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
uint32 immediate_data_size, const cmds::VertexAttribPointer& c) {
- if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) {
- if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) {
+ if (!state_.bound_array_buffer.get() ||
+ state_.bound_array_buffer->IsDeleted()) {
+ if (state_.vertex_attrib_manager.get() ==
+ default_vertex_attrib_manager_.get()) {
LOCAL_SET_GL_ERROR(
GL_INVALID_VALUE, "glVertexAttribPointer", "no array buffer bound");
return error::kNoError;
@@ -6677,15 +6685,15 @@ error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
"glVertexAttribPointer", "stride not valid for type");
return error::kNoError;
}
- state_.vertex_attrib_manager->SetAttribInfo(
- indx,
- state_.bound_array_buffer,
- size,
- type,
- normalized,
- stride,
- stride != 0 ? stride : component_size * size,
- offset);
+ state_.vertex_attrib_manager
+ ->SetAttribInfo(indx,
+ state_.bound_array_buffer.get(),
+ size,
+ type,
+ normalized,
+ stride,
+ stride != 0 ? stride : component_size * size,
+ offset);
if (type != GL_FIXED) {
glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
@@ -9077,7 +9085,7 @@ void GLES2DecoderImpl::DeleteQueriesEXTHelper(
for (GLsizei ii = 0; ii < n; ++ii) {
QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]);
if (query && !query->IsDeleted()) {
- if (query == state_.current_query) {
+ if (query == state_.current_query.get()) {
state_.current_query = NULL;
}
query->Destroy(true);
@@ -9130,7 +9138,7 @@ error::Error GLES2DecoderImpl::HandleBeginQueryEXT(
break;
}
- if (state_.current_query) {
+ if (state_.current_query.get()) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress");
return error::kNoError;
@@ -9188,7 +9196,7 @@ error::Error GLES2DecoderImpl::HandleEndQueryEXT(
GLenum target = static_cast<GLenum>(c.target);
uint32 submit_count = static_cast<GLuint>(c.submit_count);
- if (!state_.current_query) {
+ if (!state_.current_query.get()) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION, "glEndQueryEXT", "No active query");
return error::kNoError;
@@ -9200,7 +9208,7 @@ error::Error GLES2DecoderImpl::HandleEndQueryEXT(
return error::kNoError;
}
- if (!query_manager_->EndQuery(state_.current_query, submit_count)) {
+ if (!query_manager_->EndQuery(state_.current_query.get(), submit_count)) {
return error::kOutOfBounds;
}
@@ -9241,7 +9249,7 @@ void GLES2DecoderImpl::DeleteVertexArraysOESHelper(
VertexAttribManager* vao =
GetVertexAttribManager(client_ids[ii]);
if (vao && !vao->IsDeleted()) {
- if (state_.vertex_attrib_manager == vao) {
+ if (state_.vertex_attrib_manager.get() == vao) {
state_.vertex_attrib_manager = default_vertex_attrib_manager_;
}
RemoveVertexAttribManager(client_ids[ii]);
@@ -9267,11 +9275,11 @@ void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) {
service_id = vao->service_id();
}
} else {
- vao = default_vertex_attrib_manager_;
+ vao = default_vertex_attrib_manager_.get();
}
// Only set the VAO state if it's changed
- if (state_.vertex_attrib_manager != vao) {
+ if (state_.vertex_attrib_manager.get() != vao) {
state_.vertex_attrib_manager = vao;
if (!features().native_vertex_array_object) {
EmulateVertexArrayState();
@@ -9857,10 +9865,10 @@ void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
scoped_refptr<TextureRef> texture_ref =
GetTextureInfoForTargetUnlessDefault(target);
- if (!texture_ref) {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_OPERATION,
- "glConsumeTextureCHROMIUM", "unknown texture for target");
+ if (!texture_ref.get()) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
+ "glConsumeTextureCHROMIUM",
+ "unknown texture for target");
return;
}
GLuint client_id = texture_ref->client_id();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index b4baf8b..ab2a060 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -8381,23 +8381,20 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) {
false, // request stencil
true); // bind generates resource
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(true))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(true)).RetiresOnSaturation();
DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
kSharedMemoryId, kSharedMemoryOffset);
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(64))
- .WillOnce(Return(true))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64))
+ .WillOnce(Return(true)).RetiresOnSaturation();
DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
kSharedMemoryId, kSharedMemoryOffset);
EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
// Check we get out of memory and no call to glTexImage2D if Ensure fails.
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(64))
- .WillOnce(Return(false))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64))
+ .WillOnce(Return(false)).RetiresOnSaturation();
TexImage2D cmd;
cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
kSharedMemoryId, kSharedMemoryOffset);
@@ -8422,9 +8419,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) {
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
// Check we get out of memory and no call to glTexStorage2DEXT
// if Ensure fails.
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(false))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(false)).RetiresOnSaturation();
TexStorage2DEXT cmd;
cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
@@ -8452,9 +8448,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) {
false, // request stencil
true); // bind generates resource
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(true))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(true)).RetiresOnSaturation();
EXPECT_CALL(*gl_, GetError())
.WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_NO_ERROR))
@@ -8469,9 +8464,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) {
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
// Check we get out of memory and no call to glCopyTexImage2D if Ensure fails.
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(false))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(false)).RetiresOnSaturation();
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
@@ -8496,9 +8490,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) {
.WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_NO_ERROR))
.RetiresOnSaturation();
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(true))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(true)).RetiresOnSaturation();
EXPECT_CALL(*gl_, RenderbufferStorageEXT(
GL_RENDERBUFFER, GL_RGBA, 8, 4))
.Times(1)
@@ -8510,9 +8503,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) {
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
// Check we get out of memory and no call to glRenderbufferStorage if Ensure
// fails.
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(false))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(false)).RetiresOnSaturation();
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
@@ -8537,9 +8529,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerBufferData) {
.WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_NO_ERROR))
.RetiresOnSaturation();
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(true))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(true)).RetiresOnSaturation();
EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 128, _, GL_STREAM_DRAW))
.Times(1)
.RetiresOnSaturation();
@@ -8550,9 +8541,8 @@ TEST_F(GLES2DecoderManualInitTest, MemoryTrackerBufferData) {
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
// Check we get out of memory and no call to glBufferData if Ensure
// fails.
- EXPECT_CALL(*memory_tracker, EnsureGPUMemoryAvailable(128))
- .WillOnce(Return(false))
- .RetiresOnSaturation();
+ EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
+ .WillOnce(Return(false)).RetiresOnSaturation();
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 5cc2b96..3b6c2f9 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -252,7 +252,7 @@ void GLES2DecoderTestBase::InitDecoder(
context_ = new gfx::GLContextStub;
- context_->MakeCurrent(surface_);
+ context_->MakeCurrent(surface_.get());
int32 attributes[] = {
EGL_ALPHA_SIZE, request_alpha ? 8 : 0,
diff --git a/gpu/command_buffer/service/gpu_tracer.cc b/gpu/command_buffer/service/gpu_tracer.cc
index 8581499..76485c6 100644
--- a/gpu/command_buffer/service/gpu_tracer.cc
+++ b/gpu/command_buffer/service/gpu_tracer.cc
@@ -237,7 +237,7 @@ void GLARBTimerTrace::Process() {
bool GPUTracerImpl::Begin(const std::string& name) {
// Make sure we are not nesting trace commands.
- if (current_trace_)
+ if (current_trace_.get())
return false;
current_trace_ = CreateTrace(name);
@@ -246,7 +246,7 @@ bool GPUTracerImpl::Begin(const std::string& name) {
}
bool GPUTracerImpl::End() {
- if (!current_trace_)
+ if (!current_trace_.get())
return false;
current_trace_->End();
@@ -270,7 +270,7 @@ void GPUTracerImpl::Process() {
}
const std::string& GPUTracerImpl::CurrentName() const {
- if (!current_trace_)
+ if (!current_trace_.get())
return EmptyString();
return current_trace_->name();
}
diff --git a/gpu/command_buffer/service/image_manager.cc b/gpu/command_buffer/service/image_manager.cc
index b424770..6be4e66 100644
--- a/gpu/command_buffer/service/image_manager.cc
+++ b/gpu/command_buffer/service/image_manager.cc
@@ -26,7 +26,7 @@ void ImageManager::RemoveImage(int32 service_id) {
gfx::GLImage* ImageManager::LookupImage(int32 service_id) {
GLImageMap::const_iterator iter = gl_images_.find(service_id);
if (iter != gl_images_.end())
- return iter->second;
+ return iter->second.get();
return NULL;
}
diff --git a/gpu/command_buffer/service/memory_program_cache.cc b/gpu/command_buffer/service/memory_program_cache.cc
index 2582a49..f39a670 100644
--- a/gpu/command_buffer/service/memory_program_cache.cc
+++ b/gpu/command_buffer/service/memory_program_cache.cc
@@ -202,7 +202,7 @@ void MemoryProgramCache::SaveLinkedProgram(
if (store_.find(sha_string) != store_.end()) {
const StoreMap::iterator found = store_.find(sha_string);
- const ProgramCacheValue* evicting = found->second;
+ const ProgramCacheValue* evicting = found->second.get();
curr_size_bytes_ -= evicting->length;
Evict(sha_string, evicting->shader_0_hash, evicting->shader_1_hash);
store_.erase(found);
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index d362cde..c64e2bf 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -559,14 +559,14 @@ bool Program::Link(ShaderManager* manager,
&bind_attrib_location_map_);
if (status == ProgramCache::LINK_SUCCEEDED) {
- ProgramCache::ProgramLoadResult success = cache->LoadLinkedProgram(
- service_id(),
- attached_shaders_[0],
- vertex_translator,
- attached_shaders_[1],
- fragment_translator,
- &bind_attrib_location_map_,
- shader_callback);
+ ProgramCache::ProgramLoadResult success =
+ cache->LoadLinkedProgram(service_id(),
+ attached_shaders_[0].get(),
+ vertex_translator,
+ attached_shaders_[1].get(),
+ fragment_translator,
+ &bind_attrib_location_map_,
+ shader_callback);
link = success != ProgramCache::PROGRAM_LOAD_SUCCESS;
UMA_HISTOGRAM_BOOLEAN("GPU.ProgramCache.LoadBinarySuccess", !link);
}
@@ -583,7 +583,7 @@ bool Program::Link(ShaderManager* manager,
vertex_translator,
fragment_translator);
manager_->ForceCompileShader(shader->deferred_compilation_source(),
- attached_shaders_[i],
+ attached_shaders_[i].get(),
translator,
feature_info);
DCHECK(shader->IsValid());
@@ -610,9 +610,9 @@ bool Program::Link(ShaderManager* manager,
if (link) {
if (cache) {
cache->SaveLinkedProgram(service_id(),
- attached_shaders_[0],
+ attached_shaders_[0].get(),
vertex_translator,
- attached_shaders_[1],
+ attached_shaders_[1].get(),
fragment_translator,
&bind_attrib_location_map_,
shader_callback);
@@ -951,7 +951,7 @@ bool Program::AttachShader(
DCHECK(shader_manager);
DCHECK(shader);
int index = ShaderTypeToIndex(shader->shader_type());
- if (attached_shaders_[index] != NULL) {
+ if (attached_shaders_[index].get() != NULL) {
return false;
}
attached_shaders_[index] = scoped_refptr<Shader>(shader);
@@ -976,15 +976,15 @@ bool Program::DetachShader(
void Program::DetachShaders(ShaderManager* shader_manager) {
DCHECK(shader_manager);
for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
- if (attached_shaders_[ii]) {
- DetachShader(shader_manager, attached_shaders_[ii]);
+ if (attached_shaders_[ii].get()) {
+ DetachShader(shader_manager, attached_shaders_[ii].get());
}
}
}
bool Program::CanLink() const {
for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
- if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) {
+ if (!attached_shaders_[ii].get() || !attached_shaders_[ii]->IsValid()) {
return false;
}
}
@@ -998,7 +998,7 @@ bool Program::DetectAttribLocationBindingConflicts() const {
// Find out if an attribute is declared in this program's shaders.
bool active = false;
for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
- if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid())
+ if (!attached_shaders_[ii].get() || !attached_shaders_[ii]->IsValid())
continue;
if (attached_shaders_[ii]->GetAttribInfo(it->first)) {
active = true;
@@ -1145,7 +1145,7 @@ Program* ProgramManager::CreateProgram(
scoped_refptr<Program>(
new Program(this, service_id))));
DCHECK(result.second);
- return result.first->second;
+ return result.first->second.get();
}
Program* ProgramManager::GetProgram(GLuint client_id) {
diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc
index fce5ac3..25199aa 100644
--- a/gpu/command_buffer/service/program_manager_unittest.cc
+++ b/gpu/command_buffer/service/program_manager_unittest.cc
@@ -108,17 +108,17 @@ TEST_F(ProgramManagerTest, DeleteBug) {
scoped_refptr<Program> program2(
manager_.CreateProgram(kClient2Id, kService2Id));
// Check program got created.
- ASSERT_TRUE(program1);
- ASSERT_TRUE(program2);
- manager_.UseProgram(program1);
- manager_.MarkAsDeleted(&shader_manager, program1);
+ ASSERT_TRUE(program1.get());
+ ASSERT_TRUE(program2.get());
+ manager_.UseProgram(program1.get());
+ manager_.MarkAsDeleted(&shader_manager, program1.get());
// Program will be deleted when last ref is released.
EXPECT_CALL(*gl_, DeleteProgram(kService2Id))
.Times(1)
.RetiresOnSaturation();
- manager_.MarkAsDeleted(&shader_manager, program2);
- EXPECT_TRUE(manager_.IsOwned(program1));
- EXPECT_FALSE(manager_.IsOwned(program2));
+ manager_.MarkAsDeleted(&shader_manager, program2.get());
+ EXPECT_TRUE(manager_.IsOwned(program1.get()));
+ EXPECT_FALSE(manager_.IsOwned(program2.get()));
}
TEST_F(ProgramManagerTest, Program) {
diff --git a/gpu/command_buffer/service/query_manager.cc b/gpu/command_buffer/service/query_manager.cc
index a6efd47..a176661 100644
--- a/gpu/command_buffer/service/query_manager.cc
+++ b/gpu/command_buffer/service/query_manager.cc
@@ -325,7 +325,7 @@ void QueryManager::Destroy(bool have_context) {
pending_queries_.clear();
pending_transfer_queries_.clear();
while (!queries_.empty()) {
- Query* query = queries_.begin()->second;
+ Query* query = queries_.begin()->second.get();
query->Destroy(have_context);
queries_.erase(queries_.begin());
}
@@ -372,7 +372,7 @@ QueryManager::Query* QueryManager::GetQuery(
void QueryManager::RemoveQuery(GLuint client_id) {
QueryMap::iterator it = queries_.find(client_id);
if (it != queries_.end()) {
- Query* query = it->second;
+ Query* query = it->second.get();
RemovePendingQuery(query);
query->MarkAsDeleted();
queries_.erase(it);
diff --git a/gpu/command_buffer/service/renderbuffer_manager.cc b/gpu/command_buffer/service/renderbuffer_manager.cc
index 416de3b..c5a7b06 100644
--- a/gpu/command_buffer/service/renderbuffer_manager.cc
+++ b/gpu/command_buffer/service/renderbuffer_manager.cc
@@ -143,7 +143,7 @@ Renderbuffer* RenderbufferManager::GetRenderbuffer(
void RenderbufferManager::RemoveRenderbuffer(GLuint client_id) {
RenderbufferMap::iterator it = renderbuffers_.find(client_id);
if (it != renderbuffers_.end()) {
- Renderbuffer* renderbuffer = it->second;
+ Renderbuffer* renderbuffer = it->second.get();
renderbuffer->MarkAsDeleted();
renderbuffers_.erase(it);
}
diff --git a/gpu/command_buffer/service/renderbuffer_manager_unittest.cc b/gpu/command_buffer/service/renderbuffer_manager_unittest.cc
index 5b654af..20e18c1 100644
--- a/gpu/command_buffer/service/renderbuffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/renderbuffer_manager_unittest.cc
@@ -58,11 +58,10 @@ class RenderbufferManagerMemoryTrackerTest
scoped_refptr<MockMemoryTracker> mock_memory_tracker_;
};
-#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size, pool) \
- EXPECT_CALL(*mock_memory_tracker_, \
- TrackMemoryAllocatedChange(old_size, new_size, pool)) \
- .Times(1) \
- .RetiresOnSaturation() \
+#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size, pool) \
+ EXPECT_CALL(*mock_memory_tracker_.get(), \
+ TrackMemoryAllocatedChange(old_size, new_size, pool)) \
+ .Times(1).RetiresOnSaturation()
// GCC requires these declarations, but MSVC requires they not be present
#ifndef COMPILER_MSVC
@@ -82,7 +81,7 @@ TEST_F(RenderbufferManagerTest, Basic) {
// Check renderbuffer got created.
scoped_refptr<Renderbuffer> renderbuffer1 =
manager_->GetRenderbuffer(kClient1Id);
- ASSERT_TRUE(renderbuffer1 != NULL);
+ ASSERT_TRUE(renderbuffer1.get() != NULL);
EXPECT_FALSE(manager_->HaveUnclearedRenderbuffers());
EXPECT_EQ(kClient1Id, renderbuffer1->client_id());
// Check we get nothing for a non-existent renderbuffer.
@@ -205,7 +204,7 @@ TEST_F(RenderbufferManagerTest, UseDeletedRenderbufferInfo) {
manager_->CreateRenderbuffer(kClient1Id, kService1Id);
scoped_refptr<Renderbuffer> renderbuffer1(
manager_->GetRenderbuffer(kClient1Id));
- ASSERT_TRUE(renderbuffer1 != NULL);
+ ASSERT_TRUE(renderbuffer1.get() != NULL);
// Remove it.
manager_->RemoveRenderbuffer(kClient1Id);
// Use after removing.
@@ -213,10 +212,10 @@ TEST_F(RenderbufferManagerTest, UseDeletedRenderbufferInfo) {
const GLenum kFormat = GL_RGBA4;
const GLsizei kWidth = 128;
const GLsizei kHeight = 64;
- manager_->SetInfo(renderbuffer1, kSamples, kFormat, kWidth, kHeight);
+ manager_->SetInfo(renderbuffer1.get(), kSamples, kFormat, kWidth, kHeight);
// See that it still affects manager.
EXPECT_TRUE(manager_->HaveUnclearedRenderbuffers());
- manager_->SetCleared(renderbuffer1, true);
+ manager_->SetCleared(renderbuffer1.get(), true);
EXPECT_FALSE(manager_->HaveUnclearedRenderbuffers());
// Check that the renderbuffer is deleted when the last ref is released.
EXPECT_CALL(*gl_, DeleteRenderbuffersEXT(1, ::testing::Pointee(kService1Id)))
@@ -241,12 +240,12 @@ TEST_F(RenderbufferManagerTest, AddToSignature) {
manager_->CreateRenderbuffer(kClient1Id, kService1Id);
scoped_refptr<Renderbuffer> renderbuffer1(
manager_->GetRenderbuffer(kClient1Id));
- ASSERT_TRUE(renderbuffer1 != NULL);
+ ASSERT_TRUE(renderbuffer1.get() != NULL);
const GLsizei kSamples = 4;
const GLenum kFormat = GL_RGBA4;
const GLsizei kWidth = 128;
const GLsizei kHeight = 64;
- manager_->SetInfo(renderbuffer1, kSamples, kFormat, kWidth, kHeight);
+ manager_->SetInfo(renderbuffer1.get(), kSamples, kFormat, kWidth, kHeight);
std::string signature1;
std::string signature2;
renderbuffer1->AddToSignature(&signature1);
@@ -255,27 +254,31 @@ TEST_F(RenderbufferManagerTest, AddToSignature) {
EXPECT_FALSE(InSet(&string_set, signature1));
// change things and see that the signatures change.
- manager_->SetInfo(renderbuffer1, kSamples + 1, kFormat, kWidth, kHeight);
+ manager_->SetInfo(
+ renderbuffer1.get(), kSamples + 1, kFormat, kWidth, kHeight);
renderbuffer1->AddToSignature(&signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetInfo(renderbuffer1, kSamples, kFormat + 1, kWidth, kHeight);
+ manager_->SetInfo(
+ renderbuffer1.get(), kSamples, kFormat + 1, kWidth, kHeight);
signature2.clear();
renderbuffer1->AddToSignature(&signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetInfo(renderbuffer1, kSamples, kFormat, kWidth + 1, kHeight);
+ manager_->SetInfo(
+ renderbuffer1.get(), kSamples, kFormat, kWidth + 1, kHeight);
signature2.clear();
renderbuffer1->AddToSignature(&signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetInfo(renderbuffer1, kSamples, kFormat, kWidth, kHeight + 1);
+ manager_->SetInfo(
+ renderbuffer1.get(), kSamples, kFormat, kWidth, kHeight + 1);
signature2.clear();
renderbuffer1->AddToSignature(&signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
// put it back to the same and it should be the same.
- manager_->SetInfo(renderbuffer1, kSamples, kFormat, kWidth, kHeight);
+ manager_->SetInfo(renderbuffer1.get(), kSamples, kFormat, kWidth, kHeight);
signature2.clear();
renderbuffer1->AddToSignature(&signature2);
EXPECT_EQ(signature1, signature2);
diff --git a/gpu/command_buffer/service/shader_manager.cc b/gpu/command_buffer/service/shader_manager.cc
index 58711d9..d2ad56e 100644
--- a/gpu/command_buffer/service/shader_manager.cc
+++ b/gpu/command_buffer/service/shader_manager.cc
@@ -93,7 +93,7 @@ ShaderManager::~ShaderManager() {
void ShaderManager::Destroy(bool have_context) {
while (!shaders_.empty()) {
if (have_context) {
- Shader* shader = shaders_.begin()->second;
+ Shader* shader = shaders_.begin()->second.get();
if (!shader->IsDeleted()) {
glDeleteShader(shader->service_id());
shader->MarkAsDeleted();
@@ -112,7 +112,7 @@ Shader* ShaderManager::CreateShader(
client_id, scoped_refptr<Shader>(
new Shader(service_id, shader_type))));
DCHECK(result.second);
- return result.first->second;
+ return result.first->second.get();
}
Shader* ShaderManager::GetShader(GLuint client_id) {
diff --git a/gpu/command_buffer/service/shader_manager_unittest.cc b/gpu/command_buffer/service/shader_manager_unittest.cc
index 2de9a58..0971bf1 100644
--- a/gpu/command_buffer/service/shader_manager_unittest.cc
+++ b/gpu/command_buffer/service/shader_manager_unittest.cc
@@ -88,13 +88,13 @@ TEST_F(ShaderManagerTest, DeleteBug) {
manager_.CreateShader(kClient1Id, kService1Id, kShaderType));
scoped_refptr<Shader> shader2(
manager_.CreateShader(kClient2Id, kService2Id, kShaderType));
- ASSERT_TRUE(shader1);
- ASSERT_TRUE(shader2);
- manager_.UseShader(shader1);
- manager_.MarkAsDeleted(shader1);
- manager_.MarkAsDeleted(shader2);
- EXPECT_TRUE(manager_.IsOwned(shader1));
- EXPECT_FALSE(manager_.IsOwned(shader2));
+ ASSERT_TRUE(shader1.get());
+ ASSERT_TRUE(shader2.get());
+ manager_.UseShader(shader1.get());
+ manager_.MarkAsDeleted(shader1.get());
+ manager_.MarkAsDeleted(shader2.get());
+ EXPECT_TRUE(manager_.IsOwned(shader1.get()));
+ EXPECT_FALSE(manager_.IsOwned(shader2.get()));
}
TEST_F(ShaderManagerTest, Shader) {
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index f878df3..73482b0 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -356,17 +356,15 @@ bool Texture::CanGenerateMipmaps(
// TODO(gman): Check internal_format, format and type.
for (size_t ii = 0; ii < level_infos_.size(); ++ii) {
const LevelInfo& info = level_infos_[ii][0];
- if ((info.target == 0) ||
- (info.width != first.width) ||
- (info.height != first.height) ||
- (info.depth != 1) ||
+ if ((info.target == 0) || (info.width != first.width) ||
+ (info.height != first.height) || (info.depth != 1) ||
(info.format != first.format) ||
(info.internal_format != first.internal_format) ||
(info.type != first.type) ||
feature_info->validators()->compressed_texture_format.IsValid(
info.internal_format) ||
- info.image) {
- return false;
+ info.image.get()) {
+ return false;
}
}
return true;
@@ -793,7 +791,7 @@ gfx::GLImage* Texture::GetLevelImage(
static_cast<size_t>(level) < level_infos_[face_index].size()) {
const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level];
if (info.target != 0) {
- return info.image;
+ return info.image.get();
}
}
return 0;
@@ -908,22 +906,46 @@ scoped_refptr<TextureRef>
scoped_refptr<TextureRef> default_texture(
TextureRef::Create(this, 0, ids[1]));
- SetTarget(default_texture, target);
+ SetTarget(default_texture.get(), target);
if (needs_faces) {
for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) {
- SetLevelInfo(
- default_texture, GLES2Util::IndexToGLFaceTarget(ii),
- 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ SetLevelInfo(default_texture.get(),
+ GLES2Util::IndexToGLFaceTarget(ii),
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
}
} else {
if (needs_initialization) {
- SetLevelInfo(default_texture,
- GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, true);
+ SetLevelInfo(default_texture.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
} else {
- SetLevelInfo(
- default_texture, GL_TEXTURE_EXTERNAL_OES, 0,
- GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ SetLevelInfo(default_texture.get(),
+ GL_TEXTURE_EXTERNAL_OES,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
}
}
@@ -952,7 +974,8 @@ bool TextureManager::ValidForTarget(
void TextureManager::SetTarget(TextureRef* ref, GLenum target) {
DCHECK(ref);
- ref->texture()->SetTarget(feature_info_, target, MaxLevelsForTarget(target));
+ ref->texture()
+ ->SetTarget(feature_info_.get(), target, MaxLevelsForTarget(target));
}
void TextureManager::SetStreamTexture(TextureRef* ref, bool stream_texture) {
@@ -1003,9 +1026,17 @@ void TextureManager::SetLevelInfo(
Texture* texture = ref->texture();
texture->GetMemTracker()->TrackMemFree(texture->estimated_size());
- texture->SetLevelInfo(
- feature_info_, target, level, internal_format, width, height, depth,
- border, format, type, cleared);
+ texture->SetLevelInfo(feature_info_.get(),
+ target,
+ level,
+ internal_format,
+ width,
+ height,
+ depth,
+ border,
+ format,
+ type,
+ cleared);
texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size());
}
@@ -1033,7 +1064,7 @@ void TextureManager::SetParameter(
DCHECK(error_state);
DCHECK(ref);
Texture* texture = ref->texture();
- GLenum result = texture->SetParameter(feature_info_, pname, param);
+ GLenum result = texture->SetParameter(feature_info_.get(), pname, param);
if (result != GL_NO_ERROR) {
if (result == GL_INVALID_ENUM) {
ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
@@ -1055,7 +1086,7 @@ bool TextureManager::MarkMipmapsGenerated(TextureRef* ref) {
DCHECK(ref);
Texture* texture = ref->texture();
texture->GetMemTracker()->TrackMemFree(texture->estimated_size());
- bool result = texture->MarkMipmapsGenerated(feature_info_);
+ bool result = texture->MarkMipmapsGenerated(feature_info_.get());
texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size());
return result;
}
@@ -1091,7 +1122,7 @@ void TextureManager::StartTracking(TextureRef* ref) {
num_uncleared_mips_ += texture->num_uncleared_mips();
if (!texture->SafeToRenderFrom())
++num_unsafe_textures_;
- if (!texture->CanRender(feature_info_))
+ if (!texture->CanRender(feature_info_.get()))
++num_unrenderable_textures_;
}
@@ -1102,7 +1133,7 @@ void TextureManager::StopTracking(TextureRef* ref) {
Texture* texture = ref->texture();
--texture_count_;
- if (!texture->CanRender(feature_info_)) {
+ if (!texture->CanRender(feature_info_.get())) {
DCHECK_NE(0, num_unrenderable_textures_);
--num_unrenderable_textures_;
}
@@ -1151,7 +1182,7 @@ void TextureManager::SetLevelImage(
GLint level,
gfx::GLImage* image) {
DCHECK(ref);
- ref->texture()->SetLevelImage(feature_info_, target, level, image);
+ ref->texture()->SetLevelImage(feature_info_.get(), target, level, image);
}
void TextureManager::AddToSignature(
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index 2d4640e..76acd15 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -501,12 +501,12 @@ class GPU_EXPORT TextureManager {
// True if this texture meets all the GLES2 criteria for rendering.
// See section 3.8.2 of the GLES2 spec.
bool CanRender(const TextureRef* ref) const {
- return ref->texture()->CanRender(feature_info_);
+ return ref->texture()->CanRender(feature_info_.get());
}
// Returns true if mipmaps can be generated by GL.
bool CanGenerateMipmaps(const TextureRef* ref) const {
- return ref->texture()->CanGenerateMipmaps(feature_info_);
+ return ref->texture()->CanGenerateMipmaps(feature_info_.get());
}
// Sets the Texture's target
@@ -587,13 +587,13 @@ class GPU_EXPORT TextureManager {
TextureRef* GetDefaultTextureInfo(GLenum target) {
switch (target) {
case GL_TEXTURE_2D:
- return default_textures_[kTexture2D];
+ return default_textures_[kTexture2D].get();
case GL_TEXTURE_CUBE_MAP:
- return default_textures_[kCubeMap];
+ return default_textures_[kCubeMap].get();
case GL_TEXTURE_EXTERNAL_OES:
- return default_textures_[kExternalOES];
+ return default_textures_[kExternalOES].get();
case GL_TEXTURE_RECTANGLE_ARB:
- return default_textures_[kRectangleARB];
+ return default_textures_[kRectangleARB].get();
default:
NOTREACHED();
return NULL;
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index b5a0e61..758f421 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -110,7 +110,7 @@ TEST_F(TextureManagerTest, Basic) {
manager_->CreateTexture(kClient1Id, kService1Id);
// Check texture got created.
scoped_refptr<TextureRef> texture = manager_->GetTexture(kClient1Id);
- ASSERT_TRUE(texture != NULL);
+ ASSERT_TRUE(texture.get() != NULL);
EXPECT_EQ(kService1Id, texture->service_id());
EXPECT_EQ(kClient1Id, texture->client_id());
EXPECT_EQ(texture->texture(), manager_->GetTextureForServiceId(
@@ -444,21 +444,20 @@ class TextureMemoryTrackerTest : public TextureTestBase {
scoped_refptr<MockMemoryTracker> mock_memory_tracker_;
};
-#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size, pool) \
- EXPECT_CALL(*mock_memory_tracker_, \
- TrackMemoryAllocatedChange(old_size, new_size, pool)) \
- .Times(1) \
- .RetiresOnSaturation() \
+#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size, pool) \
+ EXPECT_CALL(*mock_memory_tracker_.get(), \
+ TrackMemoryAllocatedChange(old_size, new_size, pool)) \
+ .Times(1).RetiresOnSaturation()
TEST_F(TextureTest, Basic) {
Texture* texture = texture_ref_->texture();
EXPECT_EQ(0u, texture->target());
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_EQ(0, texture->num_uncleared_mips());
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(texture->IsImmutable());
EXPECT_EQ(static_cast<GLenum>(GL_NEAREST_MIPMAP_LINEAR),
@@ -473,75 +472,139 @@ TEST_F(TextureTest, Basic) {
TEST_F(TextureTest, SetTargetTexture2D) {
Texture* texture = texture_ref_->texture();
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(texture->IsImmutable());
}
TEST_F(TextureTest, SetTargetTextureExternalOES) {
Texture* texture = texture_ref_->texture();
- manager_->SetTarget(texture_ref_, GL_TEXTURE_EXTERNAL_OES);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
EXPECT_TRUE(TextureTestHelper::IsNPOT(texture));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_TRUE(texture->IsImmutable());
- manager_->SetStreamTexture(texture_ref_, true);
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ manager_->SetStreamTexture(texture_ref_.get(), true);
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
}
TEST_F(TextureTest, ZeroSizeCanNotRender) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 0,
+ 0,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
}
TEST_F(TextureTest, EstimatedSize) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 8,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_EQ(8u * 4u * 4u, texture_ref_->texture()->estimated_size());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 2, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 2,
+ GL_RGBA,
+ 8,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_EQ(8u * 4u * 4u * 2u, texture_ref_->texture()->estimated_size());
}
TEST_F(TextureMemoryTrackerTest, EstimatedSize) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 128, MemoryTracker::kUnmanaged);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 8,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_MEMORY_ALLOCATION_CHANGE(128, 0, MemoryTracker::kUnmanaged);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 256, MemoryTracker::kUnmanaged);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 2, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 2,
+ GL_RGBA,
+ 8,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
// Add expectation for texture deletion.
EXPECT_MEMORY_ALLOCATION_CHANGE(256, 0, MemoryTracker::kUnmanaged);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 0, MemoryTracker::kUnmanaged);
}
TEST_F(TextureMemoryTrackerTest, SetParameterPool) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 128, MemoryTracker::kUnmanaged);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 8,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_MEMORY_ALLOCATION_CHANGE(128, 0, MemoryTracker::kUnmanaged);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 128, MemoryTracker::kManaged);
- SetParameter(
- texture_ref_, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_MANAGED_CHROMIUM,
- GL_NO_ERROR);
+ SetParameter(texture_ref_.get(),
+ GL_TEXTURE_POOL_CHROMIUM,
+ GL_TEXTURE_POOL_MANAGED_CHROMIUM,
+ GL_NO_ERROR);
// Add expectation for texture deletion.
EXPECT_MEMORY_ALLOCATION_CHANGE(128, 0, MemoryTracker::kManaged);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 0, MemoryTracker::kUnmanaged);
@@ -549,119 +612,206 @@ TEST_F(TextureMemoryTrackerTest, SetParameterPool) {
}
TEST_F(TextureTest, POT2D) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target());
// Check Setting level 0 to POT
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_EQ(0, texture->num_uncleared_mips());
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
// Set filters to something that will work with a single mip.
- SetParameter(texture_ref_, GL_TEXTURE_MIN_FILTER, GL_LINEAR, GL_NO_ERROR);
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR, GL_NO_ERROR);
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
// Set them back.
- SetParameter(texture_ref_, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_LINEAR, GL_NO_ERROR);
+ SetParameter(texture_ref_.get(),
+ GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR,
+ GL_NO_ERROR);
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
// Make mips.
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
// Change a mip.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
// Set a level past the number of mips that would get generated.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 3,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
// Make mips.
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
}
TEST_F(TextureMemoryTrackerTest, MarkMipmapsGenerated) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 64, MemoryTracker::kUnmanaged);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_MEMORY_ALLOCATION_CHANGE(64, 0, MemoryTracker::kUnmanaged);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 84, MemoryTracker::kUnmanaged);
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_MEMORY_ALLOCATION_CHANGE(84, 0, MemoryTracker::kUnmanaged);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 0, MemoryTracker::kUnmanaged);
}
TEST_F(TextureTest, UnusedMips) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target());
// Set level zero to large size.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
// Set level zero to large smaller (levels unused mips)
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
// Set an unused level to some size
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 4, GL_RGBA, 16, 16, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 4,
+ GL_RGBA,
+ 16,
+ 16,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
}
TEST_F(TextureTest, NPOT2D) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target());
// Check Setting level 0 to NPOT
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 5,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_TRUE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- SetParameter(texture_ref_, GL_TEXTURE_MIN_FILTER, GL_LINEAR, GL_NO_ERROR);
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR, GL_NO_ERROR);
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- SetParameter(texture_ref_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- SetParameter(texture_ref_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
// Change it to POT.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
}
@@ -695,95 +845,168 @@ TEST_F(TextureTest, NPOT2DNPOTOK) {
}
TEST_F(TextureTest, POTCubeMap) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_CUBE_MAP);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_CUBE_MAP);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), texture->target());
// Check Setting level 0 each face to POT
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_POSITIVE_X,
- 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
- 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
- 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
- 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
- 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_TRUE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
- EXPECT_FALSE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
+ EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
// Make mips.
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_TRUE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_TRUE(manager_->CanRender(texture_ref_));
+ EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
// Change a mip.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
- 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+ 1,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_FALSE(TextureTestHelper::IsNPOT(texture));
EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_TRUE(TextureTestHelper::IsCubeComplete(texture));
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
// Set a level past the number of mips that would get generated.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
- 3, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+ 3,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get()));
// Make mips.
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_TRUE(TextureTestHelper::IsCubeComplete(texture));
}
TEST_F(TextureTest, GetLevelSize) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 5,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
GLsizei width = -1;
GLsizei height = -1;
Texture* texture = texture_ref_->texture();
@@ -800,9 +1023,18 @@ TEST_F(TextureTest, GetLevelSize) {
}
TEST_F(TextureTest, GetLevelType) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 5,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
GLenum type = -1;
GLenum format = -1;
Texture* texture = texture_ref_->texture();
@@ -819,9 +1051,18 @@ TEST_F(TextureTest, GetLevelType) {
}
TEST_F(TextureTest, ValidForTexture) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 5,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
// Check bad face.
Texture* texture = texture_ref_->texture();
EXPECT_FALSE(texture->ValidForTexture(
@@ -1000,54 +1241,99 @@ TEST_F(TextureTest, SafeUnsafe) {
EXPECT_FALSE(manager_->HaveUnclearedMips());
Texture* texture = texture_ref_->texture();
EXPECT_EQ(0, texture->num_uncleared_mips());
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(1, texture->num_uncleared_mips());
- manager_->SetLevelCleared(texture_ref_, GL_TEXTURE_2D, 0, true);
+ manager_->SetLevelCleared(texture_ref_.get(), GL_TEXTURE_2D, 0, true);
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
EXPECT_EQ(0, texture->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 8,
+ 8,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(1, texture->num_uncleared_mips());
- manager_->SetLevelCleared(texture_ref_, GL_TEXTURE_2D, 1, true);
+ manager_->SetLevelCleared(texture_ref_.get(), GL_TEXTURE_2D, 1, true);
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
EXPECT_EQ(0, texture->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 8,
+ 8,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(2, texture->num_uncleared_mips());
- manager_->SetLevelCleared(texture_ref_, GL_TEXTURE_2D, 0, true);
+ manager_->SetLevelCleared(texture_ref_.get(), GL_TEXTURE_2D, 0, true);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(1, texture->num_uncleared_mips());
- manager_->SetLevelCleared(texture_ref_, GL_TEXTURE_2D, 1, true);
+ manager_->SetLevelCleared(texture_ref_.get(), GL_TEXTURE_2D, 1, true);
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
EXPECT_EQ(0, texture->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 8,
+ 8,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(1, texture->num_uncleared_mips());
- manager_->MarkMipmapsGenerated(texture_ref_);
+ manager_->MarkMipmapsGenerated(texture_ref_.get());
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
@@ -1057,18 +1343,36 @@ TEST_F(TextureTest, SafeUnsafe) {
scoped_refptr<TextureRef> texture_ref2(
manager_->GetTexture(kClient2Id));
ASSERT_TRUE(texture_ref2.get() != NULL);
- manager_->SetTarget(texture_ref2, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref2.get(), GL_TEXTURE_2D);
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
Texture* texture2 = texture_ref2->texture();
EXPECT_EQ(0, texture2->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref2,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref2.get(),
+ 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, texture2->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref2,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref2.get(),
+ 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, texture2->num_uncleared_mips());
@@ -1077,26 +1381,53 @@ TEST_F(TextureTest, SafeUnsafe) {
scoped_refptr<TextureRef> texture_ref3(
manager_->GetTexture(kClient3Id));
ASSERT_TRUE(texture_ref3.get() != NULL);
- manager_->SetTarget(texture_ref3, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref3,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetTarget(texture_ref3.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref3.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 8,
+ 8,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
Texture* texture3 = texture_ref3->texture();
EXPECT_EQ(1, texture3->num_uncleared_mips());
- manager_->SetLevelCleared(texture_ref2, GL_TEXTURE_2D, 0, true);
+ manager_->SetLevelCleared(texture_ref2.get(), GL_TEXTURE_2D, 0, true);
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(0, texture2->num_uncleared_mips());
- manager_->SetLevelCleared(texture_ref3, GL_TEXTURE_2D, 0, true);
+ manager_->SetLevelCleared(texture_ref3.get(), GL_TEXTURE_2D, 0, true);
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
EXPECT_EQ(0, texture3->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref2,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_->SetLevelInfo(texture_ref3,
- GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref2.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 8,
+ 8,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
+ manager_->SetLevelInfo(texture_ref3.get(),
+ 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, texture2->num_uncleared_mips());
@@ -1124,35 +1455,73 @@ TEST_F(TextureTest, SafeUnsafe) {
TEST_F(TextureTest, ClearTexture) {
EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _))
.WillRepeatedly(Return(true));
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
Texture* texture = texture_ref_->texture();
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(2, texture->num_uncleared_mips());
- manager_->ClearRenderableLevels(decoder_.get(), texture_ref_);
+ manager_->ClearRenderableLevels(decoder_.get(), texture_ref_.get());
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
EXPECT_EQ(0, texture->num_uncleared_mips());
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(2, texture->num_uncleared_mips());
- manager_->ClearTextureLevel(decoder_.get(), texture_ref_, GL_TEXTURE_2D, 0);
+ manager_->ClearTextureLevel(
+ decoder_.get(), texture_ref_.get(), GL_TEXTURE_2D, 0);
EXPECT_FALSE(texture->SafeToRenderFrom());
EXPECT_TRUE(manager_->HaveUnsafeTextures());
EXPECT_TRUE(manager_->HaveUnclearedMips());
EXPECT_EQ(1, texture->num_uncleared_mips());
- manager_->ClearTextureLevel(decoder_.get(), texture_ref_, GL_TEXTURE_2D, 1);
+ manager_->ClearTextureLevel(
+ decoder_.get(), texture_ref_.get(), GL_TEXTURE_2D, 1);
EXPECT_TRUE(texture->SafeToRenderFrom());
EXPECT_FALSE(manager_->HaveUnsafeTextures());
EXPECT_FALSE(manager_->HaveUnclearedMips());
@@ -1163,25 +1532,43 @@ TEST_F(TextureTest, UseDeletedTexture) {
static const GLuint kClient2Id = 2;
static const GLuint kService2Id = 12;
// Make the default texture renderable
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ 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_->CreateTexture(kClient2Id, kService2Id);
scoped_refptr<TextureRef> texture_ref(
manager_->GetTexture(kClient2Id));
- manager_->SetTarget(texture_ref, GL_TEXTURE_2D);
- EXPECT_FALSE(manager_->CanRender(texture_ref));
+ manager_->SetTarget(texture_ref.get(), GL_TEXTURE_2D);
+ EXPECT_FALSE(manager_->CanRender(texture_ref.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
// Remove it.
manager_->RemoveTexture(kClient2Id);
- EXPECT_FALSE(manager_->CanRender(texture_ref));
+ EXPECT_FALSE(manager_->CanRender(texture_ref.get()));
EXPECT_TRUE(manager_->HaveUnrenderableTextures());
// Check that we can still manipulate it and it effects the manager.
- manager_->SetLevelInfo(texture_ref,
- GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
- EXPECT_TRUE(manager_->CanRender(texture_ref));
+ manager_->SetLevelInfo(texture_ref.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
+ EXPECT_TRUE(manager_->CanRender(texture_ref.get()));
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService2Id)))
.Times(1)
@@ -1190,23 +1577,41 @@ TEST_F(TextureTest, UseDeletedTexture) {
}
TEST_F(TextureTest, GetLevelImage) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
Texture* texture = texture_ref_->texture();
EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
// Set image.
- manager_->SetLevelImage(texture_ref_,
- GL_TEXTURE_2D, 1, gfx::GLImage::CreateGLImage(0));
+ manager_->SetLevelImage(
+ texture_ref_.get(), GL_TEXTURE_2D, 1, gfx::GLImage::CreateGLImage(0));
EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
// Remove it.
- manager_->SetLevelImage(texture_ref_, GL_TEXTURE_2D, 1, NULL);
+ manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, NULL);
EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
- manager_->SetLevelImage(texture_ref_,
- GL_TEXTURE_2D, 1, gfx::GLImage::CreateGLImage(0));
+ manager_->SetLevelImage(
+ texture_ref_.get(), GL_TEXTURE_2D, 1, gfx::GLImage::CreateGLImage(0));
// Image should be reset when SetLevelInfo is called.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL);
}
@@ -1221,105 +1626,200 @@ bool InSet(std::set<std::string>* string_set, const std::string& str) {
} // anonymous namespace
TEST_F(TextureTest, AddToSignature) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
std::string signature1;
std::string signature2;
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature1);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature1);
std::set<std::string> string_set;
EXPECT_FALSE(InSet(&string_set, signature1));
// check changing 1 thing makes a different signature.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 4, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 4,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
// check putting it back makes the same signature.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_EQ(signature1, signature2);
// Check setting cleared status does not change signature.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_EQ(signature1, signature2);
// Check changing other settings changes signature.
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 4,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 2,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 1,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_FLOAT,
- false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_FLOAT,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
// put it back
- manager_->SetLevelInfo(texture_ref_,
- GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- false);
+ manager_->SetLevelInfo(texture_ref_.get(),
+ GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 2,
+ 2,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_EQ(signature1, signature2);
// check changing parameters changes signature.
- SetParameter(texture_ref_, GL_TEXTURE_MIN_FILTER, GL_NEAREST, GL_NO_ERROR);
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_NEAREST, GL_NO_ERROR);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- SetParameter(texture_ref_, GL_TEXTURE_MIN_FILTER,
- GL_NEAREST_MIPMAP_LINEAR, GL_NO_ERROR);
- SetParameter(texture_ref_, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR);
+ SetParameter(texture_ref_.get(),
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST_MIPMAP_LINEAR,
+ GL_NO_ERROR);
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- SetParameter(texture_ref_, GL_TEXTURE_MAG_FILTER, GL_LINEAR, GL_NO_ERROR);
- SetParameter(texture_ref_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_MAG_FILTER, GL_LINEAR, GL_NO_ERROR);
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
- SetParameter(texture_ref_, GL_TEXTURE_WRAP_S, GL_REPEAT, GL_NO_ERROR);
- SetParameter(texture_ref_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
+ SetParameter(texture_ref_.get(), GL_TEXTURE_WRAP_S, GL_REPEAT, GL_NO_ERROR);
+ SetParameter(
+ texture_ref_.get(), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE, GL_NO_ERROR);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_FALSE(InSet(&string_set, signature2));
// Check putting it back genenerates the same signature
- SetParameter(texture_ref_, GL_TEXTURE_WRAP_T, GL_REPEAT, GL_NO_ERROR);
+ SetParameter(texture_ref_.get(), GL_TEXTURE_WRAP_T, GL_REPEAT, GL_NO_ERROR);
signature2.clear();
- manager_->AddToSignature(texture_ref_, GL_TEXTURE_2D, 1, &signature2);
+ manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
EXPECT_EQ(signature1, signature2);
// Check the set was acutally getting different signatures.
@@ -1450,27 +1950,27 @@ const GLuint ProduceConsumeTextureTest::kClient2Id = 2;
const GLuint ProduceConsumeTextureTest::kService2Id = 12;
TEST_F(ProduceConsumeTextureTest, ProduceConsume2D) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target());
LevelInfo level0(
GL_TEXTURE_2D, GL_RGBA, 4, 4, 1, 0, GL_UNSIGNED_BYTE, true);
- SetLevelInfo(texture_ref_, 0, level0);
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_));
+ SetLevelInfo(texture_ref_.get(), 0, level0);
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get()));
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
LevelInfo level1 = GetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1);
LevelInfo level2 = GetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 2);
- Texture* produced_texture = Produce(texture_ref_);
+ Texture* produced_texture = Produce(texture_ref_.get());
EXPECT_EQ(produced_texture, texture);
// Make this texture bigger with more levels, and make sure they get
// clobbered correctly during Consume().
- manager_->SetTarget(texture2_, GL_TEXTURE_2D);
+ manager_->SetTarget(texture2_.get(), GL_TEXTURE_2D);
SetLevelInfo(
- texture2_,
+ texture2_.get(),
0,
LevelInfo(GL_TEXTURE_2D, GL_RGBA, 16, 16, 1, 0, GL_UNSIGNED_BYTE, false));
- EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture2_));
+ EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture2_.get()));
texture = texture2_->texture();
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
EXPECT_EQ(1024U + 256U + 64U + 16U + 4U, texture->estimated_size());
@@ -1494,14 +1994,14 @@ TEST_F(ProduceConsumeTextureTest, ProduceConsume2D) {
}
TEST_F(ProduceConsumeTextureTest, ProduceConsumeClearRectangle) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_RECTANGLE_ARB);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_RECTANGLE_ARB);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), texture->target());
LevelInfo level0(
GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, 1, 1, 1, 0, GL_UNSIGNED_BYTE, false);
- SetLevelInfo(texture_ref_, 0, level0);
+ SetLevelInfo(texture_ref_.get(), 0, level0);
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
- Texture* produced_texture = Produce(texture_ref_);
+ Texture* produced_texture = Produce(texture_ref_.get());
EXPECT_EQ(produced_texture, texture);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB),
produced_texture->target());
@@ -1518,16 +2018,16 @@ TEST_F(ProduceConsumeTextureTest, ProduceConsumeClearRectangle) {
EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _))
.WillRepeatedly(Return(true));
EXPECT_TRUE(manager_->ClearTextureLevel(
- decoder_.get(), restored_texture, GL_TEXTURE_RECTANGLE_ARB, 0));
+ decoder_.get(), restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0));
}
TEST_F(ProduceConsumeTextureTest, ProduceConsumeStreamTexture) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_EXTERNAL_OES);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture->target());
- manager_->SetStreamTexture(texture_ref_, true);
+ manager_->SetStreamTexture(texture_ref_.get(), true);
GLuint service_id = texture->service_id();
- Texture* produced_texture = Produce(texture_ref_);
+ Texture* produced_texture = Produce(texture_ref_.get());
EXPECT_TRUE(texture->IsStreamTexture());
GLuint client_id = texture2_->client_id();
@@ -1541,7 +2041,7 @@ TEST_F(ProduceConsumeTextureTest, ProduceConsumeStreamTexture) {
}
TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {
- manager_->SetTarget(texture_ref_, GL_TEXTURE_CUBE_MAP);
+ manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_CUBE_MAP);
Texture* texture = texture_ref_->texture();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), texture->target());
LevelInfo face0(GL_TEXTURE_CUBE_MAP_POSITIVE_X,
@@ -1560,10 +2060,10 @@ TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {
0,
GL_UNSIGNED_BYTE,
true);
- SetLevelInfo(texture_ref_, 0, face0);
- SetLevelInfo(texture_ref_, 0, face5);
+ SetLevelInfo(texture_ref_.get(), 0, face0);
+ SetLevelInfo(texture_ref_.get(), 0, face5);
EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture));
- Texture* produced_texture = Produce(texture_ref_);
+ Texture* produced_texture = Produce(texture_ref_.get());
EXPECT_EQ(produced_texture, texture);
GLuint client_id = texture2_->client_id();
@@ -1571,10 +2071,12 @@ TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {
Consume(client_id, produced_texture);
scoped_refptr<TextureRef> restored_texture = manager_->GetTexture(client_id);
EXPECT_EQ(produced_texture, restored_texture->texture());
- EXPECT_EQ(face0,
- GetLevelInfo(restored_texture, GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0));
- EXPECT_EQ(face5,
- GetLevelInfo(restored_texture, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0));
+ EXPECT_EQ(
+ face0,
+ GetLevelInfo(restored_texture.get(), GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0));
+ EXPECT_EQ(
+ face5,
+ GetLevelInfo(restored_texture.get(), GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0));
}
class CountingMemoryTracker : public MemoryTracker {
@@ -1621,15 +2123,17 @@ class SharedTextureTest : public testing::Test {
::gfx::GLInterface::SetGLInterface(gl_.get());
memory_tracker1_ = new CountingMemoryTracker;
- texture_manager1_.reset(new TextureManager(
- memory_tracker1_, feature_info_.get(),
- TextureManagerTest::kMaxTextureSize,
- TextureManagerTest::kMaxCubeMapTextureSize));
+ texture_manager1_.reset(
+ new TextureManager(memory_tracker1_.get(),
+ feature_info_.get(),
+ TextureManagerTest::kMaxTextureSize,
+ TextureManagerTest::kMaxCubeMapTextureSize));
memory_tracker2_ = new CountingMemoryTracker;
- texture_manager2_.reset(new TextureManager(
- memory_tracker2_, feature_info_.get(),
- TextureManagerTest::kMaxTextureSize,
- TextureManagerTest::kMaxCubeMapTextureSize));
+ texture_manager2_.reset(
+ new TextureManager(memory_tracker2_.get(),
+ feature_info_.get(),
+ TextureManagerTest::kMaxTextureSize,
+ TextureManagerTest::kMaxCubeMapTextureSize));
TestHelper::SetupTextureManagerInitExpectations(gl_.get(), "");
texture_manager1_->Initialize();
TestHelper::SetupTextureManagerInitExpectations(gl_.get(), "");
@@ -1696,7 +2200,7 @@ TEST_F(SharedTextureTest, TextureSafetyAccounting) {
// Make texture renderable but uncleared on one texture manager, should affect
// other one.
- texture_manager1_->SetTarget(ref1, GL_TEXTURE_2D);
+ texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D);
EXPECT_TRUE(texture_manager1_->HaveUnrenderableTextures());
EXPECT_FALSE(texture_manager1_->HaveUnsafeTextures());
EXPECT_FALSE(texture_manager1_->HaveUnclearedMips());
@@ -1704,8 +2208,17 @@ TEST_F(SharedTextureTest, TextureSafetyAccounting) {
EXPECT_FALSE(texture_manager2_->HaveUnsafeTextures());
EXPECT_FALSE(texture_manager2_->HaveUnclearedMips());
- texture_manager1_->SetLevelInfo(ref1, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, false);
+ texture_manager1_->SetLevelInfo(ref1.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_FALSE(texture_manager1_->HaveUnrenderableTextures());
EXPECT_TRUE(texture_manager1_->HaveUnsafeTextures());
EXPECT_TRUE(texture_manager1_->HaveUnclearedMips());
@@ -1714,7 +2227,7 @@ TEST_F(SharedTextureTest, TextureSafetyAccounting) {
EXPECT_TRUE(texture_manager2_->HaveUnclearedMips());
// Make texture cleared on one texture manager, should affect other one.
- texture_manager1_->SetLevelCleared(ref1, GL_TEXTURE_2D, 0, true);
+ texture_manager1_->SetLevelCleared(ref1.get(), GL_TEXTURE_2D, 0, true);
EXPECT_FALSE(texture_manager1_->HaveUnsafeTextures());
EXPECT_FALSE(texture_manager1_->HaveUnclearedMips());
EXPECT_FALSE(texture_manager2_->HaveUnsafeTextures());
@@ -1738,17 +2251,27 @@ TEST_F(SharedTextureTest, FBOCompletenessCheck) {
framebuffer_manager1.CreateFramebuffer(10, 10);
scoped_refptr<Framebuffer> framebuffer1 =
framebuffer_manager1.GetFramebuffer(10);
- framebuffer1->AttachTexture(GL_COLOR_ATTACHMENT0, ref1, GL_TEXTURE_2D, 0);
- EXPECT_FALSE(framebuffer_manager1.IsComplete(framebuffer1));
+ framebuffer1->AttachTexture(
+ GL_COLOR_ATTACHMENT0, ref1.get(), GL_TEXTURE_2D, 0);
+ EXPECT_FALSE(framebuffer_manager1.IsComplete(framebuffer1.get()));
EXPECT_NE(kCompleteValue, framebuffer1->IsPossiblyComplete());
// Make FBO complete in manager 1.
- texture_manager1_->SetTarget(ref1, GL_TEXTURE_2D);
- texture_manager1_->SetLevelInfo(ref1, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, true);
+ texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D);
+ texture_manager1_->SetLevelInfo(ref1.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
EXPECT_EQ(kCompleteValue, framebuffer1->IsPossiblyComplete());
- framebuffer_manager1.MarkAsComplete(framebuffer1);
- EXPECT_TRUE(framebuffer_manager1.IsComplete(framebuffer1));
+ framebuffer_manager1.MarkAsComplete(framebuffer1.get());
+ EXPECT_TRUE(framebuffer_manager1.IsComplete(framebuffer1.get()));
// Share texture with manager 2.
scoped_refptr<TextureRef> ref2 =
@@ -1756,23 +2279,33 @@ TEST_F(SharedTextureTest, FBOCompletenessCheck) {
framebuffer_manager2.CreateFramebuffer(20, 20);
scoped_refptr<Framebuffer> framebuffer2 =
framebuffer_manager2.GetFramebuffer(20);
- framebuffer2->AttachTexture(GL_COLOR_ATTACHMENT0, ref2, GL_TEXTURE_2D, 0);
- EXPECT_FALSE(framebuffer_manager2.IsComplete(framebuffer2));
+ framebuffer2->AttachTexture(
+ GL_COLOR_ATTACHMENT0, ref2.get(), GL_TEXTURE_2D, 0);
+ EXPECT_FALSE(framebuffer_manager2.IsComplete(framebuffer2.get()));
EXPECT_EQ(kCompleteValue, framebuffer2->IsPossiblyComplete());
- framebuffer_manager2.MarkAsComplete(framebuffer2);
- EXPECT_TRUE(framebuffer_manager2.IsComplete(framebuffer2));
+ framebuffer_manager2.MarkAsComplete(framebuffer2.get());
+ EXPECT_TRUE(framebuffer_manager2.IsComplete(framebuffer2.get()));
// Change level for texture, both FBOs should be marked incomplete
- texture_manager1_->SetLevelInfo(ref1, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, true);
- EXPECT_FALSE(framebuffer_manager1.IsComplete(framebuffer1));
+ texture_manager1_->SetLevelInfo(ref1.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ EXPECT_FALSE(framebuffer_manager1.IsComplete(framebuffer1.get()));
EXPECT_EQ(kCompleteValue, framebuffer1->IsPossiblyComplete());
- framebuffer_manager1.MarkAsComplete(framebuffer1);
- EXPECT_TRUE(framebuffer_manager1.IsComplete(framebuffer1));
- EXPECT_FALSE(framebuffer_manager2.IsComplete(framebuffer2));
+ framebuffer_manager1.MarkAsComplete(framebuffer1.get());
+ EXPECT_TRUE(framebuffer_manager1.IsComplete(framebuffer1.get()));
+ EXPECT_FALSE(framebuffer_manager2.IsComplete(framebuffer2.get()));
EXPECT_EQ(kCompleteValue, framebuffer2->IsPossiblyComplete());
- framebuffer_manager2.MarkAsComplete(framebuffer2);
- EXPECT_TRUE(framebuffer_manager2.IsComplete(framebuffer2));
+ framebuffer_manager2.MarkAsComplete(framebuffer2.get());
+ EXPECT_TRUE(framebuffer_manager2.IsComplete(framebuffer2.get()));
EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _))
.Times(2)
@@ -1792,9 +2325,18 @@ TEST_F(SharedTextureTest, Memory) {
// Newly created texture is unrenderable.
scoped_refptr<TextureRef> ref1 = texture_manager1_->CreateTexture(10, 10);
- texture_manager1_->SetTarget(ref1, GL_TEXTURE_2D);
- texture_manager1_->SetLevelInfo(ref1, GL_TEXTURE_2D, 0, GL_RGBA, 10, 10, 1, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, false);
+ texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D);
+ texture_manager1_->SetLevelInfo(ref1.get(),
+ GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 10,
+ 10,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ false);
EXPECT_LT(0u, ref1->texture()->estimated_size());
EXPECT_EQ(initial_memory1 + ref1->texture()->estimated_size(),
diff --git a/gpu/command_buffer/service/vertex_array_manager.cc b/gpu/command_buffer/service/vertex_array_manager.cc
index 65fa56c..3b94fa7 100644
--- a/gpu/command_buffer/service/vertex_array_manager.cc
+++ b/gpu/command_buffer/service/vertex_array_manager.cc
@@ -47,7 +47,7 @@ VertexAttribManager* VertexArrayManager::GetVertexAttribManager(
void VertexArrayManager::RemoveVertexAttribManager(GLuint client_id) {
VertexAttribManagerMap::iterator it = vertex_attrib_managers_.find(client_id);
if (it != vertex_attrib_managers_.end()) {
- VertexAttribManager* vertex_attrib_manager = it->second;
+ VertexAttribManager* vertex_attrib_manager = it->second.get();
vertex_attrib_manager->MarkAsDeleted();
vertex_attrib_managers_.erase(it);
}
diff --git a/gpu/command_buffer/service/vertex_attrib_manager.cc b/gpu/command_buffer/service/vertex_attrib_manager.cc
index e1ae1c0..86f537e1 100644
--- a/gpu/command_buffer/service/vertex_attrib_manager.cc
+++ b/gpu/command_buffer/service/vertex_attrib_manager.cc
@@ -62,7 +62,7 @@ void VertexAttrib::SetInfo(
}
void VertexAttrib::Unbind(Buffer* buffer) {
- if (buffer_ == buffer) {
+ if (buffer_.get() == buffer) {
buffer_ = NULL;
}
}
@@ -72,7 +72,7 @@ bool VertexAttrib::CanAccess(GLuint index) const {
return true;
}
- if (!buffer_ || buffer_->IsDeleted()) {
+ if (!buffer_.get() || buffer_->IsDeleted()) {
return false;
}
@@ -152,7 +152,7 @@ bool VertexAttribManager::Enable(GLuint index, bool enable) {
}
void VertexAttribManager::Unbind(Buffer* buffer) {
- if (element_array_buffer_ == buffer) {
+ if (element_array_buffer_.get() == buffer) {
element_array_buffer_ = NULL;
}
for (uint32 vv = 0; vv < vertex_attribs_.size(); ++vv) {
diff --git a/gpu/command_buffer/service/vertex_attrib_manager.h b/gpu/command_buffer/service/vertex_attrib_manager.h
index 665f9c8..2eff3cc 100644
--- a/gpu/command_buffer/service/vertex_attrib_manager.h
+++ b/gpu/command_buffer/service/vertex_attrib_manager.h
@@ -35,9 +35,7 @@ class GPU_EXPORT VertexAttrib {
// Returns true if this VertexAttrib can access index.
bool CanAccess(GLuint index) const;
- Buffer* buffer() const {
- return buffer_;
- }
+ Buffer* buffer() const { return buffer_.get(); }
GLsizei offset() const {
return offset_;
@@ -223,9 +221,7 @@ class GPU_EXPORT VertexAttribManager :
void SetElementArrayBuffer(Buffer* buffer);
- Buffer* element_array_buffer() const {
- return element_array_buffer_;
- }
+ Buffer* element_array_buffer() const { return element_array_buffer_.get(); }
GLuint service_id() const {
return service_id_;
diff --git a/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittests.cc b/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittests.cc
index ae2ec10..6f93433 100644
--- a/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittests.cc
+++ b/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittests.cc
@@ -43,7 +43,7 @@ class MockGpuMemoryBufferTest : public testing::Test {
image_manager_ = new ImageManager;
image_factory_.reset(
new StrictMock<ImageFactoryMock>(image_manager_));
- options.image_manager = image_manager_;
+ options.image_manager = image_manager_.get();
options.image_factory = image_factory_.get();
gl_.Initialize(options);
@@ -116,13 +116,9 @@ TEST_F(MockGpuMemoryBufferTest, Lifecycle) {
// Bind the texture and the image.
glBindTexture(GL_TEXTURE_2D, texture_id);
- EXPECT_CALL(*gl_image, BindTexImage())
- .Times(1)
- .WillOnce(Return(true))
+ EXPECT_CALL(*gl_image.get(), BindTexImage()).Times(1).WillOnce(Return(true))
.RetiresOnSaturation();
- EXPECT_CALL(*gl_image, GetSize())
- .Times(1)
- .WillOnce(Return(size))
+ EXPECT_CALL(*gl_image.get(), GetSize()).Times(1).WillOnce(Return(size))
.RetiresOnSaturation();
glBindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id);
diff --git a/gpu/config/gpu_control_list.cc b/gpu/config/gpu_control_list.cc
index f5139db..67e3368 100644
--- a/gpu/config/gpu_control_list.cc
+++ b/gpu/config/gpu_control_list.cc
@@ -758,7 +758,7 @@ GpuControlList::GpuControlListEntry::GetEntryFromValue(
}
ScopedGpuControlListEntry exception(GetEntryFromValue(
exception_value, false, feature_map, supports_feature_type_all));
- if (exception == NULL) {
+ if (exception.get() == NULL) {
LOG(WARNING) << "Malformed exceptions entry " << entry->id();
return NULL;
}
@@ -1225,7 +1225,7 @@ bool GpuControlList::LoadList(const base::DictionaryValue& parsed_json,
DCHECK(browser_version_support == kSupported);
ScopedGpuControlListEntry entry(GpuControlListEntry::GetEntryFromValue(
list_item, true, feature_map_, supports_feature_type_all_));
- if (entry == NULL)
+ if (entry.get() == NULL)
return false;
if (entry->id() > max_entry_id)
max_entry_id = entry->id();
@@ -1305,7 +1305,7 @@ void GpuControlList::GetDecisionEntries(
void GpuControlList::GetReasons(base::ListValue* problem_list) const {
DCHECK(problem_list);
for (size_t i = 0; i < active_entries_.size(); ++i) {
- GpuControlListEntry* entry = active_entries_[i];
+ GpuControlListEntry* entry = active_entries_[i].get();
if (entry->disabled())
continue;
base::DictionaryValue* problem = new base::DictionaryValue();
diff --git a/gpu/config/gpu_control_list_entry_unittest.cc b/gpu/config/gpu_control_list_entry_unittest.cc
index b4505bc..8991334 100644
--- a/gpu/config/gpu_control_list_entry_unittest.cc
+++ b/gpu/config/gpu_control_list_entry_unittest.cc
@@ -94,7 +94,7 @@ TEST_F(GpuControlListEntryTest, DetailedEntry) {
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
EXPECT_FALSE(entry->disabled());
EXPECT_EQ(5u, entry->id());
@@ -124,7 +124,7 @@ TEST_F(GpuControlListEntryTest, VendorOnAllOsEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType());
const GpuControlList::OsType os_type[] = {
@@ -152,7 +152,7 @@ TEST_F(GpuControlListEntryTest, VendorOnLinuxEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
const GpuControlList::OsType os_type[] = {
@@ -185,7 +185,7 @@ TEST_F(GpuControlListEntryTest, AllExceptNVidiaOnLinuxEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
const GpuControlList::OsType os_type[] = {
@@ -217,7 +217,7 @@ TEST_F(GpuControlListEntryTest, AllExceptIntelOnLinuxEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
const GpuControlList::OsType os_type[] = {
@@ -249,7 +249,7 @@ TEST_F(GpuControlListEntryTest, DateOnWindowsEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsWin, entry->GetOsType());
GPUInfo gpu_info;
@@ -276,7 +276,7 @@ TEST_F(GpuControlListEntryTest, MultipleDevicesEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType());
const GpuControlList::OsType os_type[] = {
@@ -303,7 +303,7 @@ TEST_F(GpuControlListEntryTest, ChromeOSEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsChromeOS, entry->GetOsType());
const GpuControlList::OsType os_type[] = {
@@ -329,7 +329,7 @@ TEST_F(GpuControlListEntryTest, MalformedVendor) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry == NULL);
+ EXPECT_TRUE(entry.get() == NULL);
}
TEST_F(GpuControlListEntryTest, UnknownFieldEntry) {
@@ -343,7 +343,7 @@ TEST_F(GpuControlListEntryTest, UnknownFieldEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_TRUE(entry->contains_unknown_fields());
EXPECT_FALSE(entry->contains_unknown_features());
}
@@ -363,7 +363,7 @@ TEST_F(GpuControlListEntryTest, UnknownExceptionFieldEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_TRUE(entry->contains_unknown_fields());
EXPECT_FALSE(entry->contains_unknown_features());
}
@@ -379,7 +379,7 @@ TEST_F(GpuControlListEntryTest, UnknownFeatureEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_FALSE(entry->contains_unknown_fields());
EXPECT_TRUE(entry->contains_unknown_features());
EXPECT_EQ(1u, entry->features().size());
@@ -410,7 +410,7 @@ TEST_F(GpuControlListEntryTest, GlVendorEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
const GpuControlList::OsType os_type[] = {
GpuControlList::kOsMacosx,
@@ -437,7 +437,7 @@ TEST_F(GpuControlListEntryTest, GlRendererEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
const GpuControlList::OsType os_type[] = {
GpuControlList::kOsMacosx,
@@ -464,9 +464,8 @@ TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
- EXPECT_TRUE(entry->Contains(
- GpuControlList::kOsWin, "10.6", gpu_info()));
+ EXPECT_TRUE(entry.get() != NULL);
+ EXPECT_TRUE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info()));
}
TEST_F(GpuControlListEntryTest, PerfGamingEntry) {
@@ -483,9 +482,8 @@ TEST_F(GpuControlListEntryTest, PerfGamingEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
- EXPECT_FALSE(entry->Contains(
- GpuControlList::kOsWin, "10.6", gpu_info()));
+ EXPECT_TRUE(entry.get() != NULL);
+ EXPECT_FALSE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info()));
}
TEST_F(GpuControlListEntryTest, PerfOverallEntry) {
@@ -503,9 +501,8 @@ TEST_F(GpuControlListEntryTest, PerfOverallEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
- EXPECT_TRUE(entry->Contains(
- GpuControlList::kOsWin, "10.6", gpu_info()));
+ EXPECT_TRUE(entry.get() != NULL);
+ EXPECT_TRUE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info()));
}
TEST_F(GpuControlListEntryTest, DisabledEntry) {
@@ -519,7 +516,7 @@ TEST_F(GpuControlListEntryTest, DisabledEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_TRUE(entry->disabled());
}
@@ -540,7 +537,7 @@ TEST_F(GpuControlListEntryTest, OptimusEntry) {
gpu_info.optimus = true;
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
EXPECT_TRUE(entry->Contains(
GpuControlList::kOsLinux, "10.6", gpu_info));
@@ -563,7 +560,7 @@ TEST_F(GpuControlListEntryTest, AMDSwitchableEntry) {
gpu_info.amd_switchable = true;
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
EXPECT_TRUE(entry->Contains(
GpuControlList::kOsMacosx, "10.6", gpu_info));
@@ -591,7 +588,7 @@ TEST_F(GpuControlListEntryTest, LexicalDriverVersionEntry) {
gpu_info.gpu.vendor_id = 0x1002;
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
gpu_info.driver_version = "8.76";
@@ -623,7 +620,7 @@ TEST_F(GpuControlListEntryTest, MultipleGPUsAnyEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
GPUInfo gpu_info;
@@ -656,7 +653,7 @@ TEST_F(GpuControlListEntryTest, MultipleGPUsSecondaryEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
GPUInfo gpu_info;
@@ -688,7 +685,7 @@ TEST_F(GpuControlListEntryTest, NeedsMoreInfoEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x8086;
@@ -717,7 +714,7 @@ TEST_F(GpuControlListEntryTest, NeedsMoreInfoForExceptionsEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x8086;
@@ -737,7 +734,7 @@ TEST_F(GpuControlListEntryTest, FeatureTypeAllEntry) {
}
);
ScopedEntry entry(GetEntryFromString(json, true));
- EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(entry.get() != NULL);
EXPECT_EQ(3u, entry->features().size());
EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0));
EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_1));
diff --git a/gpu/config/gpu_info_collector.cc b/gpu/config/gpu_info_collector.cc
index e141e57..7540dd8 100644
--- a/gpu/config/gpu_info_collector.cc
+++ b/gpu/config/gpu_info_collector.cc
@@ -23,7 +23,7 @@ namespace {
scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
scoped_refptr<gfx::GLSurface> surface(
gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)));
- if (!surface) {
+ if (!surface.get()) {
LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
return NULL;
}
@@ -37,7 +37,7 @@ scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
gfx::GLContext::CreateGLContext(NULL,
surface,
gfx::PreferIntegratedGpu));
- if (!context) {
+ if (!context.get()) {
LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
return NULL;
}
@@ -88,11 +88,11 @@ bool CollectGraphicsInfoGL(GPUInfo* gpu_info) {
}
scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
- if (!surface)
+ if (!surface.get())
return false;
scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
- if (!context)
+ if (!context.get())
return false;
gpu_info->gl_renderer = GetGLString(GL_RENDERER);
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index 6eb6eab..9df88e5 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -142,7 +142,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config,
if (!gl_context_.get())
return EGL_NO_SURFACE;
- gl_context_->MakeCurrent(gl_surface_);
+ gl_context_->MakeCurrent(gl_surface_.get());
EGLint depth_size = 0;
EGLint alpha_size = 0;