OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gfx/compositor/compositor_cc.h" |
| 6 |
| 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 10 #include "ui/gfx/compositor/layer.h" |
| 11 #include "webkit/glue/webthread_impl.h" |
| 12 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
| 13 |
| 14 namespace { |
| 15 webkit_glue::WebThreadImpl* g_compositor_thread = NULL; |
| 16 } // anonymous namespace |
| 17 |
| 18 namespace ui { |
| 19 |
| 20 TextureCC::TextureCC() { |
| 21 } |
| 22 |
| 23 void TextureCC::SetCanvas(const SkCanvas& canvas, |
| 24 const gfx::Point& origin, |
| 25 const gfx::Size& overall_size) { |
| 26 } |
| 27 |
| 28 void TextureCC::Draw(const ui::TextureDrawParams& params, |
| 29 const gfx::Rect& clip_bounds_in_texture) { |
| 30 } |
| 31 |
| 32 CompositorCC::CompositorCC(CompositorDelegate* delegate, |
| 33 gfx::AcceleratedWidget widget, |
| 34 const gfx::Size& size) |
| 35 : Compositor(delegate, size), |
| 36 widget_(widget), |
| 37 root_web_layer_(WebKit::WebLayer::create(this)) { |
| 38 WebKit::WebLayerTreeView::Settings settings; |
| 39 settings.enableCompositorThread = !!g_compositor_thread; |
| 40 host_ = WebKit::WebLayerTreeView::create(this, root_web_layer_, settings); |
| 41 root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); |
| 42 OnWidgetSizeChanged(); |
| 43 } |
| 44 |
| 45 CompositorCC::~CompositorCC() { |
| 46 } |
| 47 |
| 48 void CompositorCC::InitializeThread() { |
| 49 g_compositor_thread = new webkit_glue::WebThreadImpl("Browser Compositor"); |
| 50 WebKit::WebCompositor::setThread(g_compositor_thread); |
| 51 } |
| 52 |
| 53 void CompositorCC::TerminateThread() { |
| 54 DCHECK(g_compositor_thread); |
| 55 delete g_compositor_thread; |
| 56 g_compositor_thread = NULL; |
| 57 } |
| 58 |
| 59 Texture* CompositorCC::CreateTexture() { |
| 60 return new TextureCC(); |
| 61 } |
| 62 |
| 63 void CompositorCC::Blur(const gfx::Rect& bounds) { |
| 64 NOTIMPLEMENTED(); |
| 65 } |
| 66 |
| 67 void CompositorCC::ScheduleDraw() { |
| 68 if (g_compositor_thread) |
| 69 host_.composite(); |
| 70 else |
| 71 Compositor::ScheduleDraw(); |
| 72 } |
| 73 |
| 74 void CompositorCC::OnNotifyStart(bool clear) { |
| 75 } |
| 76 |
| 77 void CompositorCC::OnNotifyEnd() { |
| 78 } |
| 79 |
| 80 void CompositorCC::OnWidgetSizeChanged() { |
| 81 host_.setViewportSize(size()); |
| 82 root_web_layer_.setBounds(size()); |
| 83 } |
| 84 |
| 85 void CompositorCC::OnRootLayerChanged() { |
| 86 root_web_layer_.removeAllChildren(); |
| 87 root_web_layer_.addChild(root_layer()->web_layer()); |
| 88 } |
| 89 |
| 90 void CompositorCC::DrawTree() { |
| 91 host_.composite(); |
| 92 } |
| 93 |
| 94 void CompositorCC::animateAndLayout(double frameBeginTime) { |
| 95 } |
| 96 |
| 97 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { |
| 98 } |
| 99 |
| 100 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() { |
| 101 WebKit::WebGraphicsContext3D* context = |
| 102 new webkit::gpu::WebGraphicsContext3DInProcessImpl(widget_, NULL); |
| 103 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 104 context->initialize(attrs, 0, true); |
| 105 return context; |
| 106 } |
| 107 |
| 108 void CompositorCC::didRebindGraphicsContext(bool success) { |
| 109 } |
| 110 |
| 111 void CompositorCC::scheduleComposite() { |
| 112 ScheduleDraw(); |
| 113 } |
| 114 |
| 115 void CompositorCC::notifyNeedsComposite() { |
| 116 ScheduleDraw(); |
| 117 } |
| 118 |
| 119 Compositor* Compositor::Create(CompositorDelegate* owner, |
| 120 gfx::AcceleratedWidget widget, |
| 121 const gfx::Size& size) { |
| 122 return new CompositorCC(owner, widget, size); |
| 123 } |
| 124 |
| 125 } // namespace ui |
OLD | NEW |