Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e9366b5dc685f1076087302fa85639bc313eecfa |
| --- /dev/null |
| +++ b/content/browser/renderer_host/compositor_impl_android.cc |
| @@ -0,0 +1,118 @@ |
| +// 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/compositor_impl_android.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/logging.h" |
| +#include "base/memory/singleton.h" |
| +#include "content/browser/android/graphics_context.h" |
| +#include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| +#include "content/common/gpu/client/gpu_channel_host.h" |
| +#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| +#include "content/common/gpu/gpu_process_launch_causes.h" |
| +#include "content/public/browser/render_widget_host_view.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h" |
| + |
| +namespace content { |
| + |
| +// static |
| +Compositor* Compositor::GetInstance() { |
| + return CompositorImpl::GetInstance(); |
| +} |
| + |
| +// static |
| +CompositorImpl* CompositorImpl::GetInstance() { |
| + return Singleton<CompositorImpl>::get(); |
|
aelias_OOO_until_Jul13
2012/08/17 04:35:42
Singletons are usually better avoided. For exampl
no sievers
2012/08/17 16:23:13
I could also add a static Initialize() function.
F
|
| +} |
| + |
| +CompositorImpl::CompositorImpl() |
| + : root_layer_(WebKit::WebLayer::create()) { |
| +} |
| + |
| +CompositorImpl::~CompositorImpl() { |
| +} |
| + |
| +void CompositorImpl::SurfaceUpdated(const SurfacePresentedCallback& callback) { |
| + host_.composite(); |
| + uint32 sync_point = context_->InsertSyncPoint(); |
| + callback.Run(sync_point); |
| +} |
| + |
| +void CompositorImpl::SetRootLayer(const WebKit::WebLayer& root_layer) { |
| + root_layer_.removeAllChildren(); |
| + root_layer_.addChild(root_layer); |
| +} |
| + |
| +void CompositorImpl::SetWindowSurface(ANativeWindow* window) { |
| + if (window) { |
| + context_.reset(GraphicsContext::CreateForUI(window)); |
| + WebKit::WebCompositor::initialize(NULL); |
| + WebKit::WebLayerTreeView::Settings settings; |
| + settings.refreshRate = 60.0; |
| + host_.initialize(this, root_layer_, settings); |
| + host_.setVisible(true); |
| + host_.setSurfaceReady(); |
| + } else { |
| + context_.reset(NULL); |
| + } |
| +} |
| + |
| +void CompositorImpl::SetWindowBounds(const gfx::Size& size) { |
| + if (size_ == size) |
| + return; |
| + |
| + size_ = size; |
| + host_.setViewportSize(size); |
| + root_layer_.setBounds(size); |
| +} |
| + |
| +void CompositorImpl::updateAnimations(double frameBeginTime) { |
| +} |
| + |
| +void CompositorImpl::layout() { |
| +} |
| + |
| +void CompositorImpl::applyScrollAndScale(const WebKit::WebSize& scrollDelta, |
| + float scaleFactor) { |
| +} |
| + |
| +WebKit::WebGraphicsContext3D* CompositorImpl::createContext3D() { |
| + WebKit::WebGraphicsContext3D::Attributes attrs; |
| + attrs.shareResources = true; |
| + GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
| + GURL url("chrome://gpu/Compositor::createContext3D"); |
| + base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; |
| + scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| + new WebGraphicsContext3DCommandBufferImpl( |
| + context_->GetSurfaceID(), |
| + url, |
| + factory, |
| + swap_client)); |
| + if (!context->Initialize( |
| + attrs, |
| + false, |
| + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { |
| + return NULL; |
| + } |
| + |
| + return context.release(); |
| +} |
| + |
| +void CompositorImpl::didRebindGraphicsContext(bool success) { |
| +} |
| + |
| +void CompositorImpl::didCommit() { |
| +} |
| + |
| +void CompositorImpl::didCommitAndDrawFrame() { |
| +} |
| + |
| +void CompositorImpl::didCompleteSwapBuffers() { |
| +} |
| + |
| +void CompositorImpl::scheduleComposite() { |
| +} |
| + |
| +} // namespace content |