| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/compositor/compositor_cc.h" | 5 #include "ui/gfx/compositor/compositor_cc.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "third_party/skia/include/images/SkImageEncoder.h" | 8 #include "third_party/skia/include/images/SkImageEncoder.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 command_line->HasSwitch(switches::kUIShowLayerTree); | 138 command_line->HasSwitch(switches::kUIShowLayerTree); |
| 139 #ifndef WEBCOMPOSITOR_HAS_INITIALIZE | 139 #ifndef WEBCOMPOSITOR_HAS_INITIALIZE |
| 140 settings.enableCompositorThread = !!g_compositor_thread; | 140 settings.enableCompositorThread = !!g_compositor_thread; |
| 141 #endif | 141 #endif |
| 142 host_ = WebKit::WebLayerTreeView::create(this, root_web_layer_, settings); | 142 host_ = WebKit::WebLayerTreeView::create(this, root_web_layer_, settings); |
| 143 root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); | 143 root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); |
| 144 OnWidgetSizeChanged(); | 144 OnWidgetSizeChanged(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 CompositorCC::~CompositorCC() { | 147 CompositorCC::~CompositorCC() { |
| 148 // There's a cycle between |root_web_layer_| and |host_|, which results in |
| 149 // leaking and/or crashing. Explicitly set the root layer to NULL so the cycle |
| 150 // is broken. |
| 151 host_.setRootLayer(NULL); |
| 148 } | 152 } |
| 149 | 153 |
| 150 void CompositorCC::Initialize(bool use_thread) { | 154 void CompositorCC::Initialize(bool use_thread) { |
| 151 if (use_thread) | 155 if (use_thread) |
| 152 g_compositor_thread = new webkit_glue::WebThreadImpl("Browser Compositor"); | 156 g_compositor_thread = new webkit_glue::WebThreadImpl("Browser Compositor"); |
| 153 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE | 157 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE |
| 154 WebKit::WebCompositor::initialize(g_compositor_thread); | 158 WebKit::WebCompositor::initialize(g_compositor_thread); |
| 155 #else | 159 #else |
| 156 if (use_thread) | 160 if (use_thread) |
| 157 WebKit::WebCompositor::setThread(g_compositor_thread); | 161 WebKit::WebCompositor::setThread(g_compositor_thread); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ScheduleDraw(); | 279 ScheduleDraw(); |
| 276 } | 280 } |
| 277 | 281 |
| 278 Compositor* Compositor::Create(CompositorDelegate* owner, | 282 Compositor* Compositor::Create(CompositorDelegate* owner, |
| 279 gfx::AcceleratedWidget widget, | 283 gfx::AcceleratedWidget widget, |
| 280 const gfx::Size& size) { | 284 const gfx::Size& size) { |
| 281 return new CompositorCC(owner, widget, size); | 285 return new CompositorCC(owner, widget, size); |
| 282 } | 286 } |
| 283 | 287 |
| 284 } // namespace ui | 288 } // namespace ui |
| OLD | NEW |