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