| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "cc/thread_proxy.h" | 30 #include "cc/thread_proxy.h" |
| 31 #include "cc/top_controls_manager.h" | 31 #include "cc/top_controls_manager.h" |
| 32 #include "cc/tree_synchronizer.h" | 32 #include "cc/tree_synchronizer.h" |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 static int numLayerTreeInstances; | 35 static int numLayerTreeInstances; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace cc { | 38 namespace cc { |
| 39 | 39 |
| 40 bool LayerTreeHost::s_needsFilterContext = false; | |
| 41 | |
| 42 RendererCapabilities::RendererCapabilities() | 40 RendererCapabilities::RendererCapabilities() |
| 43 : bestTextureFormat(0) | 41 : bestTextureFormat(0) |
| 44 , usingPartialSwap(false) | 42 , usingPartialSwap(false) |
| 45 , usingAcceleratedPainting(false) | 43 , usingAcceleratedPainting(false) |
| 46 , usingSetVisibility(false) | 44 , usingSetVisibility(false) |
| 47 , usingSwapCompleteCallback(false) | 45 , usingSwapCompleteCallback(false) |
| 48 , usingGpuMemoryManager(false) | 46 , usingGpuMemoryManager(false) |
| 49 , usingDiscardBackbuffer(false) | 47 , usingDiscardBackbuffer(false) |
| 50 , usingEglImage(false) | 48 , usingEglImage(false) |
| 51 , allowPartialTextureUpdates(false) | 49 , allowPartialTextureUpdates(false) |
| 50 , usingOffscreenContext3d(false) |
| 52 , maxTextureSize(0) | 51 , maxTextureSize(0) |
| 53 { | 52 { |
| 54 } | 53 } |
| 55 | 54 |
| 56 RendererCapabilities::~RendererCapabilities() | 55 RendererCapabilities::~RendererCapabilities() |
| 57 { | 56 { |
| 58 } | 57 } |
| 59 | 58 |
| 60 bool LayerTreeHost::anyLayerTreeHostInstanceExists() | 59 bool LayerTreeHost::anyLayerTreeHostInstanceExists() |
| 61 { | 60 { |
| 62 return numLayerTreeInstances > 0; | 61 return numLayerTreeInstances > 0; |
| 63 } | 62 } |
| 64 | 63 |
| 65 scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, con
st LayerTreeSettings& settings, scoped_ptr<Thread> implThread) | 64 scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, con
st LayerTreeSettings& settings, scoped_ptr<Thread> implThread) |
| 66 { | 65 { |
| 67 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings))
; | 66 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings))
; |
| 68 if (!layerTreeHost->initialize(implThread.Pass())) | 67 if (!layerTreeHost->initialize(implThread.Pass())) |
| 69 return scoped_ptr<LayerTreeHost>(); | 68 return scoped_ptr<LayerTreeHost>(); |
| 70 return layerTreeHost.Pass(); | 69 return layerTreeHost.Pass(); |
| 71 } | 70 } |
| 72 | 71 |
| 73 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
s& settings) | 72 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
s& settings) |
| 74 : m_animating(false) | 73 : m_animating(false) |
| 75 , m_needsFullTreeSync(true) | 74 , m_needsFullTreeSync(true) |
| 75 , m_needsFilterContext(false) |
| 76 , m_client(client) | 76 , m_client(client) |
| 77 , m_commitNumber(0) | 77 , m_commitNumber(0) |
| 78 , m_renderingStats() | 78 , m_renderingStats() |
| 79 , m_rendererInitialized(false) | 79 , m_rendererInitialized(false) |
| 80 , m_outputSurfaceLost(false) | 80 , m_outputSurfaceLost(false) |
| 81 , m_numFailedRecreateAttempts(0) | 81 , m_numFailedRecreateAttempts(0) |
| 82 , m_settings(settings) | 82 , m_settings(settings) |
| 83 , m_debugState(settings.initialDebugState) | 83 , m_debugState(settings.initialDebugState) |
| 84 , m_deviceScaleFactor(1) | 84 , m_deviceScaleFactor(1) |
| 85 , m_visible(true) | 85 , m_visible(true) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 { | 176 { |
| 177 TRACE_EVENT0("cc", "LayerTreeHost::recreateOutputSurface"); | 177 TRACE_EVENT0("cc", "LayerTreeHost::recreateOutputSurface"); |
| 178 DCHECK(m_outputSurfaceLost); | 178 DCHECK(m_outputSurfaceLost); |
| 179 | 179 |
| 180 if (m_proxy->recreateOutputSurface()) { | 180 if (m_proxy->recreateOutputSurface()) { |
| 181 m_client->didRecreateOutputSurface(true); | 181 m_client->didRecreateOutputSurface(true); |
| 182 m_outputSurfaceLost = false; | 182 m_outputSurfaceLost = false; |
| 183 return RecreateSucceeded; | 183 return RecreateSucceeded; |
| 184 } | 184 } |
| 185 | 185 |
| 186 m_client->willRetryRecreateOutputSurface(); |
| 187 |
| 186 // Tolerate a certain number of recreation failures to work around races | 188 // Tolerate a certain number of recreation failures to work around races |
| 187 // in the output-surface-lost machinery. | 189 // in the output-surface-lost machinery. |
| 188 m_numFailedRecreateAttempts++; | 190 m_numFailedRecreateAttempts++; |
| 189 if (m_numFailedRecreateAttempts < 5) { | 191 if (m_numFailedRecreateAttempts < 5) { |
| 190 // FIXME: The single thread does not self-schedule output surface | 192 // FIXME: The single thread does not self-schedule output surface |
| 191 // recreation. So force another recreation attempt to happen by requesti
ng | 193 // recreation. So force another recreation attempt to happen by requesti
ng |
| 192 // another commit. | 194 // another commit. |
| 193 if (!m_proxy->hasImplThread()) | 195 if (!m_proxy->hasImplThread()) |
| 194 setNeedsCommit(); | 196 setNeedsCommit(); |
| 195 return RecreateFailedButTryAgain; | 197 return RecreateFailedButTryAgain; |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 870 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 869 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 871 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 870 } | 872 } |
| 871 | 873 |
| 872 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() | 874 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() |
| 873 { | 875 { |
| 874 return m_proxy->capturePicture(); | 876 return m_proxy->capturePicture(); |
| 875 } | 877 } |
| 876 | 878 |
| 877 } // namespace cc | 879 } // namespace cc |
| OLD | NEW |