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 #include "base/time/time.h" 11 12 namespace gfx { 13 class Vector2d; 14 } 15 16 namespace cc { 17 class ContextProvider; 18 class InputHandlerClient; 19 class OutputSurface; 20 struct BeginFrameArgs; 21 22 class LayerTreeHostClient { 23 public: 24 virtual void WillBeginMainFrame(int frame_id) = 0; 25 // Marks finishing compositing-related tasks on the main thread. In threaded 26 // mode, this corresponds to DidCommit(). 27 virtual void BeginMainFrame(const BeginFrameArgs& args) = 0; 28 virtual void DidBeginMainFrame() = 0; 29 virtual void Layout() = 0; 30 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, 31 float page_scale, 32 float top_controls_delta) = 0; 33 // Request an OutputSurface from the client. When the client has one it should 34 // call LayerTreeHost::SetOutputSurface. If fallback is true, it should 35 // attempt to create an OutputSurface that is guaranteed to initialize 36 // correctly. 37 virtual void RequestNewOutputSurface(bool fallback) = 0; 38 virtual void DidInitializeOutputSurface() = 0; 39 virtual void WillCommit() = 0; 40 virtual void DidCommit() = 0; 41 virtual void DidCommitAndDrawFrame() = 0; 42 virtual void DidCompleteSwapBuffers() = 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