diff options
author | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-15 21:45:52 +0000 |
---|---|---|
committer | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-15 21:45:52 +0000 |
commit | f35e232a94af088f5a1a231f2489a5b06460bffe (patch) | |
tree | 124388157fbe8e64db6181a9b5467a3ca3fc8be0 /content | |
parent | 3ff3a45baf225760a1ceab36868e333010f555ee (diff) | |
download | chromium_src-f35e232a94af088f5a1a231f2489a5b06460bffe.zip chromium_src-f35e232a94af088f5a1a231f2489a5b06460bffe.tar.gz chromium_src-f35e232a94af088f5a1a231f2489a5b06460bffe.tar.bz2 |
[Android WebView] Tie together Chrome's browser compositor with the Android View system.
This patch introduces a new feature to the compositor:
- A setting to enable cleaning the framebuffer, disabled by default. This prevents destroying data below us when rendering non-rectangular views (e.g. during a rotation).
A second required feature will be added by a later patch:
- A device scissor rect that intersects any scissor calculation. Used to ensure we never render outside where the Android View System tells us.
There are also some issues with the Android View side regarding the restoration of the GL state. This patch introduces a temporary workaround by reading and manually restoring the state changed by the compositor. This will go out as soon as the problem is fixed in the Android side.
BUG=161409,154180
Review URL: https://chromiumcodereview.appspot.com/11316310
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/compositor_impl_android.cc | 13 | ||||
-rw-r--r-- | content/browser/renderer_host/compositor_impl_android.h | 2 | ||||
-rw-r--r-- | content/public/browser/android/compositor.h | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 1d6bd2f..a4b9534 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -123,6 +123,7 @@ bool CompositorImpl::UsesDirectGL() { CompositorImpl::CompositorImpl(Compositor::Client* client) : root_layer_(cc::Layer::create()), + has_transparent_background_(false), window_(NULL), surface_id_(0), client_(client), @@ -172,6 +173,11 @@ void CompositorImpl::SetVisible(bool visible) { cc::LayerTreeSettings settings; settings.refreshRate = 60.0; + // Do not clear the framebuffer when rendering into external GL contexts + // like Android View System's. + if (UsesDirectGL()) + settings.shouldClearRootRenderPass = false; + scoped_ptr<cc::Thread> impl_thread; if (g_impl_thread) impl_thread = cc::ThreadImpl::createForDifferentThread( @@ -183,6 +189,7 @@ void CompositorImpl::SetVisible(bool visible) { host_->setVisible(true); host_->setSurfaceReady(); host_->setViewportSize(size_, size_); + host_->setHasTransparentBackground(has_transparent_background_); } } @@ -196,6 +203,12 @@ void CompositorImpl::SetWindowBounds(const gfx::Size& size) { root_layer_->setBounds(size); } +void CompositorImpl::SetHasTransparentBackground(bool flag) { + has_transparent_background_ = flag; + if (host_.get()) + host_->setHasTransparentBackground(flag); +} + bool CompositorImpl::CompositeAndReadback(void *pixels, const gfx::Rect& rect) { if (host_.get()) return host_->compositeAndReadback(pixels, rect); diff --git a/content/browser/renderer_host/compositor_impl_android.h b/content/browser/renderer_host/compositor_impl_android.h index 1514fcf51..9ce37a4 100644 --- a/content/browser/renderer_host/compositor_impl_android.h +++ b/content/browser/renderer_host/compositor_impl_android.h @@ -48,6 +48,7 @@ class CONTENT_EXPORT CompositorImpl virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; virtual void SetVisible(bool visible) OVERRIDE; virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; + virtual void SetHasTransparentBackground(bool flag) OVERRIDE; virtual bool CompositeAndReadback( void *pixels, const gfx::Rect& rect) OVERRIDE; virtual void Composite() OVERRIDE; @@ -89,6 +90,7 @@ class CONTENT_EXPORT CompositorImpl scoped_ptr<cc::LayerTreeHost> host_; gfx::Size size_; + bool has_transparent_background_; ANativeWindow* window_; int surface_id_; diff --git a/content/public/browser/android/compositor.h b/content/public/browser/android/compositor.h index bca7fe7..d0f98c2 100644 --- a/content/public/browser/android/compositor.h +++ b/content/public/browser/android/compositor.h @@ -71,6 +71,9 @@ class CONTENT_EXPORT Compositor { // Set the output surface handle which the compositor renders into. virtual void SetWindowSurface(ANativeWindow* window) = 0; + // Tells the view tree to assume a transparent background when rendering. + virtual void SetHasTransparentBackground(bool flag) = 0; + // Attempts to composite and read back the result into the provided buffer. // The buffer must be at least window width * height * 4 (RGBA) bytes large. // The buffer is not modified if false is returned. |