summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-05 07:48:51 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-05 07:48:51 +0000
commit2ad674132b5a79f5c9bc108c77b5e5de3c665a05 (patch)
treeedbef08087681f69f16708f9110f76406cb432ac /gpu
parent62b22650009f851a7703db0b73e22d9eafec2ea9 (diff)
downloadchromium_src-2ad674132b5a79f5c9bc108c77b5e5de3c665a05.zip
chromium_src-2ad674132b5a79f5c9bc108c77b5e5de3c665a05.tar.gz
chromium_src-2ad674132b5a79f5c9bc108c77b5e5de3c665a05.tar.bz2
Replace context parenting by sharing through mailboxes
Instead of tying contexts together through the parenting mechanism, we can allow the client to produce the front buffer of an offscreen context into a mailbox, and use that in the "parent" context. It simplifies the code and the semantics wrt lost contexts, and we want to use mailboxes anyway. BUG=164095 Review URL: https://chromiumcodereview.appspot.com/15798014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204194 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc11
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h3
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc188
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_mock.h3
-rw-r--r--gpu/command_buffer/service/texture_manager.cc8
-rw-r--r--gpu/command_buffer/service/texture_manager.h9
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc23
-rw-r--r--gpu/command_buffer/tests/gl_manager.cc1
-rw-r--r--gpu/command_buffer/tests/gl_manager.h4
-rw-r--r--gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc54
-rw-r--r--gpu/ipc/command_buffer_proxy.h10
12 files changed, 129 insertions, 189 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index cc4ca5b..37c57b5 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -279,17 +279,6 @@ GLES2CmdHelper* GLES2Implementation::helper() const {
return helper_;
}
-GLuint GLES2Implementation::MakeTextureId() {
- GLuint id;
- GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, 1, &id);
- return id;
-}
-
-void GLES2Implementation::FreeTextureId(GLuint id) {
- GetIdHandler(id_namespaces::kTextures)->FreeIds(
- this, 1, &id, &GLES2Implementation::DeleteTexturesStub);
-}
-
IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const {
return share_group_->GetIdHandler(namespace_id);
}
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index c693383..44283db 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -216,9 +216,6 @@ class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface {
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
GLint* size, GLenum* type, char* name);
- GLuint MakeTextureId();
- void FreeTextureId(GLuint id);
-
void SetSharedMemoryChunkSizeMultiple(unsigned int multiple);
void FreeUnusedSharedMemory();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 75ad51d..3bd165e 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -29,6 +29,7 @@
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/common/debug_marker_manager.h"
#include "gpu/command_buffer/common/id_allocator.h"
+#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
@@ -513,8 +514,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
virtual void Destroy(bool have_context) OVERRIDE;
virtual void SetSurface(
const scoped_refptr<gfx::GLSurface>& surface) OVERRIDE;
- virtual bool SetParent(GLES2Decoder* parent_decoder,
- uint32 parent_texture_id) OVERRIDE;
+ virtual bool ProduceFrontBuffer(const Mailbox& mailbox) OVERRIDE;
virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) OVERRIDE;
void UpdateParentTextureInfo();
virtual bool MakeCurrent() OVERRIDE;
@@ -1557,10 +1557,6 @@ class GLES2DecoderImpl : public GLES2Decoder {
// All the state for this context.
ContextState state_;
- // A parent decoder can access this decoders saved offscreen frame buffer.
- // The parent pointer is reset if the parent is destroyed.
- base::WeakPtr<GLES2DecoderImpl> parent_;
-
// Current width and height of the offscreen frame buffer.
gfx::Size offscreen_size_;
@@ -1689,9 +1685,6 @@ class GLES2DecoderImpl : public GLES2Decoder {
TextureToIOSurfaceMap texture_to_io_surface_map_;
#endif
- typedef std::vector<GLES2DecoderImpl*> ChildList;
- ChildList children_;
-
scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
// Cached values of the currently assigned viewport dimensions.
@@ -2980,54 +2973,48 @@ GLenum GLES2DecoderImpl::GetBoundDrawFrameBufferInternalFormat() {
}
void GLES2DecoderImpl::UpdateParentTextureInfo() {
- if (parent_.get()) {
- // Update the info about the offscreen saved color texture in the parent.
- // The reference to the parent is a weak pointer and will become null if the
- // parent is later destroyed.
- GLenum target = offscreen_saved_color_texture_info_->texture()->target();
- 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_.get(),
- GL_TEXTURE_2D,
- 0, // level
- GL_RGBA,
- offscreen_size_.width(),
- offscreen_size_.height(),
- 1, // depth
- 0, // border
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- true);
- parent_texture_manager->SetParameter(
- "UpdateParentTextureInfo",
- GetErrorState(),
- offscreen_saved_color_texture_info_.get(),
- GL_TEXTURE_MAG_FILTER,
- GL_NEAREST);
- parent_texture_manager->SetParameter(
- "UpdateParentTextureInfo",
- GetErrorState(),
- offscreen_saved_color_texture_info_.get(),
- GL_TEXTURE_MIN_FILTER,
- GL_NEAREST);
- parent_texture_manager->SetParameter(
- "UpdateParentTextureInfo",
- GetErrorState(),
- 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_.get(),
- GL_TEXTURE_WRAP_T,
- GL_CLAMP_TO_EDGE);
- TextureRef* texture_ref = GetTextureInfoForTarget(target);
- glBindTexture(target, texture_ref ? texture_ref->service_id() : 0);
- } else {
- offscreen_saved_color_texture_info_ = NULL;
- }
+ if (!offscreen_saved_color_texture_info_.get())
+ return;
+ GLenum target = offscreen_saved_color_texture_info_->texture()->target();
+ glBindTexture(target, offscreen_saved_color_texture_info_->service_id());
+ texture_manager()->SetLevelInfo(
+ offscreen_saved_color_texture_info_.get(),
+ GL_TEXTURE_2D,
+ 0, // level
+ GL_RGBA,
+ offscreen_size_.width(),
+ offscreen_size_.height(),
+ 1, // depth
+ 0, // border
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ texture_manager()->SetParameter(
+ "UpdateParentTextureInfo",
+ GetErrorState(),
+ offscreen_saved_color_texture_info_.get(),
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ texture_manager()->SetParameter(
+ "UpdateParentTextureInfo",
+ GetErrorState(),
+ offscreen_saved_color_texture_info_.get(),
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ texture_manager()->SetParameter(
+ "UpdateParentTextureInfo",
+ GetErrorState(),
+ offscreen_saved_color_texture_info_.get(),
+ GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+ texture_manager()->SetParameter(
+ "UpdateParentTextureInfo",
+ GetErrorState(),
+ offscreen_saved_color_texture_info_.get(),
+ GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+ TextureRef* texture_ref = GetTextureInfoForTarget(target);
+ glBindTexture(target, texture_ref ? texture_ref->service_id() : 0);
}
void GLES2DecoderImpl::SetResizeCallback(
@@ -3110,12 +3097,6 @@ void GLES2DecoderImpl::Destroy(bool have_context) {
DCHECK(!have_context || context_->IsCurrent(NULL));
- ChildList children = children_;
- for (ChildList::iterator it = children.begin(); it != children.end(); ++it)
- (*it)->SetParent(NULL, 0);
- DCHECK(children_.empty());
- SetParent(NULL, 0);
-
// Unbind everything.
state_.vertex_attrib_manager = NULL;
default_vertex_attrib_manager_ = NULL;
@@ -3127,6 +3108,13 @@ void GLES2DecoderImpl::Destroy(bool have_context) {
state_.bound_draw_framebuffer = NULL;
state_.bound_renderbuffer = NULL;
+ if (offscreen_saved_color_texture_info_) {
+ DCHECK(offscreen_target_color_texture_);
+ DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(),
+ offscreen_saved_color_texture_->id());
+ offscreen_saved_color_texture_->Invalidate();
+ offscreen_saved_color_texture_info_ = NULL;
+ }
if (have_context) {
if (copy_texture_CHROMIUM_.get()) {
copy_texture_CHROMIUM_->Destroy();
@@ -3237,64 +3225,20 @@ void GLES2DecoderImpl::SetSurface(
RestoreCurrentFramebufferBindings();
}
-bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
- uint32 new_parent_texture_id) {
+bool GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) {
if (!offscreen_saved_color_texture_.get())
return false;
-
- // Remove the saved frame buffer mapping from the parent decoder. The
- // parent pointer is a weak pointer so it will be null if the parent has
- // already been destroyed.
- if (parent_.get()) {
- ChildList::iterator it =
- std::find(parent_->children_.begin(), parent_->children_.end(), this);
- DCHECK(it != parent_->children_.end());
- 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_.get() &&
- offscreen_saved_color_texture_info_->client_id()) {
- parent_->texture_manager()->RemoveTexture(
- offscreen_saved_color_texture_info_->client_id());
- }
- }
-
- GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>(
- new_parent);
- if (new_parent_impl) {
-#ifndef NDEBUG
- ChildList::iterator it = std::find(
- new_parent_impl->children_.begin(),
- new_parent_impl->children_.end(),
- this);
- DCHECK(it == new_parent_impl->children_.end());
-#endif
- new_parent_impl->children_.push_back(this);
- // Map the ID of the saved offscreen texture into the parent so that
- // it can reference it.
+ if (!offscreen_saved_color_texture_info_.get()) {
GLuint service_id = offscreen_saved_color_texture_->id();
-
- // Replace texture info when ID is already in use by parent.
- if (new_parent_impl->texture_manager()->GetTexture(
- new_parent_texture_id))
- new_parent_impl->texture_manager()->RemoveTexture(
- new_parent_texture_id);
-
- 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_.get(), GL_TEXTURE_2D);
-
- parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl);
-
+ offscreen_saved_color_texture_info_ = CreateTexture(0, service_id);
+ texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(),
+ GL_TEXTURE_2D);
UpdateParentTextureInfo();
- } else {
- parent_.reset();
- offscreen_saved_color_texture_info_ = NULL;
}
-
- return true;
+ gpu::gles2::MailboxName name;
+ memcpy(name.key, mailbox.name, sizeof(mailbox.name));
+ return mailbox_manager()->ProduceTexture(
+ GL_TEXTURE_2D, name, offscreen_saved_color_texture_info_->texture());
}
size_t GLES2DecoderImpl::GetBackbufferMemoryTotal() {
@@ -9040,18 +8984,6 @@ void GLES2DecoderImpl::LoseContext(uint32 reset_status) {
// Marks this context as lost.
reset_status_ = reset_status;
current_decoder_error_ = error::kLostContext;
-
- // Loses the parent's context.
- if (parent_.get()) {
- parent_->LoseContext(reset_status);
- }
-
- // Loses any child contexts.
- for (ChildList::iterator it = children_.begin();
- it != children_.end();
- ++it) {
- (*it)->LoseContext(reset_status);
- }
}
error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 15f3e97..b187b58 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -28,6 +28,7 @@ namespace gpu {
class AsyncPixelTransferDelegate;
class AsyncPixelTransferManager;
class StreamTextureManager;
+struct Mailbox;
namespace gles2 {
@@ -121,8 +122,7 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>,
// Set the surface associated with the default FBO.
virtual void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) = 0;
- virtual bool SetParent(GLES2Decoder* parent_decoder,
- uint32 parent_texture_id) = 0;
+ virtual bool ProduceFrontBuffer(const Mailbox& mailbox) = 0;
// Resize an offscreen frame buffer.
virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) = 0;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
index 4e617e3..93dd09d 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "base/callback_forward.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -43,7 +44,7 @@ class MockGLES2Decoder : public GLES2Decoder {
const std::vector<int32>& attribs));
MOCK_METHOD1(Destroy, void(bool have_context));
MOCK_METHOD1(SetSurface, void(const scoped_refptr<gfx::GLSurface>& surface));
- MOCK_METHOD2(SetParent, bool(GLES2Decoder* parent, uint32 parent_texture_id));
+ MOCK_METHOD1(ProduceFrontBuffer, bool(const Mailbox& mailbox));
MOCK_METHOD1(ResizeOffscreenFrameBuffer, bool(const gfx::Size& size));
MOCK_METHOD0(MakeCurrent, bool());
MOCK_METHOD0(ReleaseCurrent, void());
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 73482b0..8f16bbb 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -114,7 +114,6 @@ Texture::Texture(GLuint service_id)
npot_(false),
has_been_bound_(false),
framebuffer_attachment_count_(0),
- owned_(true),
stream_texture_(false),
immutable_(false),
estimated_size_(0),
@@ -143,7 +142,7 @@ void Texture::RemoveTextureRef(TextureRef* ref, bool have_context) {
size_t result = refs_.erase(ref);
DCHECK_EQ(result, 1u);
if (refs_.empty()) {
- if (owned_ && have_context) {
+ if (have_context) {
GLuint id = service_id();
glDeleteTextures(1, &id);
}
@@ -1042,10 +1041,7 @@ void TextureManager::SetLevelInfo(
Texture* TextureManager::Produce(TextureRef* ref) {
DCHECK(ref);
- Texture* texture = ref->texture();
- if (!texture->owned_)
- return NULL;
- return texture;
+ return ref->texture();
}
TextureRef* TextureManager::Consume(
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index 76acd15..c382056 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -81,6 +81,7 @@ class GPU_EXPORT Texture {
}
void SetServiceId(GLuint service_id) {
+ DCHECK(service_id);
service_id_ = service_id;
}
@@ -124,10 +125,6 @@ class GPU_EXPORT Texture {
return !!target();
}
- void SetNotOwned() {
- owned_ = false;
- }
-
bool IsAttachedToFramebuffer() const {
return framebuffer_attachment_count_ != 0;
}
@@ -368,10 +365,6 @@ class GPU_EXPORT Texture {
// The number of framebuffers this texture is attached to.
int framebuffer_attachment_count_;
- // Whether the associated context group owns this texture and should delete
- // it.
- bool owned_;
-
// Whether this is a special streaming texture.
bool stream_texture_;
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index 758f421..b5c409a 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -205,29 +205,6 @@ TEST_F(TextureManagerTest, Destroy) {
ASSERT_TRUE(texture == NULL);
}
-TEST_F(TextureManagerTest, DestroyUnowned) {
- const GLuint kClient1Id = 1;
- const GLuint kService1Id = 11;
- TestHelper::SetupTextureManagerInitExpectations(gl_.get(), "");
- TextureManager manager(
- NULL, feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize);
- manager.Initialize();
- // Check we can create texture.
- TextureRef* created_texture =
- manager.CreateTexture(kClient1Id, kService1Id);
- created_texture->texture()->SetNotOwned();
-
- // Check texture got created.
- TextureRef* texture = manager.GetTexture(kClient1Id);
- ASSERT_TRUE(texture != NULL);
-
- // Check that it is not freed if it is not owned.
- TestHelper::SetupTextureManagerDestructionExpectations(gl_.get(), "");
- manager.Destroy(true);
- texture = manager.GetTexture(kClient1Id);
- ASSERT_TRUE(texture == NULL);
-}
-
TEST_F(TextureManagerTest, MaxValues) {
// Check we get the right values for the max sizes.
EXPECT_EQ(kMax2dLevels, manager_->MaxLevelsForTarget(GL_TEXTURE_2D));
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index 3e55384..cb05e35 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -249,6 +249,7 @@ void GLManager::Destroy() {
if (decoder_.get()) {
decoder_->MakeCurrent();
decoder_->Destroy(true);
+ decoder_.reset();
}
}
diff --git a/gpu/command_buffer/tests/gl_manager.h b/gpu/command_buffer/tests/gl_manager.h
index 15fc9ef..7b96b84 100644
--- a/gpu/command_buffer/tests/gl_manager.h
+++ b/gpu/command_buffer/tests/gl_manager.h
@@ -67,6 +67,10 @@ class GLManager {
void SetSurface(gfx::GLSurface* surface);
+ gles2::GLES2Decoder* decoder() const {
+ return decoder_.get();
+ }
+
gles2::MailboxManager* mailbox_manager() const {
return mailbox_manager_.get();
}
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
index 566189f..dbd513c 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
@@ -6,6 +6,9 @@
#include <GLES2/gl2ext.h>
#include <GLES2/gl2extchromium.h>
+#include "gpu/command_buffer/client/gles2_lib.h"
+#include "gpu/command_buffer/common/mailbox.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/tests/gl_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -37,7 +40,7 @@ uint32 ReadTexel(GLuint id, GLint x, GLint y) {
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
glCheckFramebufferStatus(GL_FRAMEBUFFER));
- uint32 texel;
+ uint32 texel = 0;
glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel);
glBindFramebuffer(GL_FRAMEBUFFER, old_fbo);
@@ -266,5 +269,54 @@ TEST_F(GLTextureMailboxTest, SharedTextures) {
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
}
+TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) {
+ gl1_.MakeCurrent();
+ Mailbox mailbox;
+ glGenMailboxCHROMIUM(mailbox.name);
+
+ gl2_.MakeCurrent();
+ gl2_.decoder()->ProduceFrontBuffer(mailbox);
+
+ gl1_.MakeCurrent();
+ GLuint tex1;
+ glGenTextures(1, &tex1);
+ glBindTexture(GL_TEXTURE_2D, tex1);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ gl2_.MakeCurrent();
+ glResizeCHROMIUM(10, 10, 1);
+ glClearColor(1, 0, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ::gles2::GetGLContext()->SwapBuffers();
+
+ gl1_.MakeCurrent();
+ EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0));
+ EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 9, 9));
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ gl2_.MakeCurrent();
+ glClearColor(0, 1, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFlush();
+
+ gl1_.MakeCurrent();
+ EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0));
+
+ gl2_.MakeCurrent();
+ ::gles2::GetGLContext()->SwapBuffers();
+
+ gl1_.MakeCurrent();
+ EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0));
+
+ gl2_.MakeCurrent();
+ gl2_.Destroy();
+
+ gl1_.MakeCurrent();
+ EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0));
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ glDeleteTextures(1, &tex1);
+}
+
} // namespace gpu
diff --git a/gpu/ipc/command_buffer_proxy.h b/gpu/ipc/command_buffer_proxy.h
index a992369..d33eae4 100644
--- a/gpu/ipc/command_buffer_proxy.h
+++ b/gpu/ipc/command_buffer_proxy.h
@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
+#include "gpu/command_buffer/common/mailbox.h"
// Client side proxy that forwards messages synchronously to a
// CommandBufferStub.
@@ -28,12 +29,9 @@ class GPU_EXPORT CommandBufferProxy : public gpu::CommandBuffer {
// the task whether the echo succeeds or not.
virtual bool Echo(const base::Closure& callback) = 0;
- // Reparent a command buffer. TODO(apatrick): going forward, the notion of
- // the parent / child relationship between command buffers is going away in
- // favor of the notion of surfaces that can be drawn to in one command buffer
- // and bound as a texture in any other.
- virtual bool SetParent(CommandBufferProxy* parent_command_buffer,
- uint32 parent_texture_id) = 0;
+ // For offscreen contexts, produces the front buffer into a newly created
+ // mailbox.
+ virtual bool ProduceFrontBuffer(const gpu::Mailbox& mailbox) = 0;
virtual void SetChannelErrorCallback(const base::Closure& callback) = 0;