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

Unified Diff: ui/gfx/compositor/compositor_cc.cc

Issue 8222028: Use WebKit compositor in ui::Layer (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase,fixes Created 9 years, 2 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: ui/gfx/compositor/compositor_cc.cc
diff --git a/ui/gfx/compositor/compositor_cc.cc b/ui/gfx/compositor/compositor_cc.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f9de9740997f755bbe974c6fdeaed05c31583387
--- /dev/null
+++ b/ui/gfx/compositor/compositor_cc.cc
@@ -0,0 +1,128 @@
+// Copyright (c) 2011 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 "ui/gfx/compositor/compositor_cc.h"
+
+#include "base/bind.h"
jonathan.backer 2011/10/18 15:28:26 necessary?
piman 2011/10/19 17:53:23 Gone
+#include "base/memory/ref_counted.h"
+#include "base/message_loop_proxy.h"
jonathan.backer 2011/10/18 15:28:26 necessary?
piman 2011/10/19 17:53:23 Gone.
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
+#include "ui/gfx/compositor/layer.h"
jonathan.backer 2011/10/18 15:28:26 necessary?
piman 2011/10/19 17:53:23 Just necessary for root_layer()->web_layer().
+#include "webkit/glue/webthread_impl.h"
+#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
+
+namespace {
+webkit_glue::WebThreadImpl* g_compositor_thread = NULL;
+} // anonymous namespace
+
+namespace ui {
+
+TextureCC::TextureCC() {
+}
+
+void TextureCC::SetCanvas(const SkCanvas& canvas,
+ const gfx::Point& origin,
+ const gfx::Size& overall_size) {
+}
+
+void TextureCC::Draw(const ui::TextureDrawParams& params,
+ const gfx::Rect& clip_bounds_in_texture) {
+}
+
+CompositorCC::CompositorCC(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
+ const gfx::Size& size)
+ : Compositor(delegate, size),
+ widget_(widget),
+ root_web_layer_(WebKit::WebLayer::create(this)) {
+ WebKit::WebLayerTreeView::Settings settings;
+ settings.enableCompositorThread = !!g_compositor_thread;
+ host_ = WebKit::WebLayerTreeView::create(this, root_web_layer_, settings);
+ root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
+ OnWidgetSizeChanged();
+}
+
+CompositorCC::~CompositorCC() {
+}
+
+void CompositorCC::InitializeThread() {
+ g_compositor_thread = new webkit_glue::WebThreadImpl("Browser Compositor");
+ WebKit::WebCompositor::setThread(g_compositor_thread);
+}
+
+void CompositorCC::TerminateThread() {
+ DCHECK(g_compositor_thread);
+ delete g_compositor_thread;
+ g_compositor_thread = NULL;
+}
+
+Texture* CompositorCC::CreateTexture() {
+ return new TextureCC();
+}
+
+void CompositorCC::OnNotifyStart(bool clear) {
+}
+
+void CompositorCC::OnNotifyEnd() {
+}
+
+void CompositorCC::OnWidgetSizeChanged() {
+ host_.setViewportSize(size());
+ root_web_layer_.setBounds(size());
+}
+
+void CompositorCC::OnRootLayerChanged() {
+ DCHECK(!root_layer()->web_layer().isNull());
+ root_web_layer_.removeAllChildren();
+ root_web_layer_.addChild(root_layer()->web_layer());
+}
+
+void CompositorCC::DrawTree() {
+ host_.composite();
+}
+
+void CompositorCC::Blur(const gfx::Rect& bounds) {
+}
+
+void CompositorCC::animateAndLayout(double frameBeginTime) {
+}
+
+void CompositorCC::applyScrollDelta(const WebKit::WebSize&) {
+}
+
+WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() {
+ WebKit::WebGraphicsContext3D* context =
+ new webkit::gpu::WebGraphicsContext3DInProcessImpl(widget_);
+ WebKit::WebGraphicsContext3D::Attributes attrs;
+ context->initialize(attrs, 0, true);
+ return context;
+}
+
+void CompositorCC::didRebindGraphicsContext(bool success) {
+}
+
+void CompositorCC::scheduleComposite() {
+ ScheduleDraw();
+}
+
+void CompositorCC::notifyNeedsComposite() {
+ ScheduleDraw();
+}
+
+void CompositorCC::ScheduleDraw() {
Ben Goodger (Google) 2011/10/16 22:39:51 order of functions in the .cc file should match .h
piman 2011/10/19 17:53:23 Done.
+ if (g_compositor_thread)
+ host_.composite();
+ else
+ Compositor::ScheduleDraw();
+}
+
+Compositor* Compositor::Create(CompositorDelegate* owner,
+ gfx::AcceleratedWidget widget,
+ const gfx::Size& size) {
+ return new CompositorCC(owner, widget, size);
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698