Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Side by Side Diff: sky/compositor/layer_host.h

Issue 756673004: Surfaces should acknowledge frame submissions (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef SKY_COMPOSITOR_LAYER_HOST_H_ 5 #ifndef SKY_COMPOSITOR_LAYER_HOST_H_
6 #define SKY_COMPOSITOR_LAYER_HOST_H_ 6 #define SKY_COMPOSITOR_LAYER_HOST_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
10 #include "mojo/skia/ganesh_context.h" 11 #include "mojo/skia/ganesh_context.h"
11 #include "sky/compositor/layer_host_client.h" 12 #include "sky/compositor/layer_host_client.h"
12 #include "sky/compositor/resource_manager.h" 13 #include "sky/compositor/resource_manager.h"
13 #include "sky/compositor/surface_holder.h" 14 #include "sky/compositor/surface_holder.h"
14 #include "sky/scheduler/scheduler.h"
15 15
16 namespace sky { 16 namespace sky {
17 class ResourceManager; 17 class ResourceManager;
18 class Layer; 18 class Layer;
19 class LayerHostClient; 19 class LayerHostClient;
20 20
21 class LayerHost : public SurfaceHolder::Client, public Scheduler::Client { 21 class LayerHost : public SurfaceHolder::Client {
22 public: 22 public:
23 explicit LayerHost(LayerHostClient* client); 23 explicit LayerHost(LayerHostClient* client);
24 ~LayerHost(); 24 ~LayerHost();
25 25
26 LayerHostClient* client() const { return client_; } 26 LayerHostClient* client() const { return client_; }
27 27
28 const base::WeakPtr<mojo::GLContext>& gl_context() const { 28 const base::WeakPtr<mojo::GLContext>& gl_context() const {
29 return gl_context_; 29 return gl_context_;
30 } 30 }
31 31
32 mojo::GaneshContext* ganesh_context() const { 32 mojo::GaneshContext* ganesh_context() const {
33 return const_cast<mojo::GaneshContext*>(&ganesh_context_); 33 return const_cast<mojo::GaneshContext*>(&ganesh_context_);
34 } 34 }
35 35
36 ResourceManager* resource_manager() const { 36 ResourceManager* resource_manager() const {
37 return const_cast<ResourceManager*>(&resource_manager_); 37 return const_cast<ResourceManager*>(&resource_manager_);
38 } 38 }
39 39
40 void SetNeedsAnimate(); 40 void SetNeedsAnimate();
41 void SetRootLayer(scoped_refptr<Layer> layer); 41 void SetRootLayer(scoped_refptr<Layer> layer);
42 42
43 private: 43 private:
44 enum State { 44 enum State {
45 kIdle, 45 kWaitingForSurfaceService,
46 kWaitingForBeginFrame, 46 kReadyForFrame,
47 kProducingFrame, 47 kWaitingForFrameAcknowldgement,
48 kWaitingForSurfaceToUploadFrame,
49 }; 48 };
50 49
51 // SurfaceHolder::Client 50 // SurfaceHolder::Client
51 void OnSurfaceConnectionCreated() override;
52 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; 52 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override;
53 void ReturnResources( 53 void ReturnResources(
54 mojo::Array<mojo::ReturnedResourcePtr> resources) override; 54 mojo::Array<mojo::ReturnedResourcePtr> resources) override;
55 55
56 // Scheduler::Client 56 void BeginFrameSoon();
57 void BeginFrame(base::TimeTicks frame_time, 57 void BeginFrame();
58 base::TimeTicks deadline) override;
59 58
60 void Upload(Layer* layer); 59 void Upload(Layer* layer);
60 void DidCompleteFrame();
61 61
62 LayerHostClient* client_; 62 LayerHostClient* client_;
63 State state_; 63 State state_;
64 bool frame_requested_;
64 SurfaceHolder surface_holder_; 65 SurfaceHolder surface_holder_;
65 base::WeakPtr<mojo::GLContext> gl_context_; 66 base::WeakPtr<mojo::GLContext> gl_context_;
66 mojo::GaneshContext ganesh_context_; 67 mojo::GaneshContext ganesh_context_;
67 ResourceManager resource_manager_; 68 ResourceManager resource_manager_;
68 Scheduler scheduler_; 69 scoped_refptr<Layer> root_layer_;
69 70
70 scoped_refptr<Layer> root_layer_; 71 base::WeakPtrFactory<LayerHost> weak_factory_;
71 72
72 DISALLOW_COPY_AND_ASSIGN(LayerHost); 73 DISALLOW_COPY_AND_ASSIGN(LayerHost);
73 }; 74 };
74 75
75 } // namespace sky 76 } // namespace sky
76 77
77 #endif // SKY_COMPOSITOR_LAYER_HOST_H_ 78 #endif // SKY_COMPOSITOR_LAYER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698