| OLD | NEW |
| 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 REMOTING_CLIENT_FRAME_CONSUMER_H_ | 5 #ifndef REMOTING_CLIENT_FRAME_CONSUMER_H_ |
| 6 #define REMOTING_CLIENT_FRAME_CONSUMER_H_ | 6 #define REMOTING_CLIENT_FRAME_CONSUMER_H_ |
| 7 | 7 |
| 8 #include "remoting/base/decoder.h" // For UpdatedRects | 8 #include "third_party/skia/include/core/SkRect.h" |
| 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "third_party/skia/include/core/SkSize.h" |
| 11 |
| 12 namespace pp { |
| 13 class ImageData; |
| 14 } // namespace pp |
| 9 | 15 |
| 10 namespace remoting { | 16 namespace remoting { |
| 11 | 17 |
| 12 class FrameConsumer { | 18 class FrameConsumer { |
| 13 public: | 19 public: |
| 14 FrameConsumer() {} | 20 FrameConsumer() {} |
| 15 virtual ~FrameConsumer() {} | 21 virtual ~FrameConsumer() {} |
| 16 | 22 |
| 17 // Request a frame be allocated from the FrameConsumer. | 23 // Accepts a buffer to be painted to the screen. The buffer's dimensions and |
| 24 // relative position within the frame are specified by |clip_area|. Only |
| 25 // pixels falling within |region| and the current clipping area are painted. |
| 26 // The function assumes that the passed buffer was scaled to fit a window |
| 27 // having |view_size| dimensions. |
| 18 // | 28 // |
| 19 // If a frame cannot be allocated to fit the format, and |size| | 29 // N.B. Both |clip_area| and |region| are in output coordinates relative to |
| 20 // requirements, |frame_out| will be set to NULL. | 30 // the frame. |
| 21 // | 31 virtual void ApplyBuffer(const SkISize& view_size, |
| 22 // An allocated frame will have at least the |size| requested, but | 32 const SkIRect& clip_area, |
| 23 // may be bigger. Query the retrun frame for the actual frame size, | 33 pp::ImageData* buffer, |
| 24 // stride, etc. | 34 const SkRegion& region) = 0; |
| 25 // | |
| 26 // The AllocateFrame call is asynchronous. From invocation, until when the | |
| 27 // |done| callback is invoked, |frame_out| should be considered to be locked | |
| 28 // by the FrameConsumer, must remain a valid pointer, and should not be | |
| 29 // examined or modified. After |done| is called, the |frame_out| will | |
| 30 // contain a result of the allocation. If a frame could not be allocated, | |
| 31 // |frame_out| will be NULL. | |
| 32 // | |
| 33 // All frames retrieved via the AllocateFrame call must be released by a | |
| 34 // corresponding call ReleaseFrame(scoped_refptr<VideoFrame>* frame_out. | |
| 35 virtual void AllocateFrame(media::VideoFrame::Format format, | |
| 36 const SkISize& size, | |
| 37 scoped_refptr<media::VideoFrame>* frame_out, | |
| 38 const base::Closure& done) = 0; | |
| 39 | 35 |
| 40 virtual void ReleaseFrame(media::VideoFrame* frame) = 0; | 36 // Accepts a buffer that couldn't be used for drawing for any reason (shutdown |
| 37 // is in progress, the view area has changed, etc.). The accepted buffer can |
| 38 // be freed or reused for another drawing operation. |
| 39 virtual void ReturnBuffer(pp::ImageData* buffer) = 0; |
| 41 | 40 |
| 42 // OnPartialFrameOutput() is called every time at least one rectangle of | 41 // Set the dimension of the entire host screen. |
| 43 // output is produced. The |frame| is guaranteed to have valid data for all | 42 virtual void SetSourceSize(const SkISize& source_size) = 0; |
| 44 // of |region|. | |
| 45 // | |
| 46 // Both |frame| and |region| are guaranteed to be valid until the |done| | |
| 47 // callback is invoked. | |
| 48 virtual void OnPartialFrameOutput(media::VideoFrame* frame, | |
| 49 SkRegion* region, | |
| 50 const base::Closure& done) = 0; | |
| 51 | 43 |
| 52 private: | 44 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(FrameConsumer); | 45 DISALLOW_COPY_AND_ASSIGN(FrameConsumer); |
| 54 }; | 46 }; |
| 55 | 47 |
| 56 } // namespace remoting | 48 } // namespace remoting |
| 57 | 49 |
| 58 #endif // REMOTING_CLIENT_FRAME_CONSUMER_H_ | 50 #endif // REMOTING_CLIENT_FRAME_CONSUMER_H_ |
| OLD | NEW |