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

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

Issue 13959005: cc: Recycle resources for software video decode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Destroy recycled textures when VRU shuts down 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
« no previous file with comments | « cc/layers/video_layer_impl.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/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "cc/resources/texture_mailbox.h" 14 #include "cc/resources/texture_mailbox.h"
15 #include "ui/gfx/size.h"
14 16
15 namespace media { 17 namespace media {
16 class SkCanvasVideoRenderer; 18 class SkCanvasVideoRenderer;
17 class VideoFrame; 19 class VideoFrame;
18 } 20 }
19 21
20 namespace cc { 22 namespace cc {
21 class ResourceProvider; 23 class ResourceProvider;
22 24
23 class VideoFrameExternalResources { 25 class VideoFrameExternalResources {
(...skipping 24 matching lines...) Expand all
48 // TODO(danakj): Remove these too. 50 // TODO(danakj): Remove these too.
49 std::vector<unsigned> software_resources; 51 std::vector<unsigned> software_resources;
50 TextureMailbox::ReleaseCallback software_release_callback; 52 TextureMailbox::ReleaseCallback software_release_callback;
51 53
52 VideoFrameExternalResources(); 54 VideoFrameExternalResources();
53 ~VideoFrameExternalResources(); 55 ~VideoFrameExternalResources();
54 }; 56 };
55 57
56 // VideoResourceUpdater is by the video system to produce frame content as 58 // VideoResourceUpdater is by the video system to produce frame content as
57 // resources consumable by the compositor. 59 // resources consumable by the compositor.
58 class VideoResourceUpdater { 60 class VideoResourceUpdater
61 : public base::SupportsWeakPtr<VideoResourceUpdater> {
59 public: 62 public:
60 explicit VideoResourceUpdater(ResourceProvider* resource_provider); 63 explicit VideoResourceUpdater(ResourceProvider* resource_provider);
61 ~VideoResourceUpdater(); 64 ~VideoResourceUpdater();
62 65
63 VideoFrameExternalResources CreateForHardwarePlanes( 66 VideoFrameExternalResources CreateForHardwarePlanes(
64 const scoped_refptr<media::VideoFrame>& video_frame, 67 const scoped_refptr<media::VideoFrame>& video_frame,
65 const TextureMailbox::ReleaseCallback& release_callback); 68 const TextureMailbox::ReleaseCallback& release_callback);
66 69
67 VideoFrameExternalResources CreateForSoftwarePlanes( 70 VideoFrameExternalResources CreateForSoftwarePlanes(
68 const scoped_refptr<media::VideoFrame>& video_frame); 71 const scoped_refptr<media::VideoFrame>& video_frame);
69 72
70 private: 73 private:
74 struct PlaneResource {
75 unsigned resource_id;
76 gfx::Size resource_size;
77 unsigned resource_format;
78 unsigned sync_point;
79
80 PlaneResource(unsigned resource_id,
81 gfx::Size resource_size,
82 unsigned resource_format,
83 unsigned sync_point)
84 : resource_id(resource_id),
85 resource_size(resource_size),
86 resource_format(resource_format),
87 sync_point(sync_point) {}
88 };
89
71 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame); 90 bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame);
72 91
92 static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater,
93 ResourceProvider* resource_provider,
94 unsigned resource_id,
95 gfx::Size resource_size,
96 unsigned resource_format,
97 gpu::Mailbox mailbox,
98 unsigned sync_point);
73 static void ReturnTexture(ResourceProvider* resource_provider, 99 static void ReturnTexture(ResourceProvider* resource_provider,
74 TextureMailbox::ReleaseCallback callback, 100 TextureMailbox::ReleaseCallback callback,
75 unsigned texture_id, 101 unsigned texture_id,
76 gpu::Mailbox mailbox, 102 gpu::Mailbox mailbox,
77 unsigned sync_point); 103 unsigned sync_point);
78 104
79 ResourceProvider* resource_provider_; 105 ResourceProvider* resource_provider_;
80 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; 106 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_;
81 107
108 std::vector<PlaneResource> recycled_resources_;
109
82 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater); 110 DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater);
83 }; 111 };
84 112
85 } // namespace cc 113 } // namespace cc
86 114
87 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_ 115 #endif // CC_RESOURCES_VIDEO_RESOURCE_UPDATER_H_
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/resources/video_resource_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698