1 // Copyright 2012 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 #ifndef CC_TREES_LAYER_TREE_HOST_CLIENT_H_ 6 #define CC_TREES_LAYER_TREE_HOST_CLIENT_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "base/memory/scoped_ptr.h" 10 11 namespace gfx { 12 class Vector2d; 13 } 14 15 namespace cc { 16 class ContextProvider; 17 class InputHandlerClient; 18 class OutputSurface; 19 20 class LayerTreeHostClient { 21 public: 22 virtual void WillBeginMainFrame(int frame_id) = 0; 23 // Marks finishing compositing-related tasks on the main thread. In threaded 24 // mode, this corresponds to DidCommit(). 25 virtual void DidBeginMainFrame() = 0; 26 virtual void Animate(double frame_begin_time) = 0; 27 virtual void Layout() = 0; 28 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 29 float page_scale) = 0; 30 // Creates an OutputSurface. If fallback is true, it should attempt to 31 // create an OutputSurface that is guaranteed to initialize correctly. 32 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) = 0; 33 virtual void DidInitializeOutputSurface(bool success) = 0; 34 virtual void WillCommit() = 0; 35 virtual void DidCommit() = 0; 36 virtual void DidCommitAndDrawFrame() = 0; 37 virtual void DidCompleteSwapBuffers() = 0; 38 39 // If the client provides an OutputSurface bound to a 3d context for direct 40 // rendering, this must return a provider that provides contexts usable from 41 // the same thread as the OutputSurface's context. 42 virtual scoped_refptr<ContextProvider> OffscreenContextProvider() = 0; 43 44 // Requests that the client insert a rate limiting token in the shared main 45 // thread context's command stream that will block if the context gets too far 46 // ahead of the compositor's command stream. Only needed if the tree contains 47 // a TextureLayer that calls SetRateLimitContext(true). 48 virtual void RateLimitSharedMainThreadContext() {} 49 50 // This hook is for testing. 51 virtual void DidFailToInitializeOutputSurface() {} 52 53 protected: 54 virtual ~LayerTreeHostClient() {} 55 }; 56 57 } // namespace cc 58 59 #endif // CC_TREES_LAYER_TREE_HOST_CLIENT_H_ 60