summaryrefslogtreecommitdiffstats
path: root/content/common/gpu
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 21:27:42 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 21:27:42 +0000
commitd8f0b2d5f854cde9556fb4a9bc1a61e636aeba8e (patch)
tree76a2e23671ee3cc1d3399e701f9bfbcc0a20bc7b /content/common/gpu
parent6a9361218553ed2eecd22eab8127597bc96a0fec (diff)
downloadchromium_src-d8f0b2d5f854cde9556fb4a9bc1a61e636aeba8e.zip
chromium_src-d8f0b2d5f854cde9556fb4a9bc1a61e636aeba8e.tar.gz
chromium_src-d8f0b2d5f854cde9556fb4a9bc1a61e636aeba8e.tar.bz2
Move vsync logic to the surface type
This should be a noop right now, but will allow setting vsync differently between different surfaces (e.g. transport vs main) instead of based on an ifdef. BUG=99516 TEST=run with/without --disable-gpu-vsync, on both aura and regular, on poster circle and watch frame rate Review URL: http://codereview.chromium.org/9389031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/gpu')
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc15
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h3
-rw-r--r--content/common/gpu/image_transport_surface.cc20
-rw-r--r--content/common/gpu/image_transport_surface.h8
4 files changed, 21 insertions, 25 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 554f690..87714ae 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -138,19 +138,6 @@ bool GpuCommandBufferStub::HasMoreWork() {
return scheduler_.get() && scheduler_->HasMoreWork();
}
-void GpuCommandBufferStub::SetSwapInterval() {
-#if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
- // Set up swap interval for onscreen contexts.
- if (!surface_->IsOffscreen()) {
- decoder_->MakeCurrent();
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync))
- context_->SetSwapInterval(0);
- else
- context_->SetSwapInterval(1);
- }
-#endif
-}
-
void GpuCommandBufferStub::Destroy() {
// The scheduler has raw references to the decoder and the command buffer so
// destroy it before those.
@@ -260,8 +247,6 @@ void GpuCommandBufferStub::OnInitialize(
base::Bind(&GpuCommandBufferStub::SendConsoleMessage,
base::Unretained(this)));
- SetSwapInterval();
-
command_buffer_->SetPutOffsetChangeCallback(
base::Bind(&gpu::GpuScheduler::PutChanged,
base::Unretained(scheduler_.get())));
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index 66c3431..bec7b23 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -112,9 +112,6 @@ class GpuCommandBufferStub
// Whether this command buffer needs to be polled again in the future.
bool HasMoreWork();
- // Set the swap interval according to the command line.
- void SetSwapInterval();
-
gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); }
gpu::GpuScheduler* scheduler() const { return scheduler_.get(); }
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index 097c4ee..2f12e7b 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -8,11 +8,13 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/command_line.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/gpu_messages.h"
#include "gpu/command_buffer/service/gpu_scheduler.h"
+#include "ui/gfx/gl/gl_switches.h"
ImageTransportSurface::ImageTransportSurface() {
}
@@ -160,9 +162,10 @@ void ImageTransportHelper::Resize(gfx::Size size) {
}
void ImageTransportHelper::SetSwapInterval() {
- if (!stub_.get())
- return;
- stub_->SetSwapInterval();
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync))
+ Decoder()->GetGLContext()->SetSwapInterval(0);
+ else
+ Decoder()->GetGLContext()->SetSwapInterval(1);
}
bool ImageTransportHelper::MakeCurrent() {
@@ -194,7 +197,8 @@ PassThroughImageTransportSurface::PassThroughImageTransportSurface(
gfx::GLSurface* surface,
bool transport)
: GLSurfaceAdapter(surface),
- transport_(transport) {
+ transport_(transport),
+ did_set_swap_interval_(false) {
helper_.reset(new ImageTransportHelper(this,
manager,
stub,
@@ -256,6 +260,14 @@ bool PassThroughImageTransportSurface::PostSubBuffer(
return result;
}
+bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
+ if (!did_set_swap_interval_) {
+ helper_->SetSwapInterval();
+ did_set_swap_interval_ = true;
+ }
+ return true;
+}
+
void PassThroughImageTransportSurface::OnBuffersSwappedACK() {
DCHECK(transport_);
helper_->SetScheduled(true);
diff --git a/content/common/gpu/image_transport_surface.h b/content/common/gpu/image_transport_surface.h
index bd013f3..0664df0 100644
--- a/content/common/gpu/image_transport_surface.h
+++ b/content/common/gpu/image_transport_surface.h
@@ -109,6 +109,9 @@ class ImageTransportHelper : public IPC::Channel::Listener {
// Make the surface's context current.
bool MakeCurrent();
+ // Set the default swap interval on the surface.
+ void SetSwapInterval();
+
void Suspend();
private:
@@ -124,9 +127,6 @@ class ImageTransportHelper : public IPC::Channel::Listener {
// Backbuffer resize callback.
void Resize(gfx::Size size);
- // Set the default swap interval on the surface.
- void SetSwapInterval();
-
// Weak pointers that point to objects that outlive this helper.
ImageTransportSurface* surface_;
GpuChannelManager* manager_;
@@ -155,6 +155,7 @@ class PassThroughImageTransportSurface
virtual void Destroy() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
+ virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
// ImageTransportSurface implementation.
virtual void OnNewSurfaceACK(
@@ -168,6 +169,7 @@ class PassThroughImageTransportSurface
scoped_ptr<ImageTransportHelper> helper_;
gfx::Size new_size_;
bool transport_;
+ bool did_set_swap_interval_;
DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface);
};