OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ | 5 #ifndef CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ |
6 #define CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ | 6 #define CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // VideoResourceUpdater is used by the video system to produce frame content as | 76 // VideoResourceUpdater is used by the video system to produce frame content as |
77 // resources consumable by the compositor. | 77 // resources consumable by the compositor. |
78 class CC_EXPORT VideoResourceUpdater | 78 class CC_EXPORT VideoResourceUpdater |
79 : public base::SupportsWeakPtr<VideoResourceUpdater> { | 79 : public base::SupportsWeakPtr<VideoResourceUpdater> { |
80 public: | 80 public: |
81 VideoResourceUpdater(ContextProvider* context_provider, | 81 VideoResourceUpdater(ContextProvider* context_provider, |
82 ResourceProvider* resource_provider); | 82 ResourceProvider* resource_provider); |
83 ~VideoResourceUpdater(); | 83 ~VideoResourceUpdater(); |
84 | 84 |
85 VideoFrameExternalResources CreateExternalResourcesFromVideoFrame( | 85 VideoFrameExternalResources CreateExternalResourcesFromVideoFrame( |
86 const scoped_refptr<media::VideoFrame>& video_frame); | 86 scoped_refptr<media::VideoFrame> video_frame); |
87 | 87 |
88 private: | 88 private: |
89 struct PlaneResource { | 89 struct PlaneResource { |
90 unsigned resource_id; | 90 unsigned resource_id; |
91 gfx::Size resource_size; | 91 gfx::Size resource_size; |
92 ResourceFormat resource_format; | 92 ResourceFormat resource_format; |
93 gpu::Mailbox mailbox; | 93 gpu::Mailbox mailbox; |
94 // The balance between the number of times this resource has been returned | 94 // The balance between the number of times this resource has been returned |
95 // from CreateForSoftwarePlanes vs released in RecycleResource. | 95 // from CreateForSoftwarePlanes vs released in RecycleResource. |
96 int ref_count; | 96 int ref_count; |
(...skipping 21 matching lines...) Expand all Loading... |
118 PlaneResource* plane_resource); | 118 PlaneResource* plane_resource); |
119 | 119 |
120 // This needs to be a container where iterators can be erased without | 120 // This needs to be a container where iterators can be erased without |
121 // invalidating other iterators. | 121 // invalidating other iterators. |
122 typedef std::list<PlaneResource> ResourceList; | 122 typedef std::list<PlaneResource> ResourceList; |
123 ResourceList::iterator AllocateResource(const gfx::Size& plane_size, | 123 ResourceList::iterator AllocateResource(const gfx::Size& plane_size, |
124 ResourceFormat format, | 124 ResourceFormat format, |
125 bool has_mailbox, | 125 bool has_mailbox, |
126 bool immutable_hint); | 126 bool immutable_hint); |
127 void DeleteResource(ResourceList::iterator resource_it); | 127 void DeleteResource(ResourceList::iterator resource_it); |
128 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame); | 128 void CopyPlaneTexture(media::VideoFrame* video_frame, |
129 void CopyPlaneTexture(const scoped_refptr<media::VideoFrame>& video_frame, | |
130 const gpu::MailboxHolder& mailbox_holder, | 129 const gpu::MailboxHolder& mailbox_holder, |
131 VideoFrameExternalResources* external_resources); | 130 VideoFrameExternalResources* external_resources); |
132 VideoFrameExternalResources CreateForHardwarePlanes( | 131 VideoFrameExternalResources CreateForHardwarePlanes( |
133 const scoped_refptr<media::VideoFrame>& video_frame); | 132 scoped_refptr<media::VideoFrame> video_frame); |
134 VideoFrameExternalResources CreateForSoftwarePlanes( | 133 VideoFrameExternalResources CreateForSoftwarePlanes( |
135 const scoped_refptr<media::VideoFrame>& video_frame); | 134 scoped_refptr<media::VideoFrame> video_frame); |
136 | 135 |
137 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater, | 136 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater, |
138 unsigned resource_id, | 137 unsigned resource_id, |
139 const gpu::SyncToken& sync_token, | 138 const gpu::SyncToken& sync_token, |
140 bool lost_resource, | 139 bool lost_resource, |
141 BlockingTaskRunner* main_thread_task_runner); | 140 BlockingTaskRunner* main_thread_task_runner); |
142 static void ReturnTexture(base::WeakPtr<VideoResourceUpdater> updater, | 141 static void ReturnTexture(base::WeakPtr<VideoResourceUpdater> updater, |
143 const scoped_refptr<media::VideoFrame>& video_frame, | 142 const scoped_refptr<media::VideoFrame>& video_frame, |
144 const gpu::SyncToken& sync_token, | 143 const gpu::SyncToken& sync_token, |
145 bool lost_resource, | 144 bool lost_resource, |
146 BlockingTaskRunner* main_thread_task_runner); | 145 BlockingTaskRunner* main_thread_task_runner); |
147 | 146 |
148 ContextProvider* context_provider_; | 147 ContextProvider* context_provider_; |
149 ResourceProvider* resource_provider_; | 148 ResourceProvider* resource_provider_; |
150 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; | 149 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; |
151 std::vector<uint8_t> upload_pixels_; | 150 std::vector<uint8_t> upload_pixels_; |
152 | 151 |
153 // Recycle resources so that we can reduce the number of allocations and | 152 // Recycle resources so that we can reduce the number of allocations and |
154 // data transfers. | 153 // data transfers. |
155 ResourceList all_resources_; | 154 ResourceList all_resources_; |
156 | 155 |
157 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater); | 156 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater); |
158 }; | 157 }; |
159 | 158 |
160 } // namespace cc | 159 } // namespace cc |
161 | 160 |
162 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ | 161 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ |
OLD | NEW |