Index: content/common/gpu/texture_image_transport_surface.cc |
diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc |
index 4ad192e0213517e22becf6480779fec264aa2faa..db986cba351c091a59ff79e099b908cf91b7f7d5 100644 |
--- a/content/common/gpu/texture_image_transport_surface.cc |
+++ b/content/common/gpu/texture_image_transport_surface.cc |
@@ -1,4 +1,3 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
apatrick_chromium
2012/11/09 19:19:04
Deleted this line?
no sievers
2012/11/09 21:53:02
Oops done.
|
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -16,17 +15,19 @@ |
#include "content/public/common/content_switches.h" |
#include "gpu/command_buffer/service/context_group.h" |
#include "gpu/command_buffer/service/gpu_scheduler.h" |
-#include "gpu/command_buffer/service/texture_manager.h" |
+#include "gpu/command_buffer/service/texture_definition.h" |
using gpu::gles2::ContextGroup; |
+using gpu::gles2::MailboxManager; |
+using gpu::gles2::MailboxName; |
+using gpu::gles2::TextureDefinition; |
using gpu::gles2::TextureManager; |
-typedef TextureManager::TextureInfo TextureInfo; |
namespace content { |
TextureImageTransportSurface::Texture::Texture() |
- : client_id(0), |
- sent_to_client(false) { |
+ : service_id(0), |
+ identifier(0) { |
} |
TextureImageTransportSurface::Texture::~Texture() { |
@@ -37,17 +38,12 @@ TextureImageTransportSurface::TextureImageTransportSurface( |
GpuCommandBufferStub* stub, |
const gfx::GLSurfaceHandle& handle) |
: fbo_id_(0), |
- front_(0), |
stub_destroyed_(false), |
backbuffer_suggested_allocation_(true), |
frontbuffer_suggested_allocation_(true), |
- frontbuffer_is_protected_(true), |
- protection_state_id_(0), |
handle_(handle), |
- parent_stub_(NULL), |
is_swap_buffers_pending_(false), |
- did_unschedule_(false), |
- did_flip_(false) { |
+ did_unschedule_(false) { |
helper_.reset(new ImageTransportHelper(this, |
manager, |
stub, |
@@ -60,39 +56,12 @@ TextureImageTransportSurface::~TextureImageTransportSurface() { |
} |
bool TextureImageTransportSurface::Initialize() { |
- GpuChannelManager* manager = helper_->manager(); |
- GpuChannel* parent_channel = manager->LookupChannel(handle_.parent_client_id); |
- if (!parent_channel) |
- return false; |
- |
- parent_stub_ = parent_channel->LookupCommandBuffer(handle_.parent_context_id); |
- if (!parent_stub_) |
- return false; |
+ mailbox_manager_ = |
+ helper_->stub()->decoder()->GetContextGroup()->mailbox_manager(); |
- parent_stub_->AddDestructionObserver(this); |
- TextureManager* texture_manager = |
- parent_stub_->decoder()->GetContextGroup()->texture_manager(); |
- DCHECK(texture_manager); |
- |
- for (int i = 0; i < 2; ++i) { |
- Texture& texture = textures_[i]; |
- texture.client_id = handle_.parent_texture_id[i]; |
- texture.info = texture_manager->GetTextureInfo(texture.client_id); |
- if (!texture.info) |
- return false; |
- |
- if (!texture.info->target()) |
- texture_manager->SetInfoTarget(texture.info, GL_TEXTURE_2D); |
- texture_manager->SetParameter( |
- texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
- texture_manager->SetParameter( |
- texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
- texture_manager->SetParameter( |
- texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
- texture_manager->SetParameter( |
- texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
- } |
+ backbuffer_.identifier = 1; |
+ GpuChannelManager* manager = helper_->manager(); |
surface_ = manager->GetDefaultOffscreenSurface(); |
if (!surface_.get()) |
return false; |
@@ -100,19 +69,18 @@ bool TextureImageTransportSurface::Initialize() { |
if (!helper_->Initialize()) |
return false; |
- const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
- if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) |
- helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); |
+ // TODO: Move this somewhere else. |
jonathan.backer
2012/11/12 16:52:15
Not sure it belongs anywhere else. We only want pr
no sievers
2012/11/19 20:30:44
I've removed the TODO for now. But maybe a more ge
piman
2012/11/19 22:09:52
The preemption concept is orthogonal to whether we
|
+ GpuChannel* parent_channel = manager->LookupChannel(handle_.parent_client_id); |
+ if (parent_channel) { |
+ const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) |
+ helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); |
+ } |
return true; |
} |
void TextureImageTransportSurface::Destroy() { |
- if (parent_stub_) { |
- parent_stub_->decoder()->MakeCurrent(); |
- ReleaseParentStub(); |
- } |
- |
if (surface_.get()) |
surface_ = NULL; |
@@ -152,7 +120,8 @@ bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
if (!fbo_id_) { |
glGenFramebuffersEXT(1, &fbo_id_); |
glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_id_); |
apatrick_chromium
2012/11/09 19:19:04
This changes the FBO binding for the context and i
no sievers
2012/11/09 21:53:02
Hmm if it's a problem, it should exist before my p
piman
2012/11/09 22:02:01
It's probably not a problem, since this codes exec
jonathan.backer
2012/11/12 16:52:15
So this is the first time that MakeCurrent is ever
piman
2012/11/19 22:09:52
Yes.
|
- CreateBackTexture(gfx::Size(1, 1)); |
+ current_size_ = gfx::Size(1, 1); |
+ CreateBackTexture(); |
#ifndef NDEBUG |
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
@@ -183,11 +152,10 @@ void TextureImageTransportSurface::SetBackbufferAllocation(bool allocation) { |
return; |
if (backbuffer_suggested_allocation_) { |
- DCHECK(!textures_[back()].info->service_id() || |
- !textures_[back()].sent_to_client); |
- CreateBackTexture(textures_[back()].size); |
+ DCHECK(!backbuffer_.service_id); |
+ CreateBackTexture(); |
} else { |
- ReleaseTexture(back()); |
+ ReleaseBackBuffer(); |
} |
} |
@@ -199,18 +167,13 @@ void TextureImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
} |
void TextureImageTransportSurface::AdjustFrontBufferAllocation() { |
+ DCHECK(!is_swap_buffers_pending_); |
piman
2012/11/09 22:02:01
I don't think this check is valid. This can be cal
no sievers
2012/11/19 20:30:44
Done.
|
if (!helper_->MakeCurrent()) |
piman
2012/11/09 22:02:01
We don't need this anymore.
no sievers
2012/11/19 20:30:44
Done.
|
return; |
- if (!frontbuffer_suggested_allocation_ && !frontbuffer_is_protected_ && |
- textures_[front()].info->service_id()) { |
- ReleaseTexture(front()); |
- if (textures_[front()].sent_to_client) { |
- GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
- params.identifier = textures_[front()].client_id; |
- helper_->SendAcceleratedSurfaceRelease(params); |
- textures_[front()].sent_to_client = false; |
- } |
+ if (!frontbuffer_suggested_allocation_) { |
+ GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
+ helper_->SendAcceleratedSurfaceRelease(params); |
} |
} |
@@ -227,50 +190,41 @@ void* TextureImageTransportSurface::GetConfig() { |
} |
void TextureImageTransportSurface::OnResize(gfx::Size size) { |
- CreateBackTexture(size); |
+ current_size_ = size; |
+ CreateBackTexture(); |
} |
void TextureImageTransportSurface::OnWillDestroyStub( |
GpuCommandBufferStub* stub) { |
- if (stub == parent_stub_) { |
- ReleaseParentStub(); |
- helper_->SetPreemptByCounter(NULL); |
- } else { |
- DCHECK(stub == helper_->stub()); |
- stub->RemoveDestructionObserver(this); |
+ DCHECK(stub == helper_->stub()); |
+ stub->RemoveDestructionObserver(this); |
- // We are losing the stub owning us, this is our last chance to clean up the |
- // resources we allocated in the stub's context. |
- if (fbo_id_) { |
- glDeleteFramebuffersEXT(1, &fbo_id_); |
- CHECK_GL_ERROR(); |
- fbo_id_ = 0; |
- } |
- |
- stub_destroyed_ = true; |
+ // We are losing the stub owning us, this is our last chance to clean up the |
+ // resources we allocated in the stub's context. |
+ if (fbo_id_) { |
+ glDeleteFramebuffersEXT(1, &fbo_id_); |
+ CHECK_GL_ERROR(); |
+ fbo_id_ = 0; |
} |
+ |
+ stub_destroyed_ = true; |
} |
bool TextureImageTransportSurface::SwapBuffers() { |
DCHECK(backbuffer_suggested_allocation_); |
- if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_) |
+ if (!frontbuffer_suggested_allocation_) |
return true; |
- if (!parent_stub_) { |
- LOG(ERROR) << "SwapBuffers failed because no parent stub."; |
- return false; |
- } |
glFlush(); |
- front_ = back(); |
- previous_damage_rect_ = gfx::Rect(textures_[front()].size); |
+ const uint64 identifier = backbuffer_.identifier; |
+ ProduceTexture(backbuffer_); |
- DCHECK(textures_[front()].client_id != 0); |
+ // Do not allow destruction while we are still waiting for a swap ACK. |
+ AddRef(); |
piman
2012/11/09 22:02:01
I'm not sure you'll actually be getting an ACK if
jonathan.backer
2012/11/12 16:52:15
We have a default ACK in GpuProcessHostUIShim. I t
no sievers
2012/11/19 20:30:44
Yes, agreed that it's not pretty. Although I think
|
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
- params.surface_handle = textures_[front()].client_id; |
- params.size = textures_[front()].size; |
- params.protection_state_id = protection_state_id_; |
- params.skip_ack = false; |
+ params.surface_handle = identifier; |
+ params.size = current_size_; |
helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
DCHECK(!is_swap_buffers_pending_); |
@@ -281,68 +235,30 @@ bool TextureImageTransportSurface::SwapBuffers() { |
bool TextureImageTransportSurface::PostSubBuffer( |
int x, int y, int width, int height) { |
DCHECK(backbuffer_suggested_allocation_); |
- DCHECK(textures_[back()].info->service_id()); |
- if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_) |
+ DCHECK(backbuffer_.service_id); |
+ if (!frontbuffer_suggested_allocation_) |
return true; |
- // If we are recreating the frontbuffer with this swap, make sure we are |
- // drawing a full frame. |
- DCHECK(textures_[front()].info->service_id() || |
- (!x && !y && gfx::Size(width, height) == textures_[back()].size)); |
- if (!parent_stub_) { |
- LOG(ERROR) << "PostSubBuffer failed because no parent stub."; |
- return false; |
- } |
- |
const gfx::Rect new_damage_rect(x, y, width, height); |
+ DCHECK(gfx::Rect(gfx::Point(), current_size_).Contains(new_damage_rect)); |
// An empty damage rect is a successful no-op. |
if (new_damage_rect.IsEmpty()) |
return true; |
- int back_texture_service_id = textures_[back()].info->service_id(); |
- int front_texture_service_id = textures_[front()].info->service_id(); |
- |
- gfx::Size expected_size = textures_[back()].size; |
- bool surfaces_same_size = textures_[front()].size == expected_size; |
- |
- if (surfaces_same_size) { |
- std::vector<gfx::Rect> regions_to_copy; |
- GetRegionsToCopy(previous_damage_rect_, new_damage_rect, ®ions_to_copy); |
- |
- ScopedFrameBufferBinder fbo_binder(fbo_id_); |
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER, |
- GL_COLOR_ATTACHMENT0, |
- GL_TEXTURE_2D, |
- front_texture_service_id, |
- 0); |
- ScopedTextureBinder texture_binder(back_texture_service_id); |
- |
- for (size_t i = 0; i < regions_to_copy.size(); ++i) { |
- const gfx::Rect& region_to_copy = regions_to_copy[i]; |
- if (!region_to_copy.IsEmpty()) { |
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, region_to_copy.x(), |
- region_to_copy.y(), region_to_copy.x(), region_to_copy.y(), |
- region_to_copy.width(), region_to_copy.height()); |
- } |
- } |
- } else if (!surfaces_same_size && did_flip_) { |
- DCHECK(new_damage_rect == gfx::Rect(expected_size)); |
- } |
- |
glFlush(); |
- front_ = back(); |
- previous_damage_rect_ = new_damage_rect; |
+ const uint64 identifier = backbuffer_.identifier; |
+ ProduceTexture(backbuffer_); |
- DCHECK(textures_[front()].client_id); |
+ // Do not allow destruction while we are still waiting for a swap ACK. |
+ AddRef(); |
GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
- params.surface_handle = textures_[front()].client_id; |
- params.surface_size = textures_[front()].size; |
+ params.surface_handle = identifier; |
+ params.surface_size = current_size_; |
params.x = x; |
params.y = y; |
params.width = width; |
params.height = height; |
- params.protection_state_id = protection_state_id_; |
helper_->SendAcceleratedSurfacePostSubBuffer(params); |
DCHECK(!is_swap_buffers_pending_); |
@@ -359,7 +275,7 @@ std::string TextureImageTransportSurface::GetExtensions() { |
} |
gfx::Size TextureImageTransportSurface::GetSize() { |
- gfx::Size size = textures_[back()].size; |
+ gfx::Size size = current_size_; |
// OSMesa expects a non-zero size. |
return gfx::Size(size.width() == 0 ? 1 : size.width(), |
@@ -374,67 +290,55 @@ unsigned TextureImageTransportSurface::GetFormat() { |
return surface_.get() ? surface_->GetFormat() : 0; |
} |
-void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected( |
- bool is_protected, uint32 protection_state_id) { |
- protection_state_id_ = protection_state_id; |
- if (frontbuffer_is_protected_ == is_protected) |
- return; |
- frontbuffer_is_protected_ = is_protected; |
- AdjustFrontBufferAllocation(); |
- |
- // If surface is set to protected, and we haven't actually released it yet, |
- // we can set the ui surface handle now just by sending a swap message. |
- if (is_protected && textures_[front()].info->service_id() && |
- textures_[front()].sent_to_client) { |
- GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
- params.surface_handle = textures_[front()].client_id; |
- params.size = textures_[front()].size; |
- params.protection_state_id = protection_state_id_; |
- params.skip_ack = true; |
- helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
- } |
-} |
- |
-void TextureImageTransportSurface::OnBufferPresented(bool presented, |
+void TextureImageTransportSurface::OnBufferPresented(uint64 surface_handle, |
uint32 sync_point) { |
if (sync_point == 0) { |
- BufferPresentedImpl(presented); |
+ BufferPresentedImpl(surface_handle); |
} else { |
helper_->manager()->sync_point_manager()->AddSyncPointCallback( |
sync_point, |
base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, |
- this->AsWeakPtr(), |
- presented)); |
+ this, |
+ surface_handle)); |
} |
-} |
-void TextureImageTransportSurface::BufferPresentedImpl(bool presented) { |
- DCHECK(is_swap_buffers_pending_); |
- is_swap_buffers_pending_ = false; |
+ // Careful, we might get deleted now if we were only waiting for |
+ // a final swap ACK. |
+ Release(); |
+} |
- if (presented) { |
- // If we had not flipped, the two frame damage tracking is inconsistent. |
- // So conservatively take the whole frame. |
- if (!did_flip_) |
- previous_damage_rect_ = gfx::Rect(textures_[front()].size); |
+void TextureImageTransportSurface::BufferPresentedImpl(uint64 surface_handle) { |
+ DCHECK(!backbuffer_.service_id); |
+ if (surface_handle) { |
+ backbuffer_.identifier = surface_handle; |
+ ConsumeTexture(backbuffer_); |
} else { |
- front_ = back(); |
- previous_damage_rect_ = gfx::Rect(0, 0, 0, 0); |
+ // We didn't get back a texture, so allocate 'the other' buffer. |
+ backbuffer_.identifier = (backbuffer_.identifier == 1) ? 2 : 1; |
+ } |
+ |
+ if (stub_destroyed_ && backbuffer_.service_id) { |
+ GpuChannelManager* manager = helper_->manager(); |
+ DCHECK(manager); |
+ if (manager->MakeCurrent(surface_.get())) |
+ glDeleteTextures(1, &backbuffer_.service_id); |
piman
2012/11/09 22:02:01
Al is working on changes that will make it so that
no sievers
2012/11/19 20:30:44
Ok, sounds good and like it also will render the A
|
+ |
+ return; |
} |
- did_flip_ = presented; |
+ DCHECK(is_swap_buffers_pending_); |
+ is_swap_buffers_pending_ = false; |
// We're relying on the fact that the parent context is |
// finished with it's context when it inserts the sync point that |
// triggers this callback. |
if (helper_->MakeCurrent()) { |
- if (textures_[front()].size != textures_[back()].size || |
- !textures_[back()].info->service_id() || |
- !textures_[back()].sent_to_client) { |
+ if (backbuffer_.size != current_size_ || |
+ !backbuffer_.service_id) { |
// We may get an ACK from a stale swap just to reschedule. In that case, |
// we may not have a backbuffer suggestion and should not recreate one. |
if (backbuffer_suggested_allocation_) |
- CreateBackTexture(textures_[front()].size); |
+ CreateBackTexture(); |
} else { |
AttachBackTextureToFBO(); |
} |
@@ -452,63 +356,40 @@ void TextureImageTransportSurface::OnResizeViewACK() { |
NOTREACHED(); |
} |
-void TextureImageTransportSurface::ReleaseTexture(int id) { |
- if (!parent_stub_) |
+void TextureImageTransportSurface::ReleaseBackBuffer() { |
+ if (!backbuffer_.service_id) |
return; |
- Texture& texture = textures_[id]; |
- TextureInfo* info = texture.info; |
- DCHECK(info); |
- |
- GLuint service_id = info->service_id(); |
- if (!service_id) |
- return; |
- info->SetServiceId(0); |
{ |
ScopedFrameBufferBinder fbo_binder(fbo_id_); |
jonathan.backer
2012/11/12 16:52:15
Why the framebuffer binder? Seems like a no-op. Ma
no sievers
2012/11/19 20:30:44
Done.
|
- glDeleteTextures(1, &service_id); |
+ glDeleteTextures(1, &backbuffer_.service_id); |
+ backbuffer_.service_id = 0; |
} |
glFlush(); |
CHECK_GL_ERROR(); |
} |
-void TextureImageTransportSurface::CreateBackTexture(const gfx::Size& size) { |
- if (!parent_stub_) |
- return; |
- Texture& texture = textures_[back()]; |
- TextureInfo* info = texture.info; |
- DCHECK(info); |
+void TextureImageTransportSurface::CreateBackTexture() { |
+ // We are waiting for our backbuffer in the mailbox, so we shouldn't be |
+ // reallocating the backbuffer now. |
jonathan.backer
2012/11/12 16:52:15
comment nit: "If |is_swap_buffers_pending|, we are
no sievers
2012/11/19 20:30:44
Done.
|
+ DCHECK(!is_swap_buffers_pending_); |
- GLuint service_id = info->service_id(); |
+ gfx::Size& size = current_size_; |
jonathan.backer
2012/11/12 16:52:15
Got tired of typing?
no sievers
2012/11/19 20:30:44
Done.
|
+ Texture& texture = backbuffer_; |
piman
2012/11/09 22:02:01
nit: you have a single texture now, so that indire
no sievers
2012/11/19 20:30:44
Done.
|
- if (service_id && texture.size == size && texture.sent_to_client) |
+ if (texture.service_id && texture.size == size) |
return; |
- if (!service_id) { |
- glGenTextures(1, &service_id); |
- info->SetServiceId(service_id); |
+ if (!texture.service_id) { |
piman
2012/11/09 22:02:01
nit: no need for braces any more.
no sievers
2012/11/19 20:30:44
Done.
|
+ glGenTextures(1, &texture.service_id); |
} |
if (size != texture.size) { |
texture.size = size; |
jonathan.backer
2012/11/12 16:52:15
nit: no if necessary.
no sievers
2012/11/19 20:30:44
Done.
|
- TextureManager* texture_manager = |
- parent_stub_->decoder()->GetContextGroup()->texture_manager(); |
- texture_manager->SetLevelInfo( |
- info, |
- GL_TEXTURE_2D, |
- 0, |
- GL_RGBA, |
- size.width(), |
- size.height(), |
- 1, |
- 0, |
- GL_RGBA, |
- GL_UNSIGNED_BYTE, |
- true); |
} |
{ |
- ScopedTextureBinder texture_binder(service_id); |
+ ScopedTextureBinder texture_binder(texture.service_id); |
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
@@ -521,25 +402,26 @@ void TextureImageTransportSurface::CreateBackTexture(const gfx::Size& size) { |
AttachBackTextureToFBO(); |
+ MailboxName mailbox_name; |
+ mailbox_manager_->GenerateMailboxName(&mailbox_name); |
+ mailbox_names_[texture.identifier] = mailbox_name; |
piman
2012/11/09 22:02:01
Al can confirm but I don't think it's ok to change
no sievers
2012/11/19 20:30:44
Done.
|
+ |
GpuHostMsg_AcceleratedSurfaceNew_Params params; |
params.width = size.width(); |
params.height = size.height(); |
- params.surface_handle = texture.client_id; |
+ params.surface_handle = texture.identifier; |
+ params.mailbox_name.resize(sizeof(mailbox_name)); |
+ memcpy(params.mailbox_name.data(), &mailbox_name, sizeof(mailbox_name)); |
helper_->SendAcceleratedSurfaceNew(params); |
- texture.sent_to_client = true; |
} |
void TextureImageTransportSurface::AttachBackTextureToFBO() { |
- if (!parent_stub_) |
- return; |
- TextureInfo* info = textures_[back()].info; |
- DCHECK(info); |
- |
+ DCHECK(backbuffer_.service_id); |
ScopedFrameBufferBinder fbo_binder(fbo_id_); |
glFramebufferTexture2DEXT(GL_FRAMEBUFFER, |
GL_COLOR_ATTACHMENT0, |
GL_TEXTURE_2D, |
- info->service_id(), |
+ backbuffer_.service_id, |
0); |
glFlush(); |
CHECK_GL_ERROR(); |
@@ -547,24 +429,50 @@ void TextureImageTransportSurface::AttachBackTextureToFBO() { |
#ifndef NDEBUG |
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
if (status != GL_FRAMEBUFFER_COMPLETE) { |
- DLOG(ERROR) << "Framebuffer incomplete."; |
+ DLOG(ERROR) << "Framebuffer incomplete: " << status; |
+ DCHECK(false); |
piman
2012/11/09 22:02:01
nit: just make the above DLOG(FATAL)?
no sievers
2012/11/19 20:30:44
Done.
|
} |
#endif |
} |
-void TextureImageTransportSurface::ReleaseParentStub() { |
- DCHECK(parent_stub_); |
- parent_stub_->RemoveDestructionObserver(this); |
- for (int i = 0; i < 2; ++i) { |
- Texture& texture = textures_[i]; |
- texture.info = NULL; |
- if (!texture.sent_to_client) |
- continue; |
- GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
- params.identifier = texture.client_id; |
- helper_->SendAcceleratedSurfaceRelease(params); |
piman
2012/11/09 22:02:01
This should still happen somewhere. If we switch o
|
+void TextureImageTransportSurface::ConsumeTexture(Texture& texture) { |
+ DCHECK(!texture.service_id); |
+ DCHECK(texture.identifier == 1 || texture.identifier == 2); |
+ |
+ scoped_ptr<TextureDefinition> definition(mailbox_manager_->ConsumeTexture( |
+ GL_TEXTURE_2D, mailbox_names_[texture.identifier])); |
+ if (definition.get()) { |
+ texture.service_id = definition->ReleaseServiceId(); |
+ texture.size = gfx::Size(definition->level_infos()[0][0].width, |
+ definition->level_infos()[0][0].height); |
} |
- parent_stub_ = NULL; |
+} |
+ |
+void TextureImageTransportSurface::ProduceTexture(Texture& texture) { |
+ DCHECK(texture.service_id); |
+ DCHECK(texture.identifier == 1 || texture.identifier == 2); |
+ TextureManager* texture_manager = |
+ helper_->stub()->decoder()->GetContextGroup()->texture_manager(); |
+ DCHECK(texture.size.width() > 0 && texture.size.height() > 0); |
+ TextureDefinition::LevelInfo info( |
+ GL_TEXTURE_2D, GL_RGBA, texture.size.width(), texture.size.height(), 1, |
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, true); |
+ |
+ TextureDefinition::LevelInfos level_infos; |
+ level_infos.resize(1); |
+ level_infos[0].resize(texture_manager->MaxLevelsForTarget(GL_TEXTURE_2D)); |
+ level_infos[0][0] = info; |
+ scoped_ptr<TextureDefinition> definition(new TextureDefinition( |
+ GL_TEXTURE_2D, |
+ texture.service_id, |
+ true, |
+ level_infos)); |
+ mailbox_manager_->ProduceTexture( |
+ GL_TEXTURE_2D, |
+ mailbox_names_[texture.identifier], |
+ definition.release(), |
+ helper_->stub()->decoder()->GetContextGroup()->texture_manager()); |
+ texture.service_id = 0; |
} |
} // namespace content |