summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authornkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-18 10:46:14 +0000
committernkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-18 10:46:14 +0000
commit73d916800284bb6950492ea7c2520dd101bea91c (patch)
tree3c66f5236530af4e9154e0dbd4deebb14af1a688 /content/common
parent9f7e5f77042c5e5908696d264fa6f4c8485efba1 (diff)
downloadchromium_src-73d916800284bb6950492ea7c2520dd101bea91c.zip
chromium_src-73d916800284bb6950492ea7c2520dd101bea91c.tar.gz
chromium_src-73d916800284bb6950492ea7c2520dd101bea91c.tar.bz2
Revert 142541 - Drop frontbuffers with ui-use-gpu-process, synchronized with browser, decoupled from backbuffer drop.
Reason (speculative): According to http://build.chromium.org/p/chromium.chromiumos/builders/ChromiumOS%20%28amd64%29/builds/2556 http://build.chromium.org/p/chromium.chromiumos/builders/ChromiumOS%20%28x86%29/builds/6039 after this commit those bots startet faling VMTest stage. On Aura, every time a tab is backgrounded, RenderWidgetHostViewAura will reset its handle to the front surface. If that tab is foregrounded again, that front surface will not be used until synchronizing with the gpu process to make sure that surface is still available. By doing this, the gpu process knows when it is safe to discard the front surface. RWHVA sends a FrontSurfaceIsProtected(bool, int) message to the gpu process to keep it informed about front surface protection. The int is a state-of-the-world identifier to protect from ABA issues. RWHVA delays sending FrontSurfaceIsProtected(false) until after the current surface is certain to not be in use, namely after the compositor finishes the current frame and the browser thumbnailer is complete. BUG=112842 TEST=Manual Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=142408 Review URL: https://chromiumcodereview.appspot.com/10052018 TBR=mmocny@chromium.org Review URL: https://chromiumcodereview.appspot.com/10563021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/gpu/gpu_memory_manager_unittest.cc4
-rw-r--r--content/common/gpu/gpu_messages.h8
-rw-r--r--content/common/gpu/image_transport_surface.cc11
-rw-r--r--content/common/gpu/image_transport_surface.h4
-rw-r--r--content/common/gpu/texture_image_transport_surface.cc107
-rw-r--r--content/common/gpu/texture_image_transport_surface.h10
6 files changed, 33 insertions, 111 deletions
diff --git a/content/common/gpu/gpu_memory_manager_unittest.cc b/content/common/gpu/gpu_memory_manager_unittest.cc
index 8a9a4fd..0e861aa 100644
--- a/content/common/gpu/gpu_memory_manager_unittest.cc
+++ b/content/common/gpu/gpu_memory_manager_unittest.cc
@@ -41,6 +41,8 @@ class FakeCommandBufferStub : public GpuCommandBufferStubBase {
const GpuCommandBufferStubBase& stub) const {
return false;
}
+ virtual void SendMemoryAllocationToProxy(const GpuMemoryAllocation& alloc) {
+ }
virtual void SetMemoryAllocation(const GpuMemoryAllocation& alloc) {
allocation_ = alloc;
}
@@ -75,6 +77,8 @@ class FakeCommandBufferStubWithoutSurface : public GpuCommandBufferStubBase {
share_group_.end(),
&stub) != share_group_.end();
}
+ virtual void SendMemoryAllocationToProxy(const GpuMemoryAllocation& alloc) {
+ }
virtual void SetMemoryAllocation(const GpuMemoryAllocation& alloc) {
allocation_ = alloc;
}
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index ddaaff1..3d61a72 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -58,8 +58,6 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
#elif defined(OS_MACOSX)
IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window)
#endif
- IPC_STRUCT_MEMBER(uint32, protection_state_id)
- IPC_STRUCT_MEMBER(bool, skip_ack)
IPC_STRUCT_END()
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT
@@ -75,7 +73,6 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params)
#if defined(OS_MACOSX)
IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window)
#endif
- IPC_STRUCT_MEMBER(uint32, protection_state_id)
IPC_STRUCT_END()
IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params)
@@ -204,11 +201,6 @@ IPC_MESSAGE_ROUTED2(AcceleratedSurfaceMsg_NewACK,
uint64 /* surface_handle */,
TransportDIB::Handle /* shared memory buffer */)
-// Tells the GPU process if it's worth suggesting release of the front surface.
-IPC_MESSAGE_ROUTED2(AcceleratedSurfaceMsg_SetFrontSurfaceIsProtected,
- bool /* is_protected */,
- uint32 /* protection_state_id */)
-
// Tells the GPU process that the browser process handled the swap
// buffers request.
IPC_MESSAGE_ROUTED0(AcceleratedSurfaceMsg_BuffersSwappedACK)
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index 4ab12d4..7e49b9f 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -21,10 +21,6 @@ ImageTransportSurface::ImageTransportSurface() {}
ImageTransportSurface::~ImageTransportSurface() {}
-void ImageTransportSurface::OnSetFrontSurfaceIsProtected(
- bool is_protected, uint32 protection_state_id) {
-}
-
void ImageTransportSurface::GetRegionsToCopy(
const gfx::Rect& previous_damage_rect,
const gfx::Rect& new_damage_rect,
@@ -100,8 +96,6 @@ bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) {
OnPostSubBufferACK)
IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_NewACK,
OnNewSurfaceACK)
- IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_SetFrontSurfaceIsProtected,
- OnSetFrontSurfaceIsProtected)
IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_ResizeViewACK, OnResizeViewACK);
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -207,11 +201,6 @@ void ImageTransportHelper::OnNewSurfaceACK(
surface_->OnNewSurfaceACK(surface_handle, shm_handle);
}
-void ImageTransportHelper::OnSetFrontSurfaceIsProtected(
- bool is_protected, uint32 protection_state_id) {
- surface_->OnSetFrontSurfaceIsProtected(is_protected, protection_state_id);
-}
-
void ImageTransportHelper::OnBuffersSwappedACK() {
surface_->OnBuffersSwappedACK();
}
diff --git a/content/common/gpu/image_transport_surface.h b/content/common/gpu/image_transport_surface.h
index 936f40d..019aa50 100644
--- a/content/common/gpu/image_transport_surface.h
+++ b/content/common/gpu/image_transport_surface.h
@@ -67,8 +67,6 @@ class ImageTransportSurface {
virtual void OnPostSubBufferACK() = 0;
virtual void OnResizeViewACK() = 0;
virtual void OnResize(gfx::Size size) = 0;
- virtual void OnSetFrontSurfaceIsProtected(bool is_protected,
- uint32 protection_state_id);
// Creates the appropriate surface depending on the GL implementation.
static scoped_refptr<gfx::GLSurface>
@@ -140,8 +138,6 @@ class ImageTransportHelper : public IPC::Channel::Listener {
void OnBuffersSwappedACK();
void OnPostSubBufferACK();
void OnResizeViewACK();
- void OnSetFrontSurfaceIsProtected(bool is_protected,
- uint32 protection_state_id);
// Backbuffer resize callback.
void Resize(gfx::Size size);
diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc
index e5fd148..ec81bbc 100644
--- a/content/common/gpu/texture_image_transport_surface.cc
+++ b/content/common/gpu/texture_image_transport_surface.cc
@@ -69,8 +69,6 @@ TextureImageTransportSurface::TextureImageTransportSurface(
stub_destroyed_(false),
backbuffer_suggested_allocation_(true),
frontbuffer_suggested_allocation_(true),
- frontbuffer_is_protected_(true),
- protection_state_id_(0),
handle_(handle),
parent_stub_(NULL) {
helper_.reset(new ImageTransportHelper(this,
@@ -184,36 +182,16 @@ void TextureImageTransportSurface::SetBackbufferAllocation(bool allocation) {
if (!helper_->MakeCurrent())
return;
- if (backbuffer_suggested_allocation_) {
- DCHECK(!textures_[back()].info->service_id() ||
- !textures_[back()].sent_to_client);
+ if (backbuffer_suggested_allocation_)
CreateBackTexture(textures_[back()].size);
- } else {
- ReleaseTexture(back());
- }
+ else
+ ReleaseBackTexture();
}
void TextureImageTransportSurface::SetFrontbufferAllocation(bool allocation) {
if (frontbuffer_suggested_allocation_ == allocation)
return;
frontbuffer_suggested_allocation_ = allocation;
- AdjustFrontBufferAllocation();
-}
-
-void TextureImageTransportSurface::AdjustFrontBufferAllocation() {
- if (!helper_->MakeCurrent())
- return;
-
- if (!frontbuffer_suggested_allocation_ && !frontbuffer_is_protected_ &&
- textures_[front()].info->service_id()) {
- ReleaseTexture(front());
- if (textures_[front()].sent_to_client) {
- GpuHostMsg_AcceleratedSurfaceRelease_Params params;
- params.identifier = textures_[front()].client_id;
- helper_->SendAcceleratedSurfaceRelease(params);
- textures_[front()].sent_to_client = false;
- }
- }
}
void* TextureImageTransportSurface::GetShareHandle() {
@@ -254,7 +232,7 @@ void TextureImageTransportSurface::OnWillDestroyStub(
bool TextureImageTransportSurface::SwapBuffers() {
DCHECK(backbuffer_suggested_allocation_);
- if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_)
+ if (!frontbuffer_suggested_allocation_)
return true;
if (!parent_stub_) {
LOG(ERROR) << "SwapBuffers failed because no parent stub.";
@@ -263,14 +241,12 @@ bool TextureImageTransportSurface::SwapBuffers() {
glFlush();
front_ = back();
- previous_damage_rect_ = gfx::Rect(textures_[front()].size);
+ previous_damage_rect_ = gfx::Rect(textures_[front_].size);
- DCHECK(textures_[front()].client_id != 0);
+ DCHECK(textures_[front_].client_id != 0);
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
- params.surface_handle = textures_[front()].client_id;
- params.protection_state_id = protection_state_id_;
- params.skip_ack = false;
+ params.surface_handle = textures_[front_].client_id;
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
helper_->SetScheduled(false);
return true;
@@ -279,30 +255,32 @@ bool TextureImageTransportSurface::SwapBuffers() {
bool TextureImageTransportSurface::PostSubBuffer(
int x, int y, int width, int height) {
DCHECK(backbuffer_suggested_allocation_);
- DCHECK(textures_[back()].info->service_id());
- if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_)
+ if (!frontbuffer_suggested_allocation_)
return true;
// If we are recreating the frontbuffer with this swap, make sure we are
// drawing a full frame.
- DCHECK(textures_[front()].info->service_id() ||
+ DCHECK(textures_[front_].info->service_id() ||
(!x && !y && gfx::Size(width, height) == textures_[back()].size));
if (!parent_stub_) {
LOG(ERROR) << "PostSubBuffer failed because no parent stub.";
return false;
}
+ DCHECK(textures_[back()].info);
+ int back_texture_service_id = textures_[back()].info->service_id();
+
+ DCHECK(textures_[front_].info);
+ int front_texture_service_id = textures_[front_].info->service_id();
+
+ gfx::Size expected_size = textures_[back()].size;
+ bool surfaces_same_size = textures_[front_].size == expected_size;
+
const gfx::Rect new_damage_rect(x, y, width, height);
// An empty damage rect is a successful no-op.
if (new_damage_rect.IsEmpty())
return true;
- int back_texture_service_id = textures_[back()].info->service_id();
- int front_texture_service_id = textures_[front()].info->service_id();
-
- gfx::Size expected_size = textures_[back()].size;
- bool surfaces_same_size = textures_[front()].size == expected_size;
-
if (surfaces_same_size) {
std::vector<gfx::Rect> regions_to_copy;
GetRegionsToCopy(previous_damage_rect_, new_damage_rect, &regions_to_copy);
@@ -329,19 +307,17 @@ bool TextureImageTransportSurface::PostSubBuffer(
glFlush();
front_ = back();
- previous_damage_rect_ = new_damage_rect;
-
- DCHECK(textures_[front()].client_id);
GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
- params.surface_handle = textures_[front()].client_id;
+ params.surface_handle = textures_[front_].client_id;
params.x = x;
params.y = y;
params.width = width;
params.height = height;
- params.protection_state_id = protection_state_id_;
helper_->SendAcceleratedSurfacePostSubBuffer(params);
helper_->SetScheduled(false);
+
+ previous_damage_rect_ = new_damage_rect;
return true;
}
@@ -366,35 +342,10 @@ void TextureImageTransportSurface::OnNewSurfaceACK(
uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) {
}
-void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected(
- bool is_protected, uint32 protection_state_id) {
- protection_state_id_ = protection_state_id;
- if (frontbuffer_is_protected_ == is_protected)
- return;
- frontbuffer_is_protected_ = is_protected;
- AdjustFrontBufferAllocation();
-
- // If surface is set to protected, and we haven't actually released it yet,
- // we can set the ui surface handle now just by sending a swap message.
- if (is_protected && textures_[front()].info->service_id() &&
- textures_[front()].sent_to_client) {
- GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
- params.surface_handle = textures_[front()].client_id;
- params.protection_state_id = protection_state_id_;
- params.skip_ack = true;
- helper_->SendAcceleratedSurfaceBuffersSwapped(params);
- }
-}
-
void TextureImageTransportSurface::OnBuffersSwappedACK() {
if (helper_->MakeCurrent()) {
- if (textures_[front()].size != textures_[back()].size ||
- !textures_[back()].info->service_id() ||
- !textures_[back()].sent_to_client) {
- // We may get an ACK from a stale swap just to reschedule. In that case,
- // we may not have a backbuffer suggestion and should not recreate one.
- if (backbuffer_suggested_allocation_)
- CreateBackTexture(textures_[front()].size);
+ if (textures_[front_].size != textures_[back()].size) {
+ CreateBackTexture(textures_[front_].size);
} else {
AttachBackTextureToFBO();
}
@@ -413,11 +364,10 @@ void TextureImageTransportSurface::OnResizeViewACK() {
NOTREACHED();
}
-void TextureImageTransportSurface::ReleaseTexture(int id) {
+void TextureImageTransportSurface::ReleaseBackTexture() {
if (!parent_stub_)
return;
- Texture& texture = textures_[id];
- TextureInfo* info = texture.info;
+ TextureInfo* info = textures_[back()].info;
DCHECK(info);
GLuint service_id = info->service_id();
@@ -442,7 +392,7 @@ void TextureImageTransportSurface::CreateBackTexture(const gfx::Size& size) {
GLuint service_id = info->service_id();
- if (service_id && texture.size == size && texture.sent_to_client)
+ if (service_id && texture.size == size)
return;
if (!service_id) {
@@ -493,14 +443,13 @@ void TextureImageTransportSurface::CreateBackTexture(const gfx::Size& size) {
void TextureImageTransportSurface::AttachBackTextureToFBO() {
if (!parent_stub_)
return;
- TextureInfo* info = textures_[back()].info;
- DCHECK(info);
+ DCHECK(textures_[back()].info);
ScopedFrameBufferBinder fbo_binder(fbo_id_);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
- info->service_id(),
+ textures_[back()].info->service_id(),
0);
glFlush();
CHECK_GL_ERROR();
diff --git a/content/common/gpu/texture_image_transport_surface.h b/content/common/gpu/texture_image_transport_surface.h
index 82869e7..907bfa4 100644
--- a/content/common/gpu/texture_image_transport_surface.h
+++ b/content/common/gpu/texture_image_transport_surface.h
@@ -48,9 +48,6 @@ class TextureImageTransportSurface :
virtual void OnBuffersSwappedACK() OVERRIDE;
virtual void OnPostSubBufferACK() OVERRIDE;
virtual void OnResizeViewACK() OVERRIDE;
- virtual void OnSetFrontSurfaceIsProtected(
- bool is_protected,
- uint32 protection_state_id) OVERRIDE;
virtual void OnResize(gfx::Size size) OVERRIDE;
// GpuCommandBufferStub::DestructionObserver implementation.
@@ -77,11 +74,9 @@ class TextureImageTransportSurface :
virtual ~TextureImageTransportSurface();
void CreateBackTexture(const gfx::Size& size);
+ void ReleaseBackTexture();
void AttachBackTextureToFBO();
- void ReleaseTexture(int id);
void ReleaseParentStub();
- void AdjustFrontBufferAllocation();
- int front() const { return front_; }
int back() const { return 1 - front_; }
// The framebuffer that represents this surface (service id). Allocated lazily
@@ -102,9 +97,6 @@ class TextureImageTransportSurface :
bool backbuffer_suggested_allocation_;
bool frontbuffer_suggested_allocation_;
- bool frontbuffer_is_protected_;
- uint32 protection_state_id_;
-
scoped_ptr<ImageTransportHelper> helper_;
gfx::GLSurfaceHandle handle_;
GpuCommandBufferStub* parent_stub_;