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

Side by Side Diff: media/base/video_frame.h

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Folded sync_point into sync_tokens Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_ 6 #define MEDIA_BASE_VIDEO_FRAME_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h"
11 #include "base/md5.h" 12 #include "base/md5.h"
12 #include "base/memory/shared_memory.h" 13 #include "base/memory/shared_memory.h"
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "gpu/command_buffer/common/mailbox_holder.h" 15 #include "gpu/command_buffer/common/mailbox_holder.h"
15 #include "media/base/video_frame_metadata.h" 16 #include "media/base/video_frame_metadata.h"
16 #include "media/base/video_types.h" 17 #include "media/base/video_types.h"
17 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/size.h" 19 #include "ui/gfx/geometry/size.h"
19 20
20 #if defined(OS_MACOSX) 21 #if defined(OS_MACOSX)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 STORAGE_LAST = STORAGE_HOLE, 71 STORAGE_LAST = STORAGE_HOLE,
71 #elif defined(OS_LINUX) 72 #elif defined(OS_LINUX)
72 STORAGE_LAST = STORAGE_DMABUFS, 73 STORAGE_LAST = STORAGE_DMABUFS,
73 #else 74 #else
74 STORAGE_LAST = STORAGE_SHMEM 75 STORAGE_LAST = STORAGE_SHMEM
75 #endif 76 #endif
76 }; 77 };
77 78
78 // CB to be called on the mailbox backing this frame when the frame is 79 // CB to be called on the mailbox backing this frame when the frame is
79 // destroyed. 80 // destroyed.
80 typedef base::Callback<void(uint32)> ReleaseMailboxCB; 81 typedef base::Callback<void(const gpu::SyncToken&)> ReleaseMailboxCB;
81 82
82 // Interface representing client operations on a SyncPoint, i.e. insert one in 83 // Interface representing client operations on a SyncToken, i.e. insert one in
83 // the GPU Command Buffer and wait for it. 84 // the GPU Command Buffer and wait for it.
84 class SyncPointClient { 85 class SyncTokenClient {
85 public: 86 public:
86 SyncPointClient() {} 87 SyncTokenClient() {}
87 virtual uint32 InsertSyncPoint() = 0; 88 virtual uint32 InsertSyncPoint() = 0;
88 virtual void WaitSyncPoint(uint32 sync_point) = 0; 89 virtual void WaitSyncToken(const gpu::SyncToken& sync_token) = 0;
89 90
90 protected: 91 protected:
91 virtual ~SyncPointClient() {} 92 virtual ~SyncTokenClient() {}
92 93
93 DISALLOW_COPY_AND_ASSIGN(SyncPointClient); 94 DISALLOW_COPY_AND_ASSIGN(SyncTokenClient);
94 }; 95 };
95 96
96 // Call prior to CreateFrame to ensure validity of frame configuration. Called 97 // Call prior to CreateFrame to ensure validity of frame configuration. Called
97 // automatically by VideoDecoderConfig::IsValidConfig(). 98 // automatically by VideoDecoderConfig::IsValidConfig().
98 static bool IsValidConfig(VideoPixelFormat format, 99 static bool IsValidConfig(VideoPixelFormat format,
99 StorageType storage_type, 100 StorageType storage_type,
100 const gfx::Size& coded_size, 101 const gfx::Size& coded_size,
101 const gfx::Rect& visible_rect, 102 const gfx::Rect& visible_rect,
102 const gfx::Size& natural_size); 103 const gfx::Size& natural_size);
103 104
(...skipping 13 matching lines...) Expand all
117 static scoped_refptr<VideoFrame> CreateZeroInitializedFrame( 118 static scoped_refptr<VideoFrame> CreateZeroInitializedFrame(
118 VideoPixelFormat format, 119 VideoPixelFormat format,
119 const gfx::Size& coded_size, 120 const gfx::Size& coded_size,
120 const gfx::Rect& visible_rect, 121 const gfx::Rect& visible_rect,
121 const gfx::Size& natural_size, 122 const gfx::Size& natural_size,
122 base::TimeDelta timestamp); 123 base::TimeDelta timestamp);
123 124
124 // Wraps a native texture of the given parameters with a VideoFrame. 125 // Wraps a native texture of the given parameters with a VideoFrame.
125 // The backing of the VideoFrame is held in the mailbox held by 126 // The backing of the VideoFrame is held in the mailbox held by
126 // |mailbox_holder|, and |mailbox_holder_release_cb| will be called with 127 // |mailbox_holder|, and |mailbox_holder_release_cb| will be called with
127 // a syncpoint as the argument when the VideoFrame is to be destroyed. 128 // a sync token as the argument when the VideoFrame is to be destroyed.
128 static scoped_refptr<VideoFrame> WrapNativeTexture( 129 static scoped_refptr<VideoFrame> WrapNativeTexture(
129 VideoPixelFormat format, 130 VideoPixelFormat format,
130 const gpu::MailboxHolder& mailbox_holder, 131 const gpu::MailboxHolder& mailbox_holder,
131 const ReleaseMailboxCB& mailbox_holder_release_cb, 132 const ReleaseMailboxCB& mailbox_holder_release_cb,
132 const gfx::Size& coded_size, 133 const gfx::Size& coded_size,
133 const gfx::Rect& visible_rect, 134 const gfx::Rect& visible_rect,
134 const gfx::Size& natural_size, 135 const gfx::Size& natural_size,
135 base::TimeDelta timestamp); 136 base::TimeDelta timestamp);
136 137
137 // Wraps a set of native textures representing YUV data with a VideoFrame. 138 // Wraps a set of native textures representing YUV data with a VideoFrame.
138 // |mailbox_holders_release_cb| will be called with a syncpoint as the 139 // |mailbox_holders_release_cb| will be called with a sync token as the
139 // argument when the VideoFrame is to be destroyed. 140 // argument when the VideoFrame is to be destroyed.
140 static scoped_refptr<VideoFrame> WrapYUV420NativeTextures( 141 static scoped_refptr<VideoFrame> WrapYUV420NativeTextures(
141 const gpu::MailboxHolder& y_mailbox_holder, 142 const gpu::MailboxHolder& y_mailbox_holder,
142 const gpu::MailboxHolder& u_mailbox_holder, 143 const gpu::MailboxHolder& u_mailbox_holder,
143 const gpu::MailboxHolder& v_mailbox_holder, 144 const gpu::MailboxHolder& v_mailbox_holder,
144 const ReleaseMailboxCB& mailbox_holders_release_cb, 145 const ReleaseMailboxCB& mailbox_holders_release_cb,
145 const gfx::Size& coded_size, 146 const gfx::Size& coded_size,
146 const gfx::Rect& visible_rect, 147 const gfx::Rect& visible_rect,
147 const gfx::Size& natural_size, 148 const gfx::Size& natural_size,
148 base::TimeDelta timestamp); 149 base::TimeDelta timestamp);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // See VideoFrameMetadata::REFERENCE_TIME for details. 378 // See VideoFrameMetadata::REFERENCE_TIME for details.
378 base::TimeDelta timestamp() const { return timestamp_; } 379 base::TimeDelta timestamp() const { return timestamp_; }
379 void set_timestamp(base::TimeDelta timestamp) { 380 void set_timestamp(base::TimeDelta timestamp) {
380 timestamp_ = timestamp; 381 timestamp_ = timestamp;
381 } 382 }
382 383
383 // It uses |client| to insert a new sync point and potentially waits on a 384 // It uses |client| to insert a new sync point and potentially waits on a
384 // older sync point. The final sync point will be used to release this 385 // older sync point. The final sync point will be used to release this
385 // VideoFrame. 386 // VideoFrame.
386 // This method is thread safe. Both blink and compositor threads can call it. 387 // This method is thread safe. Both blink and compositor threads can call it.
387 void UpdateReleaseSyncPoint(SyncPointClient* client); 388 void UpdateReleaseSyncToken(SyncTokenClient* client);
388 389
389 private: 390 private:
390 friend class base::RefCountedThreadSafe<VideoFrame>; 391 friend class base::RefCountedThreadSafe<VideoFrame>;
391 392
392 static scoped_refptr<VideoFrame> WrapExternalStorage( 393 static scoped_refptr<VideoFrame> WrapExternalStorage(
393 VideoPixelFormat format, 394 VideoPixelFormat format,
394 StorageType storage_type, 395 StorageType storage_type,
395 const gfx::Size& coded_size, 396 const gfx::Size& coded_size,
396 const gfx::Rect& visible_rect, 397 const gfx::Rect& visible_rect,
397 const gfx::Size& natural_size, 398 const gfx::Size& natural_size,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 485
485 #if defined(OS_MACOSX) 486 #if defined(OS_MACOSX)
486 // CVPixelBuffer, if this frame is wrapping one. 487 // CVPixelBuffer, if this frame is wrapping one.
487 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; 488 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_;
488 #endif 489 #endif
489 490
490 std::vector<base::Closure> done_callbacks_; 491 std::vector<base::Closure> done_callbacks_;
491 492
492 base::TimeDelta timestamp_; 493 base::TimeDelta timestamp_;
493 494
494 base::Lock release_sync_point_lock_; 495 base::Lock release_sync_token_lock_;
495 uint32 release_sync_point_; 496 gpu::SyncToken release_sync_token_;
496 497
497 VideoFrameMetadata metadata_; 498 VideoFrameMetadata metadata_;
498 499
499 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 500 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
500 }; 501 };
501 502
502 } // namespace media 503 } // namespace media
503 504
504 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 505 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698