summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-25 03:15:00 +0000
committerhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-25 03:15:00 +0000
commitb8673e69bc76bac61200233453a2857ea4c334cf (patch)
tree83b0b5e79ada5b0fc970d3a64e8504a2c91dceca /content
parentc071375ae93b4bd4f40523171a457c3cefc1e527 (diff)
downloadchromium_src-b8673e69bc76bac61200233453a2857ea4c334cf.zip
chromium_src-b8673e69bc76bac61200233453a2857ea4c334cf.tar.gz
chromium_src-b8673e69bc76bac61200233453a2857ea4c334cf.tar.bz2
Use a singleton 1x1 offscreen surface for all TextureImageTransportSurface instances.
This is to reduce the number of dummy offscreen surfaces created for the purpose of making TextureImageTransportSurface current. BUG=NONE TEST=manually on daisy; verified that the dummy surface only gets allocated when first needed and destroyed when the last instance of TextureImageTrasnportSurface is destroyed. Review URL: https://chromiumcodereview.appspot.com/10984004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158512 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/gpu_channel_manager.cc12
-rw-r--r--content/common/gpu/gpu_channel_manager.h4
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc4
-rw-r--r--content/common/gpu/texture_image_transport_surface.cc8
-rw-r--r--content/common/gpu/texture_image_transport_surface.h2
5 files changed, 22 insertions, 8 deletions
diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
index be60a19..1da6aec 100644
--- a/content/common/gpu/gpu_channel_manager.cc
+++ b/content/common/gpu/gpu_channel_manager.cc
@@ -38,6 +38,10 @@ GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread,
GpuChannelManager::~GpuChannelManager() {
gpu_channels_.clear();
+ if (default_offscreen_surface_.get()) {
+ default_offscreen_surface_->Destroy();
+ default_offscreen_surface_ = NULL;
+ }
}
gpu::gles2::ProgramCache* GpuChannelManager::program_cache() {
@@ -175,3 +179,11 @@ void GpuChannelManager::LoseAllContexts() {
void GpuChannelManager::OnLoseAllContexts() {
gpu_channels_.clear();
}
+
+gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
+ if (!default_offscreen_surface_.get()) {
+ default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(
+ false, gfx::Size(1, 1));
+ }
+ return default_offscreen_surface_.get();
+}
diff --git a/content/common/gpu/gpu_channel_manager.h b/content/common/gpu/gpu_channel_manager.h
index 3e4af65..b256a56 100644
--- a/content/common/gpu/gpu_channel_manager.h
+++ b/content/common/gpu/gpu_channel_manager.h
@@ -17,6 +17,7 @@
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gl/gl_surface.h"
namespace base {
class WaitableEvent;
@@ -92,6 +93,8 @@ class GpuChannelManager : public IPC::Listener,
SyncPointManager* sync_point_manager() { return sync_point_manager_; }
+ gfx::GLSurface* GetDefaultOffscreenSurface();
+
private:
// Message handlers.
void OnEstablishChannel(int client_id, bool share_context);
@@ -123,6 +126,7 @@ class GpuChannelManager : public IPC::Listener,
GpuWatchdog* watchdog_;
scoped_refptr<SyncPointManager> sync_point_manager_;
scoped_ptr<gpu::gles2::ProgramCache> program_cache_;
+ scoped_refptr<gfx::GLSurface> default_offscreen_surface_;
DISALLOW_COPY_AND_ASSIGN(GpuChannelManager);
};
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 6661447..967f153 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -375,8 +375,8 @@ void GpuCommandBufferStub::OnInitialize(
this,
handle_);
} else {
- surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_,
- gfx::Size(1, 1));
+ GpuChannelManager* manager = channel_->gpu_channel_manager();
+ surface_ = manager->GetDefaultOffscreenSurface();
}
if (!surface_.get()) {
diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc
index c6d28e0..86f5ebc 100644
--- a/content/common/gpu/texture_image_transport_surface.cc
+++ b/content/common/gpu/texture_image_transport_surface.cc
@@ -88,7 +88,7 @@ bool TextureImageTransportSurface::Initialize() {
texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
- surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1));
+ surface_ = manager->GetDefaultOffscreenSurface();
if (!surface_.get())
return false;
@@ -108,10 +108,8 @@ void TextureImageTransportSurface::Destroy() {
ReleaseParentStub();
}
- if (surface_.get()) {
- surface_->Destroy();
+ if (surface_.get())
surface_ = NULL;
- }
helper_->Destroy();
}
@@ -348,7 +346,7 @@ void* TextureImageTransportSurface::GetHandle() {
}
unsigned TextureImageTransportSurface::GetFormat() {
- return surface_ ? surface_->GetFormat() : 0;
+ return surface_.get() ? surface_->GetFormat() : 0;
}
void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected(
diff --git a/content/common/gpu/texture_image_transport_surface.h b/content/common/gpu/texture_image_transport_surface.h
index 19ed88c..2779d8a 100644
--- a/content/common/gpu/texture_image_transport_surface.h
+++ b/content/common/gpu/texture_image_transport_surface.h
@@ -110,7 +110,7 @@ class TextureImageTransportSurface :
gfx::GLSurfaceHandle handle_;
GpuCommandBufferStub* parent_stub_;
- // The offscreeb surface used to make the context current. However note that
+ // The offscreen surface used to make the context current. However note that
// the actual rendering is always redirected to an FBO.
scoped_refptr<GLSurface> surface_;