summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-20 19:58:24 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-20 19:58:24 +0000
commit3c644d83d23318c6ba120e2303816369045f5964 (patch)
tree3f0a3b02ce1a4fd7cf8b68d3bb033be8ca8129dd /gpu
parent35c14eeb34ca5f21b70a388e868ff3968545812f (diff)
downloadchromium_src-3c644d83d23318c6ba120e2303816369045f5964.zip
chromium_src-3c644d83d23318c6ba120e2303816369045f5964.tar.gz
chromium_src-3c644d83d23318c6ba120e2303816369045f5964.tar.bz2
RendererGLContext supports reparenting a GL context.
This will allow the parenting of offscreen canvas contexts to be deferred until the compositor's view context exists, which in some cases needs to be deferred until the window is asynchronously created by the browser's UI thread. An example is JavaScript opening a popup window and then immediately using canvas to attempt to render to it. This patch alone does not fix the bug. BUG=80703 Review URL: http://codereview.chromium.org/7205012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/client/gles2_demo.cc2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc75
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h11
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_mock.h7
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc2
-rw-r--r--gpu/command_buffer/service/gpu_scheduler.cc17
-rw-r--r--gpu/command_buffer/service/gpu_scheduler.h8
-rw-r--r--gpu/command_buffer/service/gpu_scheduler_linux.cc13
-rw-r--r--gpu/command_buffer/service/gpu_scheduler_mac.cc13
-rw-r--r--gpu/command_buffer/service/gpu_scheduler_win.cc13
-rw-r--r--gpu/demos/framework/window.cc2
-rw-r--r--gpu/gles2_conform_support/egl/display.cc2
12 files changed, 67 insertions, 98 deletions
diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc
index b95a2c2..c9595df 100644
--- a/gpu/command_buffer/client/gles2_demo.cc
+++ b/gpu/command_buffer/client/gles2_demo.cc
@@ -64,8 +64,6 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) {
gpu::gles2::DisallowedExtensions(),
NULL,
std::vector<int32>(),
- NULL,
- 0,
NULL)) {
return NULL;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 28d6557..3207c70 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -712,10 +712,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
const gfx::Size& size,
const DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
- const std::vector<int32>& attribs,
- GLES2Decoder* parent,
- uint32 parent_client_texture_id);
+ const std::vector<int32>& attribs);
virtual void Destroy();
+ virtual bool SetParent(GLES2Decoder* parent_decoder,
+ uint32 parent_texture_id);
virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size);
virtual bool UpdateOffscreenFrameBufferSize();
virtual bool MakeCurrent();
@@ -1890,9 +1890,7 @@ bool GLES2DecoderImpl::Initialize(
const gfx::Size& size,
const DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
- const std::vector<int32>& attribs,
- GLES2Decoder* parent,
- uint32 parent_client_texture_id) {
+ const std::vector<int32>& attribs) {
DCHECK(context);
DCHECK(!context_.get());
@@ -1906,11 +1904,6 @@ bool GLES2DecoderImpl::Initialize(
// Take ownership of the GLContext.
context_ = context;
- // Keep only a weak pointer to the parent so we don't unmap its client
- // frame buffer after it has been destroyed.
- if (parent)
- parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr();
-
if (!MakeCurrent()) {
LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because "
<< "MakeCurrent failed.";
@@ -2068,16 +2061,6 @@ bool GLES2DecoderImpl::Initialize(
offscreen_saved_color_texture_.reset(new Texture(this));
offscreen_saved_color_texture_->Create();
- // Map the ID of the saved offscreen texture into the parent so that
- // it can reference it.
- if (parent_) {
- GLuint service_id = offscreen_saved_color_texture_->id();
- TextureManager::TextureInfo* info =
- parent_->CreateTextureInfo(parent_client_texture_id, service_id);
- info->SetNotOwned();
- parent_->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D);
- }
-
// Allocate the render buffers at their initial size and check the status
// of the frame buffers is okay.
pending_offscreen_size_ = size;
@@ -2558,6 +2541,8 @@ void GLES2DecoderImpl::Destroy() {
if (group_.get())
group_->set_have_context(have_context);
+ SetParent(NULL, 0);
+
if (have_context) {
if (current_program_) {
program_manager()->UnuseProgram(shader_manager(), current_program_);
@@ -2571,20 +2556,8 @@ void GLES2DecoderImpl::Destroy() {
glDeleteBuffersARB(1, &fixed_attrib_buffer_id_);
}
- // 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_) {
- // First check the texture has been mapped into the parent. This might not
- // be the case if initialization failed midway through.
- GLuint service_id = offscreen_saved_color_texture_->id();
- GLuint client_id = 0;
- if (parent_->texture_manager()->GetClientId(service_id, &client_id)) {
- parent_->texture_manager()->RemoveTextureInfo(feature_info_, client_id);
- }
-
+ if (copy_texture_to_parent_texture_fb_)
glDeleteFramebuffersEXT(1, &copy_texture_to_parent_texture_fb_);
- }
if (offscreen_target_frame_buffer_.get())
offscreen_target_frame_buffer_->Destroy();
@@ -2636,6 +2609,40 @@ void GLES2DecoderImpl::Destroy() {
offscreen_saved_color_texture_.reset();
}
+bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
+ uint32 new_parent_texture_id) {
+ // 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_) {
+ // First check the texture has been mapped into the parent. This might not
+ // be the case if initialization failed midway through.
+ GLuint service_id = offscreen_saved_color_texture_->id();
+ GLuint client_id = 0;
+ if (parent_->texture_manager()->GetClientId(service_id, &client_id)) {
+ parent_->texture_manager()->RemoveTextureInfo(feature_info_, client_id);
+ }
+ }
+
+ GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>(
+ new_parent);
+ if (new_parent_impl) {
+ // Map the ID of the saved offscreen texture into the parent so that
+ // it can reference it.
+ GLuint service_id = offscreen_saved_color_texture_->id();
+ TextureManager::TextureInfo* info =
+ new_parent_impl->CreateTextureInfo(new_parent_texture_id, service_id);
+ info->SetNotOwned();
+ new_parent_impl->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D);
+
+ parent_ = new_parent_impl->AsWeakPtr();
+ } else {
+ parent_.reset();
+ }
+
+ return true;
+}
+
void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
// We can't resize the render buffers immediately because there might be a
// partial frame rendered into them and we don't want the tail end of that
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 699f85e..0551e5a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -65,10 +65,6 @@ class GLES2Decoder : public CommonDecoder {
// allowed_extensions: A string in the same format as
// glGetString(GL_EXTENSIONS) that lists the extensions this context
// should allow. Passing NULL or "*" means allow all extensions.
- // parent: the GLES2 decoder that can access this decoder's front buffer
- // through a texture ID in its namespace.
- // parent_client_texture_id: the texture ID of the front buffer in the
- // parent's namespace.
// Returns:
// true if successful.
virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
@@ -76,13 +72,14 @@ class GLES2Decoder : public CommonDecoder {
const gfx::Size& size,
const DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
- const std::vector<int32>& attribs,
- GLES2Decoder* parent,
- uint32 parent_client_texture_id) = 0;
+ const std::vector<int32>& attribs) = 0;
// Destroys the graphics context.
virtual void Destroy() = 0;
+ virtual bool SetParent(GLES2Decoder* parent_decoder,
+ uint32 parent_texture_id) = 0;
+
// Resize an offscreen frame buffer.
virtual void 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 f775625..0a44ecf 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -29,16 +29,15 @@ class MockGLES2Decoder : public GLES2Decoder {
MockGLES2Decoder();
virtual ~MockGLES2Decoder();
- MOCK_METHOD8(Initialize,
+ MOCK_METHOD6(Initialize,
bool(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
const gfx::Size& size,
const DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
- const std::vector<int32>& attribs,
- GLES2Decoder* parent,
- uint32 parent_texture_id));
+ const std::vector<int32>& attribs));
MOCK_METHOD0(Destroy, void());
+ MOCK_METHOD2(SetParent, bool(GLES2Decoder* parent, uint32 parent_texture_id));
MOCK_METHOD1(ResizeOffscreenFrameBuffer, void(const gfx::Size& size));
MOCK_METHOD0(UpdateOffscreenFrameBufferSize, bool());
MOCK_METHOD0(MakeCurrent, bool());
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 9470d08..0f20e67 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -137,7 +137,7 @@ void GLES2DecoderTestBase::InitDecoder(
decoder_.reset(GLES2Decoder::Create(surface_manager_.get(), group_.get()));
decoder_->Initialize(
surface_, context_, surface_->GetSize(), DisallowedExtensions(),
- NULL, std::vector<int32>(), NULL, 0);
+ NULL, std::vector<int32>());
decoder_->set_engine(engine_.get());
EXPECT_CALL(*gl_, GenBuffersARB(_, _))
diff --git a/gpu/command_buffer/service/gpu_scheduler.cc b/gpu/command_buffer/service/gpu_scheduler.cc
index b3711aa..d4ac593 100644
--- a/gpu/command_buffer/service/gpu_scheduler.cc
+++ b/gpu/command_buffer/service/gpu_scheduler.cc
@@ -66,9 +66,7 @@ bool GpuScheduler::InitializeCommon(
const gfx::Size& size,
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
- const std::vector<int32>& attribs,
- gles2::GLES2Decoder* parent_decoder,
- uint32 parent_texture_id) {
+ const std::vector<int32>& attribs) {
DCHECK(context);
if (!context->MakeCurrent(surface))
@@ -111,9 +109,7 @@ bool GpuScheduler::InitializeCommon(
size,
disallowed_extensions,
allowed_extensions,
- attribs,
- parent_decoder,
- parent_texture_id)) {
+ attribs)) {
LOG(ERROR) << "GpuScheduler::InitializeCommon failed because decoder "
<< "failed to initialize.";
Destroy();
@@ -134,6 +130,15 @@ void GpuScheduler::DestroyCommon() {
parser_.reset();
}
+bool GpuScheduler::SetParent(GpuScheduler* parent_scheduler,
+ uint32 parent_texture_id) {
+ if (parent_scheduler)
+ return decoder_->SetParent(parent_scheduler->decoder_.get(),
+ parent_texture_id);
+ else
+ return decoder_->SetParent(NULL, 0);
+}
+
#if defined(OS_MACOSX)
namespace {
const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1;
diff --git a/gpu/command_buffer/service/gpu_scheduler.h b/gpu/command_buffer/service/gpu_scheduler.h
index 78845df..31b6a95 100644
--- a/gpu/command_buffer/service/gpu_scheduler.h
+++ b/gpu/command_buffer/service/gpu_scheduler.h
@@ -63,13 +63,13 @@ class GpuScheduler : public CommandBufferEngine {
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
const std::vector<int32>& attribs,
- GpuScheduler* parent,
- uint32 parent_texture_id,
gfx::GLShareGroup* share_group);
void Destroy();
void DestroyCommon();
+ bool SetParent(GpuScheduler* parent_scheduler, uint32 parent_texture_id);
+
void PutChanged(bool sync);
// Sets whether commands should be processed by this scheduler. Setting to
@@ -152,9 +152,7 @@ class GpuScheduler : public CommandBufferEngine {
const gfx::Size& size,
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
- const std::vector<int32>& attribs,
- gles2::GLES2Decoder* parent_decoder,
- uint32 parent_texture_id);
+ const std::vector<int32>& attribs);
private:
diff --git a/gpu/command_buffer/service/gpu_scheduler_linux.cc b/gpu/command_buffer/service/gpu_scheduler_linux.cc
index 84d821e..6adaba6 100644
--- a/gpu/command_buffer/service/gpu_scheduler_linux.cc
+++ b/gpu/command_buffer/service/gpu_scheduler_linux.cc
@@ -17,16 +17,7 @@ bool GpuScheduler::Initialize(
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
const std::vector<int32>& attribs,
- GpuScheduler* parent,
- uint32 parent_texture_id,
gfx::GLShareGroup* share_group) {
- // Get the parent decoder.
- gles2::GLES2Decoder* parent_decoder = NULL;
- if (parent) {
- parent_decoder = parent->decoder_.get();
- DCHECK(parent_decoder);
- }
-
// Create either a view or pbuffer based GLSurface.
scoped_refptr<gfx::GLSurface> surface;
if (window)
@@ -54,9 +45,7 @@ bool GpuScheduler::Initialize(
size,
disallowed_extensions,
allowed_extensions,
- attribs,
- parent_decoder,
- parent_texture_id);
+ attribs);
}
void GpuScheduler::Destroy() {
diff --git a/gpu/command_buffer/service/gpu_scheduler_mac.cc b/gpu/command_buffer/service/gpu_scheduler_mac.cc
index 0e4d8d6..2835088 100644
--- a/gpu/command_buffer/service/gpu_scheduler_mac.cc
+++ b/gpu/command_buffer/service/gpu_scheduler_mac.cc
@@ -17,16 +17,7 @@ bool GpuScheduler::Initialize(
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
const std::vector<int32>& attribs,
- GpuScheduler* parent,
- uint32 parent_texture_id,
gfx::GLShareGroup* share_group) {
- // Get the parent decoder.
- gles2::GLES2Decoder* parent_decoder = NULL;
- if (parent) {
- parent_decoder = parent->decoder_.get();
- DCHECK(parent_decoder);
- }
-
scoped_refptr<gfx::GLSurface> surface(
gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)));
if (!surface.get()) {
@@ -69,9 +60,7 @@ bool GpuScheduler::Initialize(
size,
disallowed_extensions,
allowed_extensions,
- attribs,
- parent_decoder,
- parent_texture_id);
+ attribs);
}
void GpuScheduler::Destroy() {
diff --git a/gpu/command_buffer/service/gpu_scheduler_win.cc b/gpu/command_buffer/service/gpu_scheduler_win.cc
index a92d225..20e5382 100644
--- a/gpu/command_buffer/service/gpu_scheduler_win.cc
+++ b/gpu/command_buffer/service/gpu_scheduler_win.cc
@@ -19,16 +19,7 @@ bool GpuScheduler::Initialize(
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
const std::vector<int32>& attribs,
- GpuScheduler* parent,
- uint32 parent_texture_id,
gfx::GLShareGroup* share_group) {
- // Get the parent decoder.
- gles2::GLES2Decoder* parent_decoder = NULL;
- if (parent) {
- parent_decoder = parent->decoder_.get();
- DCHECK(parent_decoder);
- }
-
// Create either a view or pbuffer based GLSurface.
scoped_refptr<gfx::GLSurface> surface;
if (window) {
@@ -57,9 +48,7 @@ bool GpuScheduler::Initialize(
size,
disallowed_extensions,
allowed_extensions,
- attribs,
- parent_decoder,
- parent_texture_id);
+ attribs);
}
void GpuScheduler::Destroy() {
diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc
index 01ce0d8..30ba86c 100644
--- a/gpu/demos/framework/window.cc
+++ b/gpu/demos/framework/window.cc
@@ -64,8 +64,6 @@ bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) {
if (!gpu_scheduler->Initialize(hwnd, gfx::Size(),
gpu::gles2::DisallowedExtensions(),
NULL, std::vector<int32>(),
- NULL,
- 0,
NULL)) {
return false;
}
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index 3f18c7e..cfadf0f 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -112,7 +112,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config,
new GpuScheduler(command_buffer_.get(), NULL, NULL));
if (!gpu_scheduler->Initialize(
win, gfx::Size(), gpu::gles2::DisallowedExtensions(), NULL,
- attribs, NULL, 0, NULL))
+ attribs, NULL))
return EGL_NO_SURFACE;
command_buffer_->SetPutOffsetChangeCallback(