summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 18:41:29 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 18:41:29 +0000
commit2e7bbf2913e4327aab57e5c1b440c13711241609 (patch)
treeea7833ea4c0d051a0d3ef626c33fd043c4fea2f9 /gpu
parentc620fd59c67f5421b75e865075fb4e9aa2c24f7f (diff)
downloadchromium_src-2e7bbf2913e4327aab57e5c1b440c13711241609.zip
chromium_src-2e7bbf2913e4327aab57e5c1b440c13711241609.tar.gz
chromium_src-2e7bbf2913e4327aab57e5c1b440c13711241609.tar.bz2
Create new GLSurface for cross process image transport.
Currently cross process image transport (on OSX and TOUCH_UI) uses the WebGL code path to render to a texture via FBO. This makes a clean break with path and centralizes the GL context specific IPC communication in one location. By separating from the WebGL code, I was able to avoid wasting a texture attached to the FBO in the decoder (the old code ignored this attachment --- the new code makes no such attachment at the decoder level). As a test of the new architecture, I have also implemented XComposite/GLX_texture_from_pixmap image transport (i.e. it's now possible to use the --use-gl=desktop backend on touch_ui builds). BUG=none TEST=3D CSS and WebGL on TOUCH_UI. Review URL: http://codereview.chromium.org/7395020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc4
-rw-r--r--gpu/command_buffer/service/gpu_scheduler.cc21
-rw-r--r--gpu/command_buffer/service/gpu_scheduler.h54
-rw-r--r--gpu/command_buffer/service/gpu_scheduler_linux.cc83
4 files changed, 24 insertions, 138 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 812218b..63f73a9 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2528,7 +2528,7 @@ void GLES2DecoderImpl::DoCopyTextureToParentTextureCHROMIUM(
}
void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) {
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI)
// Make sure that we are done drawing to the back buffer before resizing.
glFinish();
#endif
@@ -2740,7 +2740,7 @@ void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
}
info->MarkAsValid();
} else {
- service_id = 0;
+ service_id = surface_->GetBackingFrameBufferObject();
}
if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) {
diff --git a/gpu/command_buffer/service/gpu_scheduler.cc b/gpu/command_buffer/service/gpu_scheduler.cc
index fbdb16b..8809b05 100644
--- a/gpu/command_buffer/service/gpu_scheduler.cc
+++ b/gpu/command_buffer/service/gpu_scheduler.cc
@@ -68,7 +68,7 @@ bool GpuScheduler::InitializeCommon(
if (!context->MakeCurrent(surface))
return false;
-#if !defined(OS_MACOSX)
+#if !defined(OS_MACOSX) && !defined(TOUCH_UI)
// Set up swap interval for onscreen contexts.
if (!surface->IsOffscreen()) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync))
@@ -129,7 +129,7 @@ bool GpuScheduler::SetParent(GpuScheduler* parent_scheduler,
return decoder_->SetParent(NULL, 0);
}
-#if defined(OS_MACOSX) || defined(TOUCH_UI)
+#if defined(OS_MACOSX)
namespace {
const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1;
}
@@ -156,11 +156,7 @@ void GpuScheduler::PutChanged() {
#if defined(OS_MACOSX)
bool do_rate_limiting = surface_.get() != NULL;
-#elif defined(TOUCH_UI)
- bool do_rate_limiting = back_surface_.get() != NULL;
-#endif
-#if defined(OS_MACOSX) || defined(TOUCH_UI)
// Don't swamp the browser process with SwapBuffers calls it can't handle.
DCHECK(!do_rate_limiting ||
swap_buffers_count_ - acknowledged_swap_buffers_count_ == 0);
@@ -239,10 +235,7 @@ void GpuScheduler::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
}
void GpuScheduler::SetResizeCallback(Callback1<gfx::Size>::Type* callback) {
- wrapped_resize_callback_.reset(callback);
- decoder_->SetResizeCallback(
- NewCallback(this,
- &GpuScheduler::WillResize));
+ decoder_->SetResizeCallback(callback);
}
void GpuScheduler::SetSwapBuffersCallback(
@@ -271,17 +264,11 @@ GpuScheduler::GpuScheduler(CommandBuffer* command_buffer,
decoder_(decoder),
parser_(parser),
unscheduled_count_(0),
-#if defined(OS_MACOSX) || defined(TOUCH_UI)
+#if defined(OS_MACOSX)
swap_buffers_count_(0),
acknowledged_swap_buffers_count_(0),
#endif
method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
-void GpuScheduler::WillResize(gfx::Size size) {
- if (wrapped_resize_callback_.get()) {
- wrapped_resize_callback_->Run(size);
- }
-}
-
} // namespace gpu
diff --git a/gpu/command_buffer/service/gpu_scheduler.h b/gpu/command_buffer/service/gpu_scheduler.h
index 4ebbab9..4ff0f3d 100644
--- a/gpu/command_buffer/service/gpu_scheduler.h
+++ b/gpu/command_buffer/service/gpu_scheduler.h
@@ -24,8 +24,6 @@
#if defined(OS_MACOSX)
#include "ui/gfx/surface/accelerated_surface_mac.h"
-#elif defined(TOUCH_UI)
-#include "ui/gfx/surface/accelerated_surface_linux.h"
#endif
namespace gfx {
@@ -55,7 +53,8 @@ class GpuScheduler : public CommandBufferEngine {
virtual ~GpuScheduler();
- // Perform platform specific and common initialization.
+ // Platform specific code to create GLContexts and GLSurfaces that are
+ // handed off to the next function.
bool Initialize(gfx::PluginWindowHandle hwnd,
const gfx::Size& size,
bool software,
@@ -64,6 +63,15 @@ class GpuScheduler : public CommandBufferEngine {
const std::vector<int32>& attribs,
gfx::GLShareGroup* share_group);
+ // Takes ownership of GLSurface and GLContext.
+ bool InitializeCommon(
+ const scoped_refptr<gfx::GLSurface>& surface,
+ const scoped_refptr<gfx::GLContext>& context,
+ const gfx::Size& size,
+ const gles2::DisallowedExtensions& disallowed_extensions,
+ const char* allowed_extensions,
+ const std::vector<int32>& attribs);
+
void Destroy();
void DestroyCommon();
@@ -93,7 +101,7 @@ class GpuScheduler : public CommandBufferEngine {
// Asynchronously resizes an offscreen frame buffer.
void ResizeOffscreenFrameBuffer(const gfx::Size& size);
-#if defined(OS_MACOSX) || defined(TOUCH_UI)
+#if defined(OS_MACOSX)
// To prevent the GPU process from overloading the browser process,
// we need to track the number of swap buffers calls issued and
// acknowledged per on-screen context, and keep the GPU from getting
@@ -104,9 +112,7 @@ class GpuScheduler : public CommandBufferEngine {
uint64 acknowledged_swap_buffers_count() const;
void set_acknowledged_swap_buffers_count(
uint64 acknowledged_swap_buffers_count);
-#endif
-#if defined(OS_MACOSX)
// Needed only on Mac OS X, which does not render into an on-screen
// window and therefore requires the backing store to be resized
// manually. Returns an opaque identifier for the new backing store.
@@ -126,16 +132,6 @@ class GpuScheduler : public CommandBufferEngine {
void DidDestroySurface();
#endif
-#if defined(TOUCH_UI)
- virtual void CreateBackSurface(const gfx::Size& size);
- // Should not be back_surface_ or front_surface_.
- virtual void ReleaseSurface(uint64 surface_id);
-
- // Returns the id of the surface (or 0 if no such surface has been created).
- virtual uint64 GetBackSurfaceId();
- virtual uint64 GetFrontSurfaceId();
-#endif
-
// Sets a callback that is called when a glResizeCHROMIUM command
// is processed.
void SetResizeCallback(Callback1<gfx::Size>::Type* callback);
@@ -155,17 +151,6 @@ class GpuScheduler : public CommandBufferEngine {
// Get the GLES2Decoder associated with this scheduler.
gles2::GLES2Decoder* decoder() const { return decoder_.get(); }
- protected:
- // Perform common initialization. Takes ownership of GLSurface and GLContext.
- bool InitializeCommon(
- const scoped_refptr<gfx::GLSurface>& surface,
- const scoped_refptr<gfx::GLContext>& context,
- const gfx::Size& size,
- const gles2::DisallowedExtensions& disallowed_extensions,
- const char* allowed_extensions,
- const std::vector<int32>& attribs);
-
-
private:
// If a group is not passed in one will be created.
GpuScheduler(CommandBuffer* command_buffer,
@@ -173,10 +158,6 @@ class GpuScheduler : public CommandBufferEngine {
CommandParser* parser);
// Called via a callback just before we are supposed to call the
- // user's resize callback.
- void WillResize(gfx::Size size);
-
- // Called via a callback just before we are supposed to call the
// user's swap buffers callback.
void WillSwapBuffers();
@@ -193,22 +174,13 @@ class GpuScheduler : public CommandBufferEngine {
scoped_ptr<Callback0::Type> scheduled_callback_;
-#if defined(OS_MACOSX) || defined(TOUCH_UI)
+#if defined(OS_MACOSX)
uint64 swap_buffers_count_;
uint64 acknowledged_swap_buffers_count_;
-#endif
-
-#if defined(OS_MACOSX)
scoped_ptr<AcceleratedSurface> surface_;
-#elif defined(TOUCH_UI)
- std::map<uint64, scoped_refptr<AcceleratedSurface> >
- surfaces_;
- scoped_refptr<AcceleratedSurface> back_surface_;
- scoped_refptr<AcceleratedSurface> front_surface_;
#endif
ScopedRunnableMethodFactory<GpuScheduler> method_factory_;
- scoped_ptr<Callback1<gfx::Size>::Type> wrapped_resize_callback_;
scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_;
scoped_ptr<Callback0::Type> command_processed_callback_;
base::Callback<void(int32)> set_token_callback_;
diff --git a/gpu/command_buffer/service/gpu_scheduler_linux.cc b/gpu/command_buffer/service/gpu_scheduler_linux.cc
index fcbbd65..9312245 100644
--- a/gpu/command_buffer/service/gpu_scheduler_linux.cc
+++ b/gpu/command_buffer/service/gpu_scheduler_linux.cc
@@ -7,13 +7,6 @@
#include "ui/gfx/gl/gl_share_group.h"
#include "ui/gfx/gl/gl_surface.h"
-#if defined(TOUCH_UI)
-#include "third_party/angle/include/EGL/egl.h"
-#include "third_party/angle/include/EGL/eglext.h"
-#include "ui/gfx/gl/gl_surface_egl.h"
-#include "ui/gfx/gl/gl_bindings.h"
-#endif
-
using ::base::SharedMemory;
namespace gpu {
@@ -26,18 +19,18 @@ bool GpuScheduler::Initialize(
const char* allowed_extensions,
const std::vector<int32>& attribs,
gfx::GLShareGroup* share_group) {
+#if defined(TOUCH_UI)
+ NOTIMPLEMENTED();
+ return false;
+#endif
+
// Create either a view or pbuffer based GLSurface.
scoped_refptr<gfx::GLSurface> surface;
-#if defined(TOUCH_UI)
- surface = gfx::GLSurface::CreateOffscreenGLSurface(software, gfx::Size(1, 1));
-#else
if (window)
surface = gfx::GLSurface::CreateViewGLSurface(software, window);
else
surface = gfx::GLSurface::CreateOffscreenGLSurface(software,
gfx::Size(1, 1));
-#endif
-
if (!surface.get()) {
LOG(ERROR) << "GpuScheduler::Initialize failed.\n";
Destroy();
@@ -66,75 +59,9 @@ void GpuScheduler::Destroy() {
}
void GpuScheduler::WillSwapBuffers() {
-#if defined(TOUCH_UI)
- front_surface_.swap(back_surface_);
- DCHECK_NE(front_surface_.get(), static_cast<AcceleratedSurface*>(NULL));
-
- gfx::Size expected_size = front_surface_->size();
- if (!back_surface_.get() || back_surface_->size() != expected_size) {
- wrapped_resize_callback_->Run(expected_size);
- } else {
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- back_surface_->texture(),
- 0);
- }
- ++swap_buffers_count_;
- glFlush();
-#endif
if (wrapped_swap_buffers_callback_.get()) {
wrapped_swap_buffers_callback_->Run();
}
}
-#if defined(TOUCH_UI)
-uint64 GpuScheduler::GetBackSurfaceId() {
- if (!back_surface_.get())
- return 0;
- return back_surface_->pixmap();
-}
-
-uint64 GpuScheduler::GetFrontSurfaceId() {
- if (!front_surface_.get())
- return 0;
- return front_surface_->pixmap();
-}
-
-uint64 GpuScheduler::swap_buffers_count() const {
- return swap_buffers_count_;
-}
-
-uint64 GpuScheduler::acknowledged_swap_buffers_count() const {
- return acknowledged_swap_buffers_count_;
-}
-
-void GpuScheduler::set_acknowledged_swap_buffers_count(
- uint64 acknowledged_swap_buffers_count) {
- acknowledged_swap_buffers_count_ = acknowledged_swap_buffers_count;
-}
-
-void GpuScheduler::CreateBackSurface(const gfx::Size& size) {
- decoder()->ResizeOffscreenFrameBuffer(size);
- decoder()->UpdateOffscreenFrameBufferSize();
-
- back_surface_ = new AcceleratedSurface(size);
- surfaces_[back_surface_->pixmap()] = back_surface_;
-
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- back_surface_->texture(),
- 0);
- glFlush();
-}
-
-void GpuScheduler::ReleaseSurface(uint64 surface_id) {
- DCHECK_NE(surfaces_[surface_id].get(), back_surface_.get());
- DCHECK_NE(surfaces_[surface_id].get(), front_surface_.get());
- surfaces_.erase(surface_id);
-}
-
-#endif
-
} // namespace gpu