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 COMPONENTS_VIZ_COMMON_RESOURCES_RETURNED_RESOURCE_H_ 6 #define COMPONENTS_VIZ_COMMON_RESOURCES_RETURNED_RESOURCE_H_ 7 8 #include <vector> 9 10 #include "components/viz/common/resources/resource_id.h" 11 #include "components/viz/common/viz_common_export.h" 12 #include "gpu/command_buffer/common/sync_token.h" 13 14 namespace viz { 15 16 // A ReturnedResource is a struct passed along to a child compositor from a 17 // parent compositor that corresponds to a TransferableResource that was 18 // first passed to the parent compositor. 19 struct VIZ_COMMON_EXPORT ReturnedResource { ReturnedResourceReturnedResource20 ReturnedResource(ResourceId id, 21 gpu::SyncToken sync_token, 22 int count, 23 bool lost) 24 : id(id), sync_token(sync_token), count(count), lost(lost) {} 25 ReturnedResourceReturnedResource26 ReturnedResource() {} 27 28 bool operator==(const ReturnedResource& other) const { 29 return id == other.id && sync_token == other.sync_token && 30 count == other.count && lost == other.lost; 31 } 32 33 bool operator!=(const ReturnedResource& other) const { 34 return !(*this == other); 35 } 36 37 // |id| is an identifier generated by the child compositor that uniquely 38 // identifies a resource. This is the same ID space as TransferableResource. 39 ResourceId id = 0; 40 41 // A |sync_token| is an identifier for a point in the parent compositor's 42 // command buffer. The child compositor then issues a WaitSyncPointCHROMIUM 43 // command with this |sync_token| as a parameter into its own command buffer. 44 // This ensures that uses of the resource submitted by the parent compositor 45 // are executed before commands submitted by the child. 46 gpu::SyncToken sync_token; 47 48 // |count| is a reference count for this resource. A resource may be used 49 // by mulitple compositor frames submitted to the parent compositor. |count| 50 // is the number of references being returned back to the child compositor. 51 int count = 0; 52 53 // If the resource is lost, then the returner cannot give a sync point for it, 54 // and so it has taken ownership of the resource. The receiver cannot do 55 // anything with the resource except delete it. 56 bool lost = false; 57 }; 58 59 } // namespace viz 60 61 #endif // COMPONENTS_VIZ_COMMON_RESOURCES_RETURNED_RESOURCE_H_ 62