| 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 CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ | 5 #ifndef CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ |
| 6 #define CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ | 6 #define CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/base/resource_id.h" | 11 #include "cc/base/resource_id.h" |
| 12 #include "cc/resources/returned_resource.h" | 12 #include "cc/resources/returned_resource.h" |
| 13 #include "cc/resources/transferable_resource.h" | 13 #include "cc/resources/transferable_resource.h" |
| 14 #include "cc/surfaces/surfaces_export.h" | 14 #include "cc/surfaces/surfaces_export.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 class SurfaceFactoryClient; | 17 class CompositorFrameSinkSupport; |
| 18 | 18 |
| 19 // A SurfaceResourceHolder manages the lifetime of resources submitted by a | 19 // A SurfaceResourceHolder manages the lifetime of resources submitted by a |
| 20 // particular SurfaceFactory. Each resource is held by the service until | 20 // particular SurfaceFactory. Each resource is held by the service until |
| 21 // it is no longer referenced by any pending frames or by any | 21 // it is no longer referenced by any pending frames or by any |
| 22 // resource providers. | 22 // resource providers. |
| 23 class CC_SURFACES_EXPORT SurfaceResourceHolder { | 23 class CC_SURFACES_EXPORT SurfaceResourceHolder { |
| 24 public: | 24 public: |
| 25 explicit SurfaceResourceHolder(SurfaceFactoryClient* client); | 25 explicit SurfaceResourceHolder(CompositorFrameSinkSupport* client); |
| 26 ~SurfaceResourceHolder(); | 26 ~SurfaceResourceHolder(); |
| 27 | 27 |
| 28 void Reset(); | 28 void Reset(); |
| 29 void ReceiveFromChild(const TransferableResourceArray& resources); | 29 void ReceiveFromChild(const TransferableResourceArray& resources); |
| 30 void RefResources(const TransferableResourceArray& resources); | 30 void RefResources(const TransferableResourceArray& resources); |
| 31 void UnrefResources(const ReturnedResourceArray& resources); | 31 void UnrefResources(const ReturnedResourceArray& resources); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 SurfaceFactoryClient* client_; | 34 CompositorFrameSinkSupport* client_; |
| 35 | 35 |
| 36 struct ResourceRefs { | 36 struct ResourceRefs { |
| 37 ResourceRefs(); | 37 ResourceRefs(); |
| 38 | 38 |
| 39 int refs_received_from_child; | 39 int refs_received_from_child; |
| 40 int refs_holding_resource_alive; | 40 int refs_holding_resource_alive; |
| 41 gpu::SyncToken sync_token; | 41 gpu::SyncToken sync_token; |
| 42 }; | 42 }; |
| 43 // Keeps track of the number of users currently in flight for each resource | 43 // Keeps track of the number of users currently in flight for each resource |
| 44 // ID we've received from the client. When this counter hits zero for a | 44 // ID we've received from the client. When this counter hits zero for a |
| 45 // particular resource, that ID is available to return to the client with | 45 // particular resource, that ID is available to return to the client with |
| 46 // the most recently given non-empty sync token. | 46 // the most recently given non-empty sync token. |
| 47 using ResourceIdInfoMap = std::unordered_map<ResourceId, ResourceRefs>; | 47 using ResourceIdInfoMap = std::unordered_map<ResourceId, ResourceRefs>; |
| 48 ResourceIdInfoMap resource_id_info_map_; | 48 ResourceIdInfoMap resource_id_info_map_; |
| 49 | 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(SurfaceResourceHolder); | 50 DISALLOW_COPY_AND_ASSIGN(SurfaceResourceHolder); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } // namespace cc | 53 } // namespace cc |
| 54 | 54 |
| 55 #endif // CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ | 55 #endif // CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ |
| OLD | NEW |