diff options
-rw-r--r-- | cc/delegated_renderer_layer_impl_unittest.cc | 1 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.cc | 25 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.h | 17 | ||||
-rw-r--r-- | cc/layer_tree_host_impl_unittest.cc | 1 | ||||
-rw-r--r-- | cc/picture_layer_impl.cc | 3 | ||||
-rw-r--r-- | cc/single_thread_proxy.cc | 8 | ||||
-rw-r--r-- | cc/single_thread_proxy.h | 1 | ||||
-rw-r--r-- | cc/thread_proxy.cc | 17 | ||||
-rw-r--r-- | cc/thread_proxy.h | 3 | ||||
-rw-r--r-- | cc/tile_manager.h | 3 | ||||
-rw-r--r-- | cc/tile_priority.h | 7 |
11 files changed, 76 insertions, 10 deletions
diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc index eb8a5dd..4fb4864 100644 --- a/cc/delegated_renderer_layer_impl_unittest.cc +++ b/cc/delegated_renderer_layer_impl_unittest.cc @@ -50,6 +50,7 @@ public: virtual void onCanDrawStateChanged(bool) OVERRIDE { } virtual void setNeedsRedrawOnImplThread() OVERRIDE { } virtual void setNeedsCommitOnImplThread() OVERRIDE { } + virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) OVERRIDE { } virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return true; } virtual void sendManagedMemoryStats() OVERRIDE { } diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index e8ff61f..48bc1fb 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -291,6 +291,12 @@ void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallCl animateScrollbars(monotonicTime); } +void LayerTreeHostImpl::manageTiles() +{ + DCHECK(m_tileManager); + m_tileManager->ManageTiles(); +} + void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) { if (!m_rootScrollLayerImpl) @@ -755,6 +761,15 @@ void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po m_client->onCanDrawStateChanged(canDraw()); } m_client->sendManagedMemoryStats(); + + if (m_tileManager) { + // TODO(nduca): Pass something useful into the memory manager. + LOG(INFO) << "Setting up initial tile manager policy"; + GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState()); + new_state.memory_limit_in_bytes = PrioritizedResourceManager::defaultMemoryAllocationLimit(); + new_state.memory_limit_policy = ALLOW_ANYTHING; + m_tileManager->SetGlobalState(new_state); + } } bool LayerTreeHostImpl::hasImplThread() const @@ -762,6 +777,12 @@ bool LayerTreeHostImpl::hasImplThread() const return m_proxy->hasImplThread(); } +void LayerTreeHostImpl::ScheduleManageTiles() +{ + if (m_client) + m_client->setNeedsManageTilesOnImplThread(); +} + void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) { if (m_managedMemoryPolicy == policy) @@ -968,6 +989,7 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<GraphicsContext> context) } // Note: order is important here. m_renderer.reset(); + m_tileManager.reset(); m_resourceProvider.reset(); m_context.reset(); @@ -978,6 +1000,9 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<GraphicsContext> context) if (!resourceProvider) return false; + if (m_settings.implSidePainting) + m_tileManager.reset(new TileManager(this, resourceProvider.get())); + if (context->context3D()) m_renderer = GLRenderer::create(this, resourceProvider.get()); else if (context->softwareDevice()) diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h index ee8ac98..736090d 100644 --- a/cc/layer_tree_host_impl.h +++ b/cc/layer_tree_host_impl.h @@ -15,6 +15,7 @@ #include "cc/render_pass.h" #include "cc/render_pass_sink.h" #include "cc/renderer.h" +#include "cc/tile_manager.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/rect.h" #include <public/WebCompositorOutputSurfaceClient.h> @@ -33,13 +34,6 @@ class ResourceProvider; struct RendererCapabilities; struct RenderingStats; -enum WhichTree { - // Note: these must be 0 and 1 because we index with them in various places, - // e.g. in Tile::priority_. - ACTIVE_TREE = 0, - PENDING_TREE = 1 -}; - // LayerTreeHost->Proxy callback interface. class LayerTreeHostImplClient { public: @@ -49,6 +43,7 @@ public: virtual void onCanDrawStateChanged(bool canDraw) = 0; virtual void setNeedsRedrawOnImplThread() = 0; virtual void setNeedsCommitOnImplThread() = 0; + virtual void setNeedsManageTilesOnImplThread() = 0; virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) = 0; // Returns true if resources were deleted by this call. virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) = 0; @@ -117,6 +112,7 @@ private: // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering state class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, public RendererClient, + public TileManagerClient, public NON_EXPORTED_BASE(WebKit::WebCompositorOutputSurfaceClient) { typedef std::vector<LayerImpl*> LayerList; @@ -155,6 +151,8 @@ public: virtual void commitComplete(); virtual void animate(base::TimeTicks monotonicTime, base::Time wallClockTime); + void manageTiles(); + // Returns false if problems occured preparing the frame, and we should try // to avoid displaying the frame. If prepareToDraw is called, // didDrawAllLayers must also be called, regardless of whether drawLayers is @@ -174,6 +172,9 @@ public: virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; virtual bool hasImplThread() const OVERRIDE; + // TileManagerClient implementation. + virtual void ScheduleManageTiles() OVERRIDE; + // WebCompositorOutputSurfaceClient implementation. virtual void onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds) OVERRIDE; @@ -188,6 +189,7 @@ public: bool initializeRenderer(scoped_ptr<GraphicsContext>); bool isContextLost(); + TileManager* tileManager() { return m_tileManager.get(); } Renderer* renderer() { return m_renderer.get(); } const RendererCapabilities& rendererCapabilities() const; @@ -330,6 +332,7 @@ private: scoped_ptr<GraphicsContext> m_context; scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<Renderer> m_renderer; + scoped_ptr<TileManager> m_tileManager; scoped_ptr<LayerImpl> m_rootLayerImpl; LayerImpl* m_rootScrollLayerImpl; LayerImpl* m_currentlyScrollingLayerImpl; diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index aa556f6..a85ff1d 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -96,6 +96,7 @@ public: virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawStateChangedCalled = true; } virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = true; } virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; } + virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) OVERRIDE { } virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } virtual void sendManagedMemoryStats() OVERRIDE { } diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc index 6155ed0..ab23a660 100644 --- a/cc/picture_layer_impl.cc +++ b/cc/picture_layer_impl.cc @@ -82,8 +82,7 @@ void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, gfx::Rect rect) { - // TODO(nduca): where does this come from? - TileManager* tile_manager = NULL; + TileManager* tile_manager = layerTreeHostImpl()->tileManager(); return make_scoped_refptr(new Tile( tile_manager, diff --git a/cc/single_thread_proxy.cc b/cc/single_thread_proxy.cc index a91738f..7e53375 100644 --- a/cc/single_thread_proxy.cc +++ b/cc/single_thread_proxy.cc @@ -275,6 +275,11 @@ void SingleThreadProxy::setNeedsCommitOnImplThread() m_layerTreeHost->scheduleComposite(); } +void SingleThreadProxy::setNeedsManageTilesOnImplThread() +{ + m_layerTreeHost->scheduleComposite(); +} + void SingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector> events, base::Time wallClockTime) { DCHECK(Proxy::isImplThread()); @@ -369,6 +374,9 @@ bool SingleThreadProxy::doComposite() m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); + if (m_layerTreeHostImpl->settings().implSidePainting) + m_layerTreeHostImpl->manageTiles(); + // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only // be used when such a frame is possible. Since drawLayers() depends on the result of // prepareToDraw(), it is guarded on canDraw() as well. diff --git a/cc/single_thread_proxy.h b/cc/single_thread_proxy.h index d41955a..a51c64f 100644 --- a/cc/single_thread_proxy.h +++ b/cc/single_thread_proxy.h @@ -53,6 +53,7 @@ public: virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { } virtual void setNeedsRedrawOnImplThread() OVERRIDE; virtual void setNeedsCommitOnImplThread() OVERRIDE; + virtual void setNeedsManageTilesOnImplThread() OVERRIDE; virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) OVERRIDE; virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE; virtual void sendManagedMemoryStats() OVERRIDE; diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc index ab36b65..2281164 100644 --- a/cc/thread_proxy.cc +++ b/cc/thread_proxy.cc @@ -43,6 +43,7 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh , m_started(false) , m_texturesAcquired(true) , m_inCompositeAndReadback(false) + , m_manageTilesPending(false) , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) , m_beginFrameCompletionEventOnImplThread(0) , m_readbackRequestOnImplThread(0) @@ -332,6 +333,22 @@ void ThreadProxy::setNeedsCommitOnImplThread() m_schedulerOnImplThread->setNeedsCommit(); } +void ThreadProxy::setNeedsManageTilesOnImplThread() +{ + if (m_manageTilesPending) + return; + Proxy::implThread()->postTask(base::Bind(&ThreadProxy::manageTilesOnImplThread, base::Unretained(this))); + m_manageTilesPending = true; +} + +void ThreadProxy::manageTilesOnImplThread() +{ + // TODO(nduca): If needed, move this into CCSchedulerStateMachine. + m_manageTilesPending = false; + if (m_layerTreeHostImpl) + m_layerTreeHostImpl->manageTiles(); +} + void ThreadProxy::setNeedsForcedCommitOnImplThread() { DCHECK(isImplThread()); diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h index 296c180..683dac3 100644 --- a/cc/thread_proxy.h +++ b/cc/thread_proxy.h @@ -61,6 +61,7 @@ public: virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE; virtual void setNeedsRedrawOnImplThread() OVERRIDE; virtual void setNeedsCommitOnImplThread() OVERRIDE; + virtual void setNeedsManageTilesOnImplThread() OVERRIDE; virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) OVERRIDE; virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE; virtual void sendManagedMemoryStats() OVERRIDE; @@ -118,6 +119,7 @@ private: void initializeContextOnImplThread(scoped_ptr<GraphicsContext>); void initializeRendererOnImplThread(CompletionEvent*, bool* initializeSucceeded, RendererCapabilities*); void layerTreeHostClosedOnImplThread(CompletionEvent*); + void manageTilesOnImplThread(); void setFullRootLayerDamageOnImplThread(); void acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*); void recreateContextOnImplThread(CompletionEvent*, scoped_ptr<GraphicsContext>, bool* recreateSucceeded, RendererCapabilities*); @@ -137,6 +139,7 @@ private: bool m_started; bool m_texturesAcquired; bool m_inCompositeAndReadback; + bool m_manageTilesPending; scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; diff --git a/cc/tile_manager.h b/cc/tile_manager.h index f907be9..56ea032 100644 --- a/cc/tile_manager.h +++ b/cc/tile_manager.h @@ -9,7 +9,6 @@ #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "cc/layer_tree_host_impl.h" #include "cc/resource_pool.h" #include "cc/tile_priority.h" @@ -69,7 +68,9 @@ class CC_EXPORT TileManager { TileManager(TileManagerClient* client, ResourceProvider *resource_provider); virtual ~TileManager(); + const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_state_; } void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); + void ManageTiles(); protected: diff --git a/cc/tile_priority.h b/cc/tile_priority.h index 94bbed2..8002f09 100644 --- a/cc/tile_priority.h +++ b/cc/tile_priority.h @@ -12,6 +12,13 @@ namespace cc { +enum WhichTree { + // Note: these must be 0 and 1 because we index with them in various places, + // e.g. in Tile::priority_. + ACTIVE_TREE = 0, + PENDING_TREE = 1 +}; + enum TileResolution { LOW_RESOLUTION = 0 , HIGH_RESOLUTION = 1, |