 Chromium Code Reviews
 Chromium Code Reviews Issue 11428091:
  Migrate the Android compositor to cc::Layer classes.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 11428091:
  Migrate the Android compositor to cc::Layer classes.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: content/browser/renderer_host/compositor_impl_android.cc | 
| diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc | 
| index e72ee85a4f8bfeca5d67eee2762e548bdf9c0b39..d08f195e959a472fd0be6c78266ee0208d025f38 100644 | 
| --- a/content/browser/renderer_host/compositor_impl_android.cc | 
| +++ b/content/browser/renderer_host/compositor_impl_android.cc | 
| @@ -11,6 +11,10 @@ | 
| #include "base/command_line.h" | 
| #include "base/lazy_instance.h" | 
| #include "base/logging.h" | 
| +#include "cc/input_handler.h" | 
| +#include "cc/layer.h" | 
| +#include "cc/layer_tree_host.h" | 
| +#include "cc/thread_impl.h" | 
| #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 
| #include "content/browser/gpu/gpu_surface_tracker.h" | 
| #include "content/browser/renderer_host/image_transport_factory_android.h" | 
| @@ -23,14 +27,10 @@ | 
| #include "third_party/khronos/GLES2/gl2ext.h" | 
| #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h" | 
| #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" | 
| -#include "third_party/WebKit/Source/Platform/chromium/public/WebSolidColorLayer.h" | 
| #include "ui/gfx/android/java_bitmap.h" | 
| -#include "webkit/compositor_bindings/web_compositor_support_impl.h" | 
| #include "webkit/glue/webthread_impl.h" | 
| #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 
| -using webkit::WebCompositorSupportImpl; | 
| - | 
| namespace gfx { | 
| class JavaBitmap; | 
| } | 
| @@ -38,9 +38,7 @@ class JavaBitmap; | 
| namespace { | 
| static bool g_initialized = false; | 
| -static base::LazyInstance<WebCompositorSupportImpl> g_compositor_support = | 
| - LAZY_INSTANCE_INITIALIZER; | 
| -static WebKit::WebThread* g_impl_thread = NULL; | 
| +static webkit_glue::WebThreadImpl* g_impl_thread = NULL; | 
| static bool g_use_direct_gl = false; | 
| // Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface. | 
| @@ -97,27 +95,27 @@ Compositor* Compositor::Create(Client* client) { | 
| // static | 
| void Compositor::Initialize() { | 
| DCHECK(!CompositorImpl::IsInitialized()); | 
| - g_compositor_support.Get().initialize(g_impl_thread); | 
| g_initialized = true; | 
| } | 
| // static | 
| void Compositor::InitializeWithFlags(uint32 flags) { | 
| g_use_direct_gl = flags & DIRECT_CONTEXT_ON_DRAW_THREAD; | 
| - if (flags & ENABLE_COMPOSITOR_THREAD) | 
| + if (flags & ENABLE_COMPOSITOR_THREAD) { | 
| + TRACE_EVENT_INSTANT0("test_gpu", "ThreadedCompositingInitialization"); | 
| g_impl_thread = new webkit_glue::WebThreadImpl("Browser Compositor"); | 
| + } | 
| Compositor::Initialize(); | 
| } | 
| // static | 
| -WebCompositorSupportImpl* CompositorImpl::CompositorSupport() { | 
| - DCHECK(g_initialized); | 
| - return g_compositor_support.Pointer(); | 
| +bool CompositorImpl::IsInitialized() { | 
| + return g_initialized; | 
| } | 
| // static | 
| -bool CompositorImpl::IsInitialized() { | 
| - return g_initialized; | 
| +bool CompositorImpl::IsThreadingEnabled() { | 
| + return g_impl_thread; | 
| } | 
| // static | 
| @@ -126,12 +124,12 @@ bool CompositorImpl::UsesDirectGL() { | 
| } | 
| CompositorImpl::CompositorImpl(Compositor::Client* client) | 
| - : window_(NULL), | 
| + : root_layer_(cc::Layer::create()), | 
| + window_(NULL), | 
| surface_id_(0), | 
| client_(client), | 
| weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 
| DCHECK(client); | 
| - root_layer_.reset(g_compositor_support.Get().createLayer()); | 
| } | 
| CompositorImpl::~CompositorImpl() { | 
| @@ -142,7 +140,7 @@ void CompositorImpl::Composite() { | 
| host_->composite(); | 
| } | 
| -void CompositorImpl::SetRootLayer(WebKit::WebLayer* root_layer) { | 
| +void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { | 
| root_layer_->removeAllChildren(); | 
| root_layer_->addChild(root_layer); | 
| } | 
| @@ -173,13 +171,20 @@ void CompositorImpl::SetVisible(bool visible) { | 
| if (!visible) { | 
| host_.reset(); | 
| } else if (!host_.get()) { | 
| - WebKit::WebLayerTreeView::Settings settings; | 
| + cc::LayerTreeSettings settings; | 
| settings.refreshRate = 60.0; | 
| - host_.reset(g_compositor_support.Get().createLayerTreeView( | 
| - this, *root_layer_, settings)); | 
| + | 
| + scoped_ptr<cc::Thread> impl_thread; | 
| + if (g_impl_thread) | 
| + impl_thread = cc::ThreadImpl::createForDifferentThread( | 
| + g_impl_thread->message_loop()->message_loop_proxy()); | 
| + | 
| + host_ = cc::LayerTreeHost::create(this, settings, impl_thread.Pass()); | 
| + host_->setRootLayer(root_layer_); | 
| + | 
| host_->setVisible(true); | 
| host_->setSurfaceReady(); | 
| - host_->setViewportSize(size_); | 
| + host_->setViewportSize(size_, size_); | 
| } | 
| } | 
| @@ -189,7 +194,7 @@ void CompositorImpl::SetWindowBounds(const gfx::Size& size) { | 
| size_ = size; | 
| if (host_) | 
| - host_->setViewportSize(size); | 
| + host_->setViewportSize(size, size); | 
| root_layer_->setBounds(size); | 
| } | 
| @@ -262,17 +267,18 @@ void CompositorImpl::CopyTextureToBitmap(WebKit::WebGLId texture_id, | 
| static_cast<unsigned char*> (bitmap.pixels())); | 
| } | 
| -void CompositorImpl::updateAnimations(double frameBeginTime) { | 
| +void CompositorImpl::animate(double monotonicFrameBeginTime) { | 
| } | 
| void CompositorImpl::layout() { | 
| } | 
| -void CompositorImpl::applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 
| - float scaleFactor) { | 
| +void CompositorImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, | 
| + float pageScale) { | 
| } | 
| -WebKit::WebCompositorOutputSurface* CompositorImpl::createOutputSurface() { | 
| +scoped_ptr<WebKit::WebCompositorOutputSurface> | 
| + CompositorImpl::createOutputSurface() { | 
| if (g_use_direct_gl) { | 
| WebKit::WebGraphicsContext3D::Attributes attrs; | 
| attrs.shareResources = false; | 
| @@ -282,7 +288,8 @@ WebKit::WebCompositorOutputSurface* CompositorImpl::createOutputSurface() { | 
| attrs, | 
| window_, | 
| NULL)); | 
| - return new WebGraphicsContextToOutputSurfaceAdapter(context.release()); | 
| + return scoped_ptr<WebKit::WebCompositorOutputSurface>( | 
| + new WebGraphicsContextToOutputSurfaceAdapter(context.release())); | 
| } else { | 
| DCHECK(window_ && surface_id_); | 
| WebKit::WebGraphicsContext3D::Attributes attrs; | 
| @@ -300,12 +307,18 @@ WebKit::WebCompositorOutputSurface* CompositorImpl::createOutputSurface() { | 
| false, | 
| CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { | 
| LOG(ERROR) << "Failed to create 3D context for compositor."; | 
| - return NULL; | 
| + return scoped_ptr<WebKit::WebCompositorOutputSurface>(); | 
| } | 
| - return new WebGraphicsContextToOutputSurfaceAdapter(context.release()); | 
| + return scoped_ptr<WebKit::WebCompositorOutputSurface>( | 
| + new WebGraphicsContextToOutputSurfaceAdapter(context.release())); | 
| } | 
| } | 
| +scoped_ptr<cc::InputHandler> CompositorImpl::createInputHandler() { | 
| + scoped_ptr<cc::InputHandler> ret; | 
| + return ret.Pass(); | 
| 
joth
2012/11/29 21:19:38
wrong indent
I think just "return scoped_ptr<cc::
 
Leandro GraciĆ” Gil
2012/11/30 12:11:11
Done.
 | 
| +} | 
| + | 
| void CompositorImpl::didRecreateOutputSurface(bool success) { | 
| } |