Commit 79635310 authored by danakj@chromium.org's avatar danakj@chromium.org

cc: Recycle resources for software video decode.

When we update a compositor resource from a media::VideoFrame,
try to reuse resources from previous frames that were returned
to us by the ResourceProvider.

R=piman,enne
BUG=179729
Depends on: https://codereview.chromium.org/13445009/

Review URL: https://chromiumcodereview.appspot.com/13959005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193409 0039d316-1c4b-4281-b951-d872f2087c98
parent 70b0c164
...@@ -83,6 +83,9 @@ void VideoLayerImpl::WillDraw(ResourceProvider* resource_provider) { ...@@ -83,6 +83,9 @@ void VideoLayerImpl::WillDraw(ResourceProvider* resource_provider) {
frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); frame_ = provider_client_impl_->AcquireLockAndCurrentFrame();
if (!frame_) { if (!frame_) {
// Drop any resources used by the updater if there is no frame to display.
updater_.reset();
provider_client_impl_->ReleaseLock(); provider_client_impl_->ReleaseLock();
return; return;
} }
......
This diff is collapsed.
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "cc/resources/texture_mailbox.h" #include "cc/resources/texture_mailbox.h"
#include "ui/gfx/size.h"
namespace media { namespace media {
class SkCanvasVideoRenderer; class SkCanvasVideoRenderer;
...@@ -55,7 +57,8 @@ class VideoFrameExternalResources { ...@@ -55,7 +57,8 @@ class VideoFrameExternalResources {
// VideoResourceUpdater is by the video system to produce frame content as // VideoResourceUpdater is by the video system to produce frame content as
// resources consumable by the compositor. // resources consumable by the compositor.
class VideoResourceUpdater { class VideoResourceUpdater
: public base::SupportsWeakPtr<VideoResourceUpdater> {
public: public:
explicit VideoResourceUpdater(ResourceProvider* resource_provider); explicit VideoResourceUpdater(ResourceProvider* resource_provider);
~VideoResourceUpdater(); ~VideoResourceUpdater();
...@@ -68,8 +71,31 @@ class VideoResourceUpdater { ...@@ -68,8 +71,31 @@ class VideoResourceUpdater {
const scoped_refptr<media::VideoFrame>& video_frame); const scoped_refptr<media::VideoFrame>& video_frame);
private: private:
struct PlaneResource {
unsigned resource_id;
gfx::Size resource_size;
unsigned resource_format;
unsigned sync_point;
PlaneResource(unsigned resource_id,
gfx::Size resource_size,
unsigned resource_format,
unsigned sync_point)
: resource_id(resource_id),
resource_size(resource_size),
resource_format(resource_format),
sync_point(sync_point) {}
};
bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame); bool VerifyFrame(const scoped_refptr<media::VideoFrame>& video_frame);
static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater,
ResourceProvider* resource_provider,
unsigned resource_id,
gfx::Size resource_size,
unsigned resource_format,
gpu::Mailbox mailbox,
unsigned sync_point);
static void ReturnTexture(ResourceProvider* resource_provider, static void ReturnTexture(ResourceProvider* resource_provider,
TextureMailbox::ReleaseCallback callback, TextureMailbox::ReleaseCallback callback,
unsigned texture_id, unsigned texture_id,
...@@ -79,6 +105,8 @@ class VideoResourceUpdater { ...@@ -79,6 +105,8 @@ class VideoResourceUpdater {
ResourceProvider* resource_provider_; ResourceProvider* resource_provider_;
scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_;
std::vector<PlaneResource> recycled_resources_;
DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater); DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment