Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: cc/resources/video_resource_updater.h

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/transparency_display_item.cc ('k') | cc/resources/video_resource_updater.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
13 #include "cc/base/cc_export.h" 14 #include "cc/base/cc_export.h"
14 #include "cc/resources/release_callback_impl.h" 15 #include "cc/resources/release_callback_impl.h"
15 #include "cc/resources/resource_format.h" 16 #include "cc/resources/resource_format.h"
16 #include "cc/resources/texture_mailbox.h" 17 #include "cc/resources/texture_mailbox.h"
17 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
18 19
19 namespace media { 20 namespace media {
20 class SkCanvasVideoRenderer; 21 class SkCanvasVideoRenderer;
21 class VideoFrame; 22 class VideoFrame;
22 } 23 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 VideoFrameExternalResources CreateExternalResourcesFromVideoFrame( 72 VideoFrameExternalResources CreateExternalResourcesFromVideoFrame(
72 const scoped_refptr<media::VideoFrame>& video_frame); 73 const scoped_refptr<media::VideoFrame>& video_frame);
73 74
74 private: 75 private:
75 struct PlaneResource { 76 struct PlaneResource {
76 unsigned resource_id; 77 unsigned resource_id;
77 gfx::Size resource_size; 78 gfx::Size resource_size;
78 ResourceFormat resource_format; 79 ResourceFormat resource_format;
79 gpu::Mailbox mailbox; 80 gpu::Mailbox mailbox;
81 // These last three members will be used for identifying the data stored in
82 // this resource, and uniquely identifies a media::VideoFrame plane. The
83 // frame pointer will only be used for pointer comparison, i.e. the
84 // underlying data will not be accessed.
85 const void* frame_ptr;
86 int plane_index;
87 base::TimeDelta timestamp;
80 88
81 PlaneResource(unsigned resource_id, 89 PlaneResource(unsigned resource_id,
82 const gfx::Size& resource_size, 90 const gfx::Size& resource_size,
83 ResourceFormat resource_format, 91 ResourceFormat resource_format,
84 gpu::Mailbox mailbox) 92 gpu::Mailbox mailbox);
85 : resource_id(resource_id),
86 resource_size(resource_size),
87 resource_format(resource_format),
88 mailbox(mailbox) {}
89 }; 93 };
90 94
95 static bool PlaneResourceMatchesUniqueID(const PlaneResource& plane_resource,
96 const media::VideoFrame* video_frame,
97 int plane_index);
98
99 static void SetPlaneResourceUniqueId(const media::VideoFrame* video_frame,
100 int plane_index,
101 PlaneResource* plane_resource);
102
91 void DeleteResource(unsigned resource_id); 103 void DeleteResource(unsigned resource_id);
92 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame); 104 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame);
93 VideoFrameExternalResources CreateForHardwarePlanes( 105 VideoFrameExternalResources CreateForHardwarePlanes(
94 const scoped_refptr<media::VideoFrame>& video_frame); 106 const scoped_refptr<media::VideoFrame>& video_frame);
95 VideoFrameExternalResources CreateForSoftwarePlanes( 107 VideoFrameExternalResources CreateForSoftwarePlanes(
96 const scoped_refptr<media::VideoFrame>& video_frame); 108 const scoped_refptr<media::VideoFrame>& video_frame);
97 109
98 struct RecycleResourceData {
99 unsigned resource_id;
100 gfx::Size resource_size;
101 ResourceFormat resource_format;
102 gpu::Mailbox mailbox;
103 };
104 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater, 110 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater,
105 RecycleResourceData data, 111 PlaneResource data,
106 uint32 sync_point, 112 uint32 sync_point,
107 bool lost_resource, 113 bool lost_resource,
108 BlockingTaskRunner* main_thread_task_runner); 114 BlockingTaskRunner* main_thread_task_runner);
109 static void ReturnTexture(base::WeakPtr<VideoResourceUpdater> updater, 115 static void ReturnTexture(base::WeakPtr<VideoResourceUpdater> updater,
110 const scoped_refptr<media::VideoFrame>& video_frame, 116 const scoped_refptr<media::VideoFrame>& video_frame,
111 uint32 sync_point, 117 uint32 sync_point,
112 bool lost_resource, 118 bool lost_resource,
113 BlockingTaskRunner* main_thread_task_runner); 119 BlockingTaskRunner* main_thread_task_runner);
114 120
115 ContextProvider* context_provider_; 121 ContextProvider* context_provider_;
116 ResourceProvider* resource_provider_; 122 ResourceProvider* resource_provider_;
117 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; 123 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_;
118 124
119 std::vector<unsigned> all_resources_; 125 std::vector<unsigned> all_resources_;
126 // Recycle resources so that we can reduce the number of allocations and
127 // data transfers.
120 std::vector<PlaneResource> recycled_resources_; 128 std::vector<PlaneResource> recycled_resources_;
121 129
122 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater); 130 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater);
123 }; 131 };
124 132
125 } // namespace cc 133 } // namespace cc
126 134
127 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ 135 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_
OLDNEW
« no previous file with comments | « cc/resources/transparency_display_item.cc ('k') | cc/resources/video_resource_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698