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..5dddf5b96ec451a91e1cacdd2b8c10ed363691b1 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/compositor_impl_android.cc |
| @@ -0,0 +1,112 @@ |
| +// 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 "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 "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h" |
| + |
| +namespace content { |
| + |
| +// static |
| +Compositor* Compositor::Create() { |
| + return new CompositorImpl(); |
| +} |
| + |
| +CompositorImpl::CompositorImpl() |
| + : root_layer_(WebKit::WebLayer::create()) { |
| +} |
| + |
| +CompositorImpl::~CompositorImpl() { |
| +} |
| + |
| +void CompositorImpl::OnSurfaceUpdated( |
| + const SurfacePresentedCallback& callback) { |
| + host_.composite(); |
| + uint32 sync_point = context_->InsertSyncPoint(); |
| + callback.Run(sync_point); |
| +} |
| + |
| +void CompositorImpl::SetRootLayer(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); |
|
klobag.chromium
2012/08/28 00:12:07
If SurfaceView is shown and hidden and shown again
no sievers
2012/08/29 02:30:50
Done. Added a static Compositor::Initialize() func
|
| + WebKit::WebLayerTreeView::Settings settings; |
| + settings.refreshRate = 60.0; |
| + host_.initialize(this, *root_layer_, settings); |
| + host_.setVisible(true); |
| + host_.setSurfaceReady(); |
| + } else { |
| + context_.reset(NULL); |
|
klobag.chromium
2012/08/28 00:12:07
Should you reset size_ as you use it to compare in
no sievers
2012/08/29 02:30:50
Done.
|
| + } |
| +} |
| + |
| +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; |
|
klobag.chromium
2012/08/28 00:12:07
Should you check context_ for null first as it may
no sievers
2012/08/29 02:30:50
Done.
|
| + 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 |