| OLD | NEW |
| 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 "mojo/skia/ganesh_context.h" | 10 #include "mojo/skia/ganesh_context.h" |
| 11 #include "sky/compositor/layer_host_client.h" | 11 #include "sky/compositor/layer_host_client.h" |
| 12 #include "sky/compositor/resource_manager.h" | 12 #include "sky/compositor/resource_manager.h" |
| 13 #include "sky/compositor/surface_holder.h" | 13 #include "sky/compositor/surface_holder.h" |
| 14 #include "sky/scheduler/scheduler.h" |
| 14 | 15 |
| 15 namespace sky { | 16 namespace sky { |
| 16 class ResourceManager; | 17 class ResourceManager; |
| 17 class Layer; | 18 class Layer; |
| 18 class LayerHostClient; | 19 class LayerHostClient; |
| 19 | 20 |
| 20 class LayerHost : public SurfaceHolder::Client { | 21 class LayerHost : public SurfaceHolder::Client, public Scheduler::Client { |
| 21 public: | 22 public: |
| 22 explicit LayerHost(LayerHostClient* client); | 23 explicit LayerHost(LayerHostClient* client); |
| 23 ~LayerHost(); | 24 ~LayerHost(); |
| 24 | 25 |
| 25 LayerHostClient* client() const { return client_; } | 26 LayerHostClient* client() const { return client_; } |
| 26 | 27 |
| 27 const base::WeakPtr<mojo::GLContext>& gl_context() const { | 28 const base::WeakPtr<mojo::GLContext>& gl_context() const { |
| 28 return gl_context_; | 29 return gl_context_; |
| 29 } | 30 } |
| 30 | 31 |
| 31 mojo::GaneshContext* ganesh_context() const { | 32 mojo::GaneshContext* ganesh_context() const { |
| 32 return const_cast<mojo::GaneshContext*>(&ganesh_context_); | 33 return const_cast<mojo::GaneshContext*>(&ganesh_context_); |
| 33 } | 34 } |
| 34 | 35 |
| 35 ResourceManager* resource_manager() const { | 36 ResourceManager* resource_manager() const { |
| 36 return const_cast<ResourceManager*>(&resource_manager_); | 37 return const_cast<ResourceManager*>(&resource_manager_); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void SetNeedsAnimate(); | 40 void SetNeedsAnimate(); |
| 40 void SetRootLayer(scoped_refptr<Layer> layer); | 41 void SetRootLayer(scoped_refptr<Layer> layer); |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 // SurfaceHolder::Client | 44 // SurfaceHolder::Client |
| 44 void OnReadyForNextFrame() override; | |
| 45 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; | 45 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; |
| 46 void ReturnResources( | 46 void ReturnResources( |
| 47 mojo::Array<mojo::ReturnedResourcePtr> resources) override; | 47 mojo::Array<mojo::ReturnedResourcePtr> resources) override; |
| 48 | 48 |
| 49 // Scheduler::Client |
| 50 void BeginFrame(base::TimeTicks frame_time, |
| 51 base::TimeTicks deadline) override; |
| 52 |
| 49 void Upload(Layer* layer); | 53 void Upload(Layer* layer); |
| 50 | 54 |
| 51 LayerHostClient* client_; | 55 LayerHostClient* client_; |
| 52 SurfaceHolder surface_holder_; | 56 SurfaceHolder surface_holder_; |
| 53 base::WeakPtr<mojo::GLContext> gl_context_; | 57 base::WeakPtr<mojo::GLContext> gl_context_; |
| 54 mojo::GaneshContext ganesh_context_; | 58 mojo::GaneshContext ganesh_context_; |
| 55 ResourceManager resource_manager_; | 59 ResourceManager resource_manager_; |
| 60 Scheduler scheduler_; |
| 56 | 61 |
| 57 scoped_refptr<Layer> root_layer_; | 62 scoped_refptr<Layer> root_layer_; |
| 58 | 63 |
| 59 DISALLOW_COPY_AND_ASSIGN(LayerHost); | 64 DISALLOW_COPY_AND_ASSIGN(LayerHost); |
| 60 }; | 65 }; |
| 61 | 66 |
| 62 } // namespace sky | 67 } // namespace sky |
| 63 | 68 |
| 64 #endif // SKY_COMPOSITOR_LAYER_HOST_H_ | 69 #endif // SKY_COMPOSITOR_LAYER_HOST_H_ |
| OLD | NEW |