| 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 MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 5 #ifndef MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 
| 6 #define MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 6 #define MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 
| 7 | 7 | 
| 8 #include "media/base/media_export.h" | 8 #include "media/base/media_export.h" | 
| 9 #include "media/base/video_frame.h" | 9 #include "media/base/video_frame.h" | 
| 10 | 10 | 
| 11 namespace media { | 11 namespace media { | 
| 12 | 12 | 
| 13 // Simple VideoFrame pool used to avoid unnecessarily allocating and destroying | 13 // Simple VideoFrame pool used to avoid unnecessarily allocating and destroying | 
| 14 // VideoFrame objects. The pool manages the memory for the VideoFrame | 14 // VideoFrame objects. The pool manages the memory for the VideoFrame | 
| 15 // returned by CreateFrame(). When one of these VideoFrames is destroyed, | 15 // returned by CreateFrame(). When one of these VideoFrames is destroyed, | 
| 16 // the memory is returned to the pool for use by a subsequent CreateFrame() | 16 // the memory is returned to the pool for use by a subsequent CreateFrame() | 
| 17 // call. The memory in the pool is retained for the life of the | 17 // call. The memory in the pool is retained for the life of the | 
| 18 // VideoFramePool object. If the parameters passed to CreateFrame() change | 18 // VideoFramePool object. If the parameters passed to CreateFrame() change | 
| 19 // during the life of this object, then the memory used by frames with the old | 19 // during the life of this object, then the memory used by frames with the old | 
| 20 // parameter values will be purged from the pool. | 20 // parameter values will be purged from the pool. | 
| 21 class MEDIA_EXPORT VideoFramePool { | 21 class MEDIA_EXPORT VideoFramePool { | 
| 22  public: | 22  public: | 
| 23   VideoFramePool(); | 23   VideoFramePool(); | 
| 24   ~VideoFramePool(); | 24   ~VideoFramePool(); | 
| 25 | 25 | 
| 26   // Returns a frame from the pool that matches the specified | 26   // Returns a frame from the pool that matches the specified | 
| 27   // parameters or creates a new frame if no suitable frame exists in | 27   // parameters or creates a new frame if no suitable frame exists in | 
| 28   // the pool. | 28   // the pool. The pool is drained if no matching frame is found. | 
|  | 29   // If a new frame must be created and |zero_new_frames| is true, the buffer | 
|  | 30   // for the new frame will be zero initialized.  Reused frames will not be zero | 
|  | 31   // initialized. | 
| 29   scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format, | 32   scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format, | 
| 30                                         const gfx::Size& coded_size, | 33                                         const gfx::Size& coded_size, | 
| 31                                         const gfx::Rect& visible_rect, | 34                                         const gfx::Rect& visible_rect, | 
| 32                                         const gfx::Size& natural_size, | 35                                         const gfx::Size& natural_size, | 
| 33                                         base::TimeDelta timestamp); | 36                                         base::TimeDelta timestamp, | 
|  | 37                                         bool zero_new_frames); | 
| 34 | 38 | 
| 35 protected: | 39 protected: | 
| 36   friend class VideoFramePoolTest; | 40   friend class VideoFramePoolTest; | 
| 37 | 41 | 
| 38   // Returns the number of frames in the pool for testing purposes. | 42   // Returns the number of frames in the pool for testing purposes. | 
| 39   size_t GetPoolSizeForTesting() const; | 43   size_t GetPoolSizeForTesting() const; | 
| 40 | 44 | 
| 41  private: | 45  private: | 
| 42   class PoolImpl; | 46   class PoolImpl; | 
| 43   scoped_refptr<PoolImpl> pool_; | 47   scoped_refptr<PoolImpl> pool_; | 
| 44 | 48 | 
| 45   DISALLOW_COPY_AND_ASSIGN(VideoFramePool); | 49   DISALLOW_COPY_AND_ASSIGN(VideoFramePool); | 
| 46 }; | 50 }; | 
| 47 | 51 | 
| 48 }  // namespace media | 52 }  // namespace media | 
| 49 | 53 | 
| 50 #endif  // MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 54 #endif  // MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 
| OLD | NEW | 
|---|