| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ |
| 6 #define CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ |
| 7 |
| 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "cc/base/cc_export.h" |
| 13 #include "cc/resources/return_callback.h" |
| 14 #include "cc/resources/returned_resource.h" |
| 15 #include "cc/resources/transferable_resource.h" |
| 16 |
| 17 namespace cc { |
| 18 class BlockingTaskRunner; |
| 19 |
| 20 class CC_EXPORT DelegatedFrameResourceCollectionClient { |
| 21 public: |
| 22 // Called to inform the client that returned resources can be |
| 23 // grabbed off the DelegatedFrameResourceCollection. |
| 24 virtual void UnusedResourcesAreAvailable() = 0; |
| 25 }; |
| 26 |
| 27 class CC_EXPORT DelegatedFrameResourceCollection { |
| 28 public: |
| 29 explicit DelegatedFrameResourceCollection( |
| 30 DelegatedFrameResourceCollectionClient* client); |
| 31 ~DelegatedFrameResourceCollection(); |
| 32 |
| 33 void TakeUnusedResourcesForChildCompositor(ReturnedResourceArray* array); |
| 34 |
| 35 // Methods for DelegatedFrameProvider. |
| 36 void RefResources(const TransferableResourceArray& resources); |
| 37 ReturnCallback GetReturnResourcesCallbackForImplThread(); |
| 38 void ReceivedResources(const TransferableResourceArray& resources); |
| 39 void ReturnResources(const ReturnedResourceArray& returned); |
| 40 |
| 41 private: |
| 42 void UnrefResources(const ReturnedResourceArray& returned); |
| 43 static void UnrefResourcesOnImplThread( |
| 44 scoped_refptr<BlockingTaskRunner> main_thread_runner, |
| 45 base::WeakPtr<DelegatedFrameResourceCollection> self, |
| 46 const ReturnedResourceArray& returned); |
| 47 |
| 48 DelegatedFrameResourceCollectionClient* client_; |
| 49 scoped_refptr<BlockingTaskRunner> main_thread_runner_; |
| 50 |
| 51 ReturnedResourceArray returned_resources_for_child_compositor_; |
| 52 |
| 53 struct RefCount { |
| 54 int refs_to_return; |
| 55 int refs_to_wait_for; |
| 56 }; |
| 57 typedef base::hash_map<unsigned, RefCount> ResourceIdRefCountMap; |
| 58 ResourceIdRefCountMap resource_id_ref_count_map_; |
| 59 |
| 60 base::ThreadChecker main_thread_checker_; |
| 61 base::WeakPtrFactory<DelegatedFrameResourceCollection> weak_ptrs_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameResourceCollection); |
| 64 }; |
| 65 |
| 66 } // namespace cc |
| 67 |
| 68 #endif // CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ |
| OLD | NEW |