| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ | 5 #ifndef CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ |
| 6 #define CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ | 6 #define CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 11 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 13 #include "cc/layers/delegated_frame_provider.h" |
| 12 #include "cc/layers/layer.h" | 14 #include "cc/layers/layer.h" |
| 13 #include "cc/resources/returned_resource.h" | 15 #include "cc/resources/returned_resource.h" |
| 14 | 16 |
| 15 namespace cc { | 17 namespace cc { |
| 16 class BlockingTaskRunner; | 18 class BlockingTaskRunner; |
| 17 class DelegatedFrameData; | |
| 18 class DelegatedRendererLayerClient; | 19 class DelegatedRendererLayerClient; |
| 19 | 20 |
| 20 class CC_EXPORT DelegatedRendererLayer : public Layer { | 21 class CC_EXPORT DelegatedRendererLayer : public Layer { |
| 21 public: | 22 public: |
| 22 static scoped_refptr<DelegatedRendererLayer> Create( | 23 static scoped_refptr<DelegatedRendererLayer> Create( |
| 23 DelegatedRendererLayerClient* client); | 24 DelegatedRendererLayerClient* client, |
| 25 const scoped_refptr<DelegatedFrameProvider>& frame_provider); |
| 24 | 26 |
| 25 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 27 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
| 26 OVERRIDE; | 28 OVERRIDE; |
| 27 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; | 29 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; |
| 30 virtual bool Update(ResourceUpdateQueue* queue, |
| 31 const OcclusionTracker* occlusion) OVERRIDE; |
| 28 virtual void PushPropertiesTo(LayerImpl* impl) OVERRIDE; | 32 virtual void PushPropertiesTo(LayerImpl* impl) OVERRIDE; |
| 29 virtual bool DrawsContent() const OVERRIDE; | |
| 30 | 33 |
| 31 // Set the size at which the frame should be displayed, with the origin at the | 34 // Set the size at which the frame should be displayed, with the origin at the |
| 32 // layer's origin. This must always contain at least the layer's bounds. A | 35 // layer's origin. This must always contain at least the layer's bounds. A |
| 33 // value of (0, 0) implies that the frame should be displayed to fit exactly | 36 // value of (0, 0) implies that the frame should be displayed to fit exactly |
| 34 // in the layer's bounds. | 37 // in the layer's bounds. |
| 35 void SetDisplaySize(gfx::Size size); | 38 void SetDisplaySize(gfx::Size size); |
| 36 | 39 |
| 37 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data); | 40 // Called by the DelegatedFrameProvider when a new frame is available to be |
| 38 | 41 // picked up. |
| 39 // Passes ownership of any unused resources that had been given by the child | 42 void ProviderHasNewFrame(); |
| 40 // compositor to the given array, so they can be given back to the child. | |
| 41 void TakeUnusedResourcesForChildCompositor(ReturnedResourceArray* array); | |
| 42 | 43 |
| 43 protected: | 44 protected: |
| 44 explicit DelegatedRendererLayer(DelegatedRendererLayerClient* client); | 45 DelegatedRendererLayer( |
| 46 DelegatedRendererLayerClient* client, |
| 47 const scoped_refptr<DelegatedFrameProvider>& frame_provider); |
| 45 virtual ~DelegatedRendererLayer(); | 48 virtual ~DelegatedRendererLayer(); |
| 46 | 49 |
| 47 private: | 50 private: |
| 48 void ReceiveUnusedResources(const ReturnedResourceArray& unused); | 51 DelegatedRendererLayerClient* client_; |
| 49 static void ReceiveUnusedResourcesOnImplThread( | 52 scoped_refptr<DelegatedFrameProvider> frame_provider_; |
| 50 scoped_refptr<BlockingTaskRunner> task_runner, | |
| 51 base::WeakPtr<DelegatedRendererLayer> self, | |
| 52 const ReturnedResourceArray& unused); | |
| 53 | 53 |
| 54 scoped_ptr<DelegatedFrameData> frame_data_; | 54 bool should_collect_new_frame_; |
| 55 gfx::RectF damage_in_frame_; | 55 |
| 56 gfx::Size frame_size_; | 56 DelegatedFrameData* frame_data_; |
| 57 gfx::RectF frame_damage_; |
| 58 |
| 57 gfx::Size display_size_; | 59 gfx::Size display_size_; |
| 58 | 60 |
| 59 DelegatedRendererLayerClient* client_; | |
| 60 bool needs_filter_context_; | |
| 61 | |
| 62 ReturnedResourceArray unused_resources_for_child_compositor_; | |
| 63 scoped_refptr<BlockingTaskRunner> main_thread_runner_; | 61 scoped_refptr<BlockingTaskRunner> main_thread_runner_; |
| 64 base::WeakPtrFactory<DelegatedRendererLayer> weak_ptrs_; | 62 base::WeakPtrFactory<DelegatedRendererLayer> weak_ptrs_; |
| 65 | 63 |
| 66 DISALLOW_COPY_AND_ASSIGN(DelegatedRendererLayer); | 64 DISALLOW_COPY_AND_ASSIGN(DelegatedRendererLayer); |
| 67 }; | 65 }; |
| 68 | 66 |
| 69 } // namespace cc | 67 } // namespace cc |
| 70 | 68 |
| 71 #endif // CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ | 69 #endif // CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ |
| OLD | NEW |