OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_COMMON_GPU_SURFACE_CAPTURER_H_ |
| 6 #define CONTENT_COMMON_GPU_SURFACE_CAPTURER_H_ |
| 7 |
| 8 #include "content/common/content_export.h" |
| 9 #include "media/base/video_frame.h" |
| 10 |
| 11 namespace gfx { |
| 12 |
| 13 class Size; |
| 14 class Rect; |
| 15 |
| 16 }; // namespace ui |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // Surface capturer interface. This interface is implemented by classes |
| 21 // that perform image capturing from the backbuffer. |
| 22 class CONTENT_EXPORT SurfaceCapturer { |
| 23 public: |
| 24 enum Error { |
| 25 // Invalid argument was passed to an API method. |
| 26 kInvalidArgumentError, |
| 27 // A failure occurred at the GPU process or one of its dependencies. |
| 28 // Examples of such failures include GPU hardware failures, GPU driver |
| 29 // failures, GPU library failures, GPU process programming errors, and so |
| 30 // on. |
| 31 kPlatformFailureError, |
| 32 }; |
| 33 |
| 34 class CONTENT_EXPORT Client { |
| 35 public: |
| 36 // Callback to notify client of parameters of the backbuffer capture. Every |
| 37 // time the Client receivce this callback, subsequent media::VideoFrames |
| 38 // passed to Capture() should mind the new parameters. |
| 39 // Parameters: |
| 40 // |buffer_size| is the required logical size (in pixels) of the buffer |
| 41 // to capture to (corresponds to |frame->coded_size()| from in Capture(). |
| 42 // |visible_rect| is the visible subrect of the actual screen capture |
| 43 // contents in the buffer to capture to (corresponds to |
| 44 // |frame->visible_rect()| in Capture(). |
| 45 virtual void NotifyCaptureParameters(const gfx::Size& buffer_size, |
| 46 const gfx::Rect& visible_rect) = 0; |
| 47 |
| 48 // Error notification callback. |
| 49 // Parameters: |
| 50 // |error| is the error to report. |
| 51 virtual void NotifyError(Error error) = 0; |
| 52 |
| 53 protected: |
| 54 // Clients are not owned by Capturer instances and should not be deleted |
| 55 // through these pointers. |
| 56 virtual ~Client() {} |
| 57 }; |
| 58 |
| 59 // Initialize the capturer to a specific configuration. |
| 60 // Parameters: |
| 61 // |format| is the format to capture to (corresponds to |frame->format()| in |
| 62 // Capture()). |
| 63 virtual void Initialize(media::VideoFrame::Format format) = 0; |
| 64 |
| 65 // Capture a frame. |
| 66 // Parameters: |
| 67 // |frame| is the frame holding the buffer to capture to. |
| 68 virtual void Capture(const scoped_refptr<media::VideoFrame>& frame) = 0; |
| 69 |
| 70 // Destroys the capturer; all pending inputs and outputs are dropped |
| 71 // immediately and the component is freed. This call may asynchronously free |
| 72 // system resources, but its client-visible effects are synchronous. After |
| 73 // this method returns no more callbacks will be made on the client. Deletes |
| 74 // |this| unconditionally, so make sure to drop all pointers to it! |
| 75 virtual void Destroy() = 0; |
| 76 |
| 77 virtual ~SurfaceCapturer(); |
| 78 }; |
| 79 |
| 80 } // namespace content |
| 81 |
| 82 #endif // CONTENT_COMMON_GPU_SURFACE_CAPTURER_H_ |
OLD | NEW |