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

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

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ifdefed Created 7 years, 8 months 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 | Annotate | Revision Log
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/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "cc/resources/texture_mailbox.h" 14 #include "cc/resources/texture_mailbox.h"
15 #include "media/base/video_frame.h" // TODO(danakj): rm w/ VIDEO_FRAME_MAILBOX
15 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
16 17
17 namespace media { 18 namespace media {
18 class SkCanvasVideoRenderer; 19 class SkCanvasVideoRenderer;
19 class VideoFrame; 20 class VideoFrame;
20 } 21 }
21 22
22 namespace cc { 23 namespace cc {
23 class ResourceProvider; 24 class ResourceProvider;
24 25
(...skipping 15 matching lines...) Expand all
40 #endif 41 #endif
41 42
42 // TODO(danakj): Remove this and abstract TextureMailbox into 43 // TODO(danakj): Remove this and abstract TextureMailbox into
43 // "ExternalResource" that can hold a hardware or software backing. 44 // "ExternalResource" that can hold a hardware or software backing.
44 SOFTWARE_RESOURCE 45 SOFTWARE_RESOURCE
45 }; 46 };
46 47
47 ResourceType type; 48 ResourceType type;
48 std::vector<TextureMailbox> mailboxes; 49 std::vector<TextureMailbox> mailboxes;
49 50
51 #ifndef VIDEO_FRAME_MAILBOX
52 unsigned hardware_resource;
53 TextureMailbox::ReleaseCallback hardware_release_callback;
54 #endif
55
50 // TODO(danakj): Remove these too. 56 // TODO(danakj): Remove these too.
51 std::vector<unsigned> software_resources; 57 std::vector<unsigned> software_resources;
52 TextureMailbox::ReleaseCallback software_release_callback; 58 TextureMailbox::ReleaseCallback software_release_callback;
53 59
54 VideoFrameExternalResources(); 60 VideoFrameExternalResources();
55 ~VideoFrameExternalResources(); 61 ~VideoFrameExternalResources();
56 }; 62 };
57 63
58 // VideoResourceUpdater is by the video system to produce frame content as 64 // VideoResourceUpdater is by the video system to produce frame content as
59 // resources consumable by the compositor. 65 // resources consumable by the compositor.
60 class VideoResourceUpdater 66 class VideoResourceUpdater
61 : public base::SupportsWeakPtr<VideoResourceUpdater> { 67 : public base::SupportsWeakPtr<VideoResourceUpdater> {
62 public: 68 public:
63 explicit VideoResourceUpdater(ResourceProvider* resource_provider); 69 explicit VideoResourceUpdater(ResourceProvider* resource_provider);
64 ~VideoResourceUpdater(); 70 ~VideoResourceUpdater();
65 71
66 VideoFrameExternalResources CreateForHardwarePlanes( 72 VideoFrameExternalResources CreateExternalResourcesFromVideoFrame(
67 const scoped_refptr<media::VideoFrame>& video_frame,
68 const TextureMailbox::ReleaseCallback& release_callback);
69
70 VideoFrameExternalResources CreateForSoftwarePlanes(
71 const scoped_refptr<media::VideoFrame>& video_frame); 73 const scoped_refptr<media::VideoFrame>& video_frame);
72 74
73 private: 75 private:
74 struct PlaneResource { 76 struct PlaneResource {
75 unsigned resource_id; 77 unsigned resource_id;
76 gfx::Size resource_size; 78 gfx::Size resource_size;
77 unsigned resource_format; 79 unsigned resource_format;
78 unsigned sync_point; 80 unsigned sync_point;
79 81
80 PlaneResource(unsigned resource_id, 82 PlaneResource(unsigned resource_id,
81 gfx::Size resource_size, 83 gfx::Size resource_size,
82 unsigned resource_format, 84 unsigned resource_format,
83 unsigned sync_point) 85 unsigned sync_point)
84 : resource_id(resource_id), 86 : resource_id(resource_id),
85 resource_size(resource_size), 87 resource_size(resource_size),
86 resource_format(resource_format), 88 resource_format(resource_format),
87 sync_point(sync_point) {} 89 sync_point(sync_point) {}
88 }; 90 };
89 91
90 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame); 92 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame);
93 VideoFrameExternalResources CreateForHardwarePlanes(
94 const scoped_refptr<media::VideoFrame>& video_frame);
95 VideoFrameExternalResources CreateForSoftwarePlanes(
96 const scoped_refptr<media::VideoFrame>& video_frame);
91 97
92 struct RecycleResourceData { 98 struct RecycleResourceData {
93 unsigned resource_id; 99 unsigned resource_id;
94 gfx::Size resource_size; 100 gfx::Size resource_size;
95 unsigned resource_format; 101 unsigned resource_format;
96 gpu::Mailbox mailbox; 102 gpu::Mailbox mailbox;
97 }; 103 };
98 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater, 104 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater,
99 ResourceProvider* resource_provider, 105 ResourceProvider* resource_provider,
100 RecycleResourceData data, 106 RecycleResourceData data,
101 unsigned sync_point, 107 unsigned sync_point,
102 bool lost_resource); 108 bool lost_resource);
103 static void ReturnTexture(ResourceProvider* resource_provider, 109 static void ReturnTexture(scoped_refptr<media::VideoFrame> video_frame,
104 TextureMailbox::ReleaseCallback callback, 110 #ifndef VIDEO_FRAME_MAILBOX
105 unsigned texture_id, 111 ResourceProvider* resource_provider,
106 gpu::Mailbox mailbox, 112 unsigned resource_id,
113 #endif
107 unsigned sync_point, 114 unsigned sync_point,
108 bool lost_resource); 115 bool lost_resource);
109 116
110 ResourceProvider* resource_provider_; 117 ResourceProvider* resource_provider_;
111 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; 118 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_;
112 119
113 std::vector<PlaneResource> recycled_resources_; 120 std::vector<PlaneResource> recycled_resources_;
114 121
115 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater); 122 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater);
116 }; 123 };
117 124
118 } // namespace cc 125 } // namespace cc
119 126
120 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ 127 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698