diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-29 21:22:13 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-29 21:22:13 +0000 |
commit | ab6627371cb52d504cdc0bb33ca6ead8a7f8ac70 (patch) | |
tree | 61d64d4d0d4fba470b9d3b0a62f0f3e1a8e986d7 /content | |
parent | f65d3ac3652849f5645ad8982ce5639752439140 (diff) | |
download | chromium_src-ab6627371cb52d504cdc0bb33ca6ead8a7f8ac70.zip chromium_src-ab6627371cb52d504cdc0bb33ca6ead8a7f8ac70.tar.gz chromium_src-ab6627371cb52d504cdc0bb33ca6ead8a7f8ac70.tar.bz2 |
Merge Compositor and CompositorCC
This also removes a few unused calls.
BUG=None
TEST=compiles, tests pass
Review URL: http://codereview.chromium.org/9297041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
5 files changed, 85 insertions, 108 deletions
diff --git a/content/browser/renderer_host/accelerated_surface_container_linux.cc b/content/browser/renderer_host/accelerated_surface_container_linux.cc new file mode 100644 index 0000000..90ce064 --- /dev/null +++ b/content/browser/renderer_host/accelerated_surface_container_linux.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/renderer_host/accelerated_surface_container_linux.h" + +#include "base/memory/scoped_ptr.h" +#include "content/browser/renderer_host/image_transport_client.h" +#include "ui/gfx/gl/gl_bindings.h" +#include "ui/gfx/gl/scoped_make_current.h" +#include "ui/gfx/rect.h" +#include "ui/gfx/transform.h" + +AcceleratedSurfaceContainerLinux::AcceleratedSurfaceContainerLinux( + const gfx::Size& size) + : acquired_(false) { + size_ = size; +} + +AcceleratedSurfaceContainerLinux::~AcceleratedSurfaceContainerLinux() { + if (texture_id_) { + ui::SharedResources* instance = ui::SharedResources::GetInstance(); + DCHECK(instance); + scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); + glDeleteTextures(1, &texture_id_); + } + + if (image_transport_client_.get()) + image_transport_client_->Release(); +} + +bool AcceleratedSurfaceContainerLinux::Initialize(uint64* surface_handle) { + ui::SharedResources* instance = ui::SharedResources::GetInstance(); + DCHECK(instance); + image_transport_client_.reset( + ImageTransportClient::Create(instance, size_)); + if (!image_transport_client_.get()) + return false; + + texture_id_ = image_transport_client_->Initialize(surface_handle); + if (!texture_id_) { + image_transport_client_.reset(); + return false; + } + flipped_ = image_transport_client_->Flipped(); + return true; +} + +// Texture implementation +void AcceleratedSurfaceContainerLinux::Update() { + ui::SharedResources* instance = ui::SharedResources::GetInstance(); + DCHECK(instance); + scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); + if (acquired_) + image_transport_client_->Release(); + else + acquired_ = true; + image_transport_client_->Acquire(); +} + +TransportDIB::Handle AcceleratedSurfaceContainerLinux::Handle() const { + return image_transport_client_->Handle(); +} diff --git a/content/browser/renderer_host/accelerated_surface_container_linux.h b/content/browser/renderer_host/accelerated_surface_container_linux.h index 3083fe3..129644a 100644 --- a/content/browser/renderer_host/accelerated_surface_container_linux.h +++ b/content/browser/renderer_host/accelerated_surface_container_linux.h @@ -10,30 +10,32 @@ #include "ui/gfx/compositor/compositor.h" #include "ui/gfx/surface/transport_dib.h" +class ImageTransportClient; + // Helper class for storing image data from the GPU process renderered // on behalf of the RWHVV. It assumes that GL context that will display // the image data is current when an instance of this object is created // or destroyed. -class AcceleratedSurfaceContainerLinux { +class AcceleratedSurfaceContainerLinux : public ui::Texture { public: - virtual ~AcceleratedSurfaceContainerLinux() { } - virtual void AddRef() = 0; - virtual void Release() = 0; + explicit AcceleratedSurfaceContainerLinux(const gfx::Size& size); + virtual ~AcceleratedSurfaceContainerLinux(); // Initialize the surface container, and returns an ID for it. // The |surface_handle| given to this function may be modified, and the // modified value should be used to identify the object. - virtual bool Initialize(uint64* surface_handle) = 0; + bool Initialize(uint64* surface_handle); // Some implementations of this class use shared memory, this is the handle // to the shared buffer, which is part of the surface container. - virtual TransportDIB::Handle Handle() const = 0; - - virtual ui::Texture* GetTexture() = 0; + TransportDIB::Handle Handle() const; - virtual const gfx::Size& GetSize() = 0; + void Update(); - static AcceleratedSurfaceContainerLinux* Create(const gfx::Size& size); + private: + scoped_ptr<ImageTransportClient> image_transport_client_; + bool acquired_; + DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerLinux); }; #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_SURFACE_CONTAINER_LINUX_H_ diff --git a/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc b/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc deleted file mode 100644 index e6936de..0000000 --- a/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/renderer_host/accelerated_surface_container_linux.h" - -#include "base/memory/scoped_ptr.h" -#include "content/browser/renderer_host/image_transport_client.h" -#include "ui/gfx/compositor/compositor_cc.h" -#include "ui/gfx/gl/gl_bindings.h" -#include "ui/gfx/gl/scoped_make_current.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/transform.h" - -namespace { - -class AcceleratedSurfaceContainerLinuxCC - : public AcceleratedSurfaceContainerLinux, public ui::TextureCC { - public: - explicit AcceleratedSurfaceContainerLinuxCC(const gfx::Size& size) - : acquired_(false) { - size_ = size; - } - - virtual ~AcceleratedSurfaceContainerLinuxCC() { - if (texture_id_) { - ui::SharedResourcesCC* instance = ui::SharedResourcesCC::GetInstance(); - DCHECK(instance); - scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); - glDeleteTextures(1, &texture_id_); - } - - if (image_transport_client_.get()) - image_transport_client_->Release(); - } - - virtual void AddRef() { ui::TextureCC::AddRef(); } - virtual void Release() { ui::TextureCC::Release(); } - - virtual bool Initialize(uint64* surface_handle) OVERRIDE { - ui::SharedResourcesCC* instance = ui::SharedResourcesCC::GetInstance(); - DCHECK(instance); - image_transport_client_.reset( - ImageTransportClient::Create(instance, size_)); - if (!image_transport_client_.get()) - return false; - - texture_id_ = image_transport_client_->Initialize(surface_handle); - if (!texture_id_) { - image_transport_client_.reset(); - return false; - } - flipped_ = image_transport_client_->Flipped(); - return true; - } - - virtual const gfx::Size& GetSize() { - return ui::TextureCC::size(); - } - - // TextureCC implementation - virtual void Update() OVERRIDE { - ui::SharedResourcesCC* instance = ui::SharedResourcesCC::GetInstance(); - DCHECK(instance); - scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); - if (acquired_) - image_transport_client_->Release(); - else - acquired_ = true; - image_transport_client_->Acquire(); - } - - virtual TransportDIB::Handle Handle() const { - return image_transport_client_->Handle(); - } - - virtual ui::Texture* GetTexture() { return this; } - - private: - scoped_ptr<ImageTransportClient> image_transport_client_; - bool acquired_; - DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerLinuxCC); -}; - -} // namespace - -// static -AcceleratedSurfaceContainerLinux* -AcceleratedSurfaceContainerLinux::Create(const gfx::Size& size) { - return new AcceleratedSurfaceContainerLinuxCC(size); -} diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index ba5da59..b77fefa 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -352,8 +352,11 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() { #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) if (current_surface_ != gfx::kNullPluginWindow && host_->is_accelerated_compositing_active()) { - window_->SetExternalTexture( - accelerated_surface_containers_[current_surface_]->GetTexture()); + AcceleratedSurfaceContainerLinux* container = + accelerated_surface_containers_[current_surface_]; + if (container) + container->Update(); + window_->SetExternalTexture(container); glFlush(); } else { window_->SetExternalTexture(NULL); @@ -374,7 +377,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); } else { gfx::Size surface_size = - accelerated_surface_containers_[params.surface_handle]->GetSize(); + accelerated_surface_containers_[params.surface_handle]->size(); window_->SchedulePaintInRect(gfx::Rect(surface_size)); // Add sending an ACK to the list of things to do OnCompositingEnded @@ -403,7 +406,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); } else { gfx::Size surface_size = - accelerated_surface_containers_[params.surface_handle]->GetSize(); + accelerated_surface_containers_[params.surface_handle]->size(); // Co-ordinates come in OpenGL co-ordinate space. // We need to convert to layer space. @@ -433,7 +436,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceNew( uint64* surface_handle, TransportDIB::Handle* shm_handle) { scoped_refptr<AcceleratedSurfaceContainerLinux> surface( - AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); + new AcceleratedSurfaceContainerLinux(gfx::Size(width, height))); if (!surface->Initialize(surface_handle)) { LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; return; diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 1c23638..623c7e9 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -399,7 +399,7 @@ 'browser/quota_permission_context.h', 'browser/renderer_host/accelerated_plugin_view_mac.h', 'browser/renderer_host/accelerated_plugin_view_mac.mm', - 'browser/renderer_host/accelerated_surface_container_linux_cc.cc', + 'browser/renderer_host/accelerated_surface_container_linux.cc', 'browser/renderer_host/accelerated_surface_container_linux.h', 'browser/renderer_host/accelerated_surface_container_mac.cc', 'browser/renderer_host/accelerated_surface_container_mac.h', @@ -823,7 +823,7 @@ ], }, { 'sources/': [ - ['exclude', '^browser/renderer_host/accelerated_surface_container_linux_cc.cc'], + ['exclude', '^browser/renderer_host/accelerated_surface_container_linux.cc'], ['exclude', '^browser/renderer_host/accelerated_surface_container_linux.h'], ['exclude', '^browser/renderer_host/image_transport_client.cc'], ['exclude', '^browser/renderer_host/image_transport_client.h'], |