summaryrefslogtreecommitdiffstats
path: root/ui/gfx/surface
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 22:57:49 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 22:57:49 +0000
commit33e9cda3cdc7dfa6c0787814512fb6b42b0ff408 (patch)
tree428a14ec79e3024cf852690f4d3a31b8b655a573 /ui/gfx/surface
parent5eab39e3f747dbb4caa4dfff6029ec00572e6d89 (diff)
downloadchromium_src-33e9cda3cdc7dfa6c0787814512fb6b42b0ff408.zip
chromium_src-33e9cda3cdc7dfa6c0787814512fb6b42b0ff408.tar.gz
chromium_src-33e9cda3cdc7dfa6c0787814512fb6b42b0ff408.tar.bz2
Add IPC allowing GPU process to tell browser process to temporarily drop a front buffer.
This is to conserve video memory for hidden tabs that are not expected to be needed in the near term. Review URL: https://chromiumcodereview.appspot.com/9303009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/surface')
-rw-r--r--ui/gfx/surface/accelerated_surface_win.cc17
-rw-r--r--ui/gfx/surface/accelerated_surface_win.h5
2 files changed, 22 insertions, 0 deletions
diff --git a/ui/gfx/surface/accelerated_surface_win.cc b/ui/gfx/surface/accelerated_surface_win.cc
index c5c93c2..45fdf48 100644
--- a/ui/gfx/surface/accelerated_surface_win.cc
+++ b/ui/gfx/surface/accelerated_surface_win.cc
@@ -122,6 +122,10 @@ class AcceleratedPresenter {
const int thread_affinity_;
base::ScopedNativeLibrary d3d_module_;
+ // Whether the presenter is suspended and therefore unable to represent. Only
+ // accessed on the UI thread so the lock is unnecessary.
+ bool suspended_;
+
// The size of the swap chain once any pending resizes have been processed.
// Only accessed on the UI thread so the lock is unnecessary.
gfx::Size pending_size_;
@@ -151,6 +155,7 @@ class AcceleratedPresenter {
AcceleratedPresenter::AcceleratedPresenter()
: thread_affinity_(g_present_thread_pool.Pointer()->NextThread()),
+ suspended_(true),
num_pending_resizes_(0) {
g_present_thread_pool.Pointer()->PostTask(
thread_affinity_,
@@ -196,6 +201,8 @@ void AcceleratedPresenter::AsyncPresentAndAcknowledge(
size,
surface_id,
completion_task));
+
+ suspended_ = false;
}
bool AcceleratedPresenter::Present(gfx::NativeWindow window) {
@@ -203,6 +210,9 @@ bool AcceleratedPresenter::Present(gfx::NativeWindow window) {
HRESULT hr;
+ if (suspended_)
+ return false;
+
base::AutoLock locked(lock_);
if (!device_)
@@ -265,6 +275,8 @@ void AcceleratedPresenter::Suspend() {
base::Bind(&AcceleratedPresenter::DoResize,
base::Unretained(this),
gfx::Size(1, 1)));
+
+ suspended_ = true;
}
void AcceleratedPresenter::DoInitialize() {
@@ -499,3 +511,8 @@ void AcceleratedSurface::AsyncPresentAndAcknowledge(
bool AcceleratedSurface::Present(HWND window) {
return presenter_->Present(window);
}
+
+void AcceleratedSurface::Suspend() {
+ presenter_->Suspend();
+}
+
diff --git a/ui/gfx/surface/accelerated_surface_win.h b/ui/gfx/surface/accelerated_surface_win.h
index a2b6c66..cf59178 100644
--- a/ui/gfx/surface/accelerated_surface_win.h
+++ b/ui/gfx/surface/accelerated_surface_win.h
@@ -30,6 +30,11 @@ class SURFACE_EXPORT AcceleratedSurface {
// Synchronously present a frame with no acknowledgement.
bool Present(HWND window);
+ // Temporarily release resources until a new surface is asynchronously
+ // presented. Present will not be able to represent the last surface after
+ // calling this and will return false.
+ void Suspend();
+
private:
linked_ptr<AcceleratedPresenter> presenter_;
DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface);