Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 10828356: Very basic Android browser-side compositing support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments, make compositor non-singleton Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698