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

Side by Side Diff: cc/layers/video_frame_provider.h

Issue 1083683003: Speculative revert by sheriff (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed an unrelated commit that had accidentally slipped in. Created 5 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
« no previous file with comments | « cc/layers/picture_layer_unittest.cc ('k') | cc/layers/video_frame_provider_client_impl.h » ('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 (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 CC_LAYERS_VIDEO_FRAME_PROVIDER_H_ 5 #ifndef CC_LAYERS_VIDEO_FRAME_PROVIDER_H_
6 #define CC_LAYERS_VIDEO_FRAME_PROVIDER_H_ 6 #define CC_LAYERS_VIDEO_FRAME_PROVIDER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10 #include "cc/base/cc_export.h" 9 #include "cc/base/cc_export.h"
11 10
12 namespace media { 11 namespace media {
13 class VideoFrame; 12 class VideoFrame;
14 } 13 }
15 14
16 namespace cc { 15 namespace cc {
17 16
18 // VideoFrameProvider and VideoFrameProvider::Client define the relationship by 17 // Threading notes: This class may be used in a multi threaded manner.
19 // which video frames are exchanged between a provider and client. 18 // Specifically, the implementation may call GetCurrentFrame() or
20 // 19 // PutCurrentFrame() from the compositor thread. If so, the caller is
21 // Threading notes: This class may be used in a multithreaded manner. However, 20 // responsible for making sure Client::DidReceiveFrame() and
22 // if the Client implementation calls GetCurrentFrame()/PutCurrentFrame() from 21 // Client::DidUpdateMatrix() are only called from this same thread.
23 // one thread, the provider must ensure that all client methods (except
24 // StopUsingProvider()) are called from that thread (typically the compositor
25 // thread).
26 class CC_EXPORT VideoFrameProvider { 22 class CC_EXPORT VideoFrameProvider {
27 public: 23 public:
24 virtual ~VideoFrameProvider() {}
25
28 class CC_EXPORT Client { 26 class CC_EXPORT Client {
29 public: 27 public:
30 // The provider will call this method to tell the client to stop using it. 28 // Provider will call this method to tell the client to stop using it.
31 // StopUsingProvider() may be called from any thread. The client should 29 // StopUsingProvider() may be called from any thread. The client should
32 // block until it has PutCurrentFrame() any outstanding frames. 30 // block until it has PutCurrentFrame() any outstanding frames.
33 virtual void StopUsingProvider() = 0; 31 virtual void StopUsingProvider() = 0;
34 32
35 // Notifies the client that it should start or stop making regular 33 // Notifies the provider's client that a call to GetCurrentFrame() will
36 // UpdateCurrentFrame() calls to the provider. No further calls to 34 // return new data.
37 // UpdateCurrentFrame() should be made once StopRendering() returns.
38 //
39 // Callers should use these methods to indicate when it expects and no
40 // longer expects (respectively) to have new frames for the client. Clients
41 // may use this information for power conservation.
42 virtual void StartRendering() = 0;
43 virtual void StopRendering() = 0;
44
45 // Notifies the client that GetCurrentFrame() will return new data.
46 // TODO(dalecurtis): Nuke this once VideoFrameProviderClientImpl is using a
47 // BeginFrameObserver based approach. http://crbug.com/336733
48 virtual void DidReceiveFrame() = 0; 35 virtual void DidReceiveFrame() = 0;
49 36
50 // Notifies the client of a new UV transform matrix to be used. 37 // Notifies the provider's client of a new UV transform matrix to be used.
51 virtual void DidUpdateMatrix(const float* matrix) = 0; 38 virtual void DidUpdateMatrix(const float* matrix) = 0;
52 39
53 protected: 40 protected:
54 virtual ~Client() {} 41 virtual ~Client() {}
55 }; 42 };
56 43
57 // May be called from any thread, but there must be some external guarantee 44 // May be called from any thread, but there must be some external guarantee
58 // that the provider is not destroyed before this call returns. 45 // that the provider is not destroyed before this call returns.
59 virtual void SetVideoFrameProviderClient(Client* client) = 0; 46 virtual void SetVideoFrameProviderClient(Client* client) = 0;
60 47
61 // Called by the client on a regular interval. Returns true if a new frame 48 // This function places a lock on the current frame and returns a pointer to
62 // will be available via GetCurrentFrame() which should be displayed within 49 // it. Calls to this method should always be followed with a call to
63 // the presentation interval [|deadline_min|, |deadline_max|]. 50 // PutCurrentFrame().
64 // 51 // Only the current provider client should call this function.
65 // Implementations may use this to drive frame acquisition from underlying
66 // sources, so it must be called by clients before calling GetCurrentFrame().
67 virtual bool UpdateCurrentFrame(base::TimeTicks deadline_min,
68 base::TimeTicks deadline_max) = 0;
69
70 // Returns the current frame, which may have been updated by a recent call to
71 // UpdateCurrentFrame(). A call to this method does not ensure that the frame
72 // will be rendered. A subsequent call to PutCurrentFrame() must be made if
73 // the frame is expected to be rendered.
74 //
75 // Clients should call this in response to UpdateCurrentFrame() returning true
76 // or in response to a DidReceiveFrame() call.
77 //
78 // TODO(dalecurtis): Remove text about DidReceiveFrame() once the old path
79 // has been removed. http://crbug.com/439548
80 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() = 0; 52 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() = 0;
81 53
82 // Indicates that the last frame returned via GetCurrentFrame() is expected to 54 // This function releases the lock on the video frame. It should always be
83 // be rendered. Must only occur after a previous call to GetCurrentFrame(). 55 // called after GetCurrentFrame(). Frames passed into this method
84 virtual void PutCurrentFrame() = 0; 56 // should no longer be referenced after the call is made. Only the current
85 57 // provider client should call this function.
86 protected: 58 virtual void PutCurrentFrame(
87 virtual ~VideoFrameProvider() {} 59 const scoped_refptr<media::VideoFrame>& frame) = 0;
88 }; 60 };
89 61
90 } // namespace cc 62 } // namespace cc
91 63
92 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_H_ 64 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_unittest.cc ('k') | cc/layers/video_frame_provider_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698