Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ |
| 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "webrtc/base/constructormagic.h" | 16 #include "webrtc/base/constructormagic.h" |
| 17 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 17 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
| 18 #include "webrtc/modules/desktop_capture/desktop_region.h" | 18 #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 19 #include "webrtc/modules/desktop_capture/rgba_color.h" | |
| 19 #include "webrtc/modules/desktop_capture/shared_memory.h" | 20 #include "webrtc/modules/desktop_capture/shared_memory.h" |
| 20 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
| 21 | 22 |
| 22 namespace webrtc { | 23 namespace webrtc { |
| 23 | 24 |
| 24 // DesktopFrame represents a video frame captured from the screen. | 25 // DesktopFrame represents a video frame captured from the screen. |
| 25 class DesktopFrame { | 26 class DesktopFrame { |
| 26 public: | 27 public: |
| 27 // DesktopFrame objects always hold RGBA data. | 28 // DesktopFrame objects always hold RGBA data. |
| 28 static const int kBytesPerPixel = 4; | 29 static const int kBytesPerPixel = 4; |
| 30 static_assert(kBytesPerPixel == sizeof(RgbaColor), | |
| 31 "A pixel in DesktopFrame should be safe to be represented by a " | |
| 32 "RgbaColor"); | |
| 29 | 33 |
| 30 virtual ~DesktopFrame(); | 34 virtual ~DesktopFrame(); |
| 31 | 35 |
| 32 // Size of the frame. | 36 // Size of the frame. |
| 33 const DesktopSize& size() const { return size_; } | 37 const DesktopSize& size() const { return size_; } |
| 34 | 38 |
| 35 // Distance in the buffer between two neighboring rows in bytes. | 39 // Distance in the buffer between two neighboring rows in bytes. |
| 36 int stride() const { return stride_; } | 40 int stride() const { return stride_; } |
| 37 | 41 |
| 38 // Data buffer used for the frame. | 42 // Data buffer used for the frame. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 61 void CopyPixelsFrom(const uint8_t* src_buffer, | 65 void CopyPixelsFrom(const uint8_t* src_buffer, |
| 62 int src_stride, | 66 int src_stride, |
| 63 const DesktopRect& dest_rect); | 67 const DesktopRect& dest_rect); |
| 64 void CopyPixelsFrom(const DesktopFrame& src_frame, | 68 void CopyPixelsFrom(const DesktopFrame& src_frame, |
| 65 const DesktopVector& src_pos, | 69 const DesktopVector& src_pos, |
| 66 const DesktopRect& dest_rect); | 70 const DesktopRect& dest_rect); |
| 67 | 71 |
| 68 // A helper to return the data pointer of a frame at the specified position. | 72 // A helper to return the data pointer of a frame at the specified position. |
| 69 uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const; | 73 uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const; |
| 70 | 74 |
| 75 // Whether current instance equals to the |other| in both size() and data(). | |
| 76 bool DataEquals(const DesktopFrame& other) const; | |
| 77 | |
| 78 // Paints the pixel at |pos| with |color|. This should be for test purpose | |
| 79 // only. This function triggers check failure if pos is out of current | |
| 80 // DesktopFrame. | |
| 81 void Paint(DesktopVector pos, RgbaColor color); | |
|
Sergey Ulanov
2016/11/15 02:28:10
Do we really need this function here? RgbaColor is
Hzj_jie
2016/11/15 05:17:02
Sure. Updated.
| |
| 82 | |
| 83 // Clears DesktopFrame by set entire data() buffer into 0. This should be for | |
| 84 // test purpose only. | |
| 85 void Clear(); | |
| 86 | |
| 71 protected: | 87 protected: |
| 72 DesktopFrame(DesktopSize size, | 88 DesktopFrame(DesktopSize size, |
| 73 int stride, | 89 int stride, |
| 74 uint8_t* data, | 90 uint8_t* data, |
| 75 SharedMemory* shared_memory); | 91 SharedMemory* shared_memory); |
| 76 | 92 |
| 77 // Ownership of the buffers is defined by the classes that inherit from this | 93 // Ownership of the buffers is defined by the classes that inherit from this |
| 78 // class. They must guarantee that the buffer is not deleted before the frame | 94 // class. They must guarantee that the buffer is not deleted before the frame |
| 79 // is deleted. | 95 // is deleted. |
| 80 uint8_t* const data_; | 96 uint8_t* const data_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 ~SharedMemoryDesktopFrame() override; | 140 ~SharedMemoryDesktopFrame() override; |
| 125 | 141 |
| 126 private: | 142 private: |
| 127 RTC_DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame); | 143 RTC_DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame); |
| 128 }; | 144 }; |
| 129 | 145 |
| 130 } // namespace webrtc | 146 } // namespace webrtc |
| 131 | 147 |
| 132 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ | 148 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ |
| 133 | 149 |
| OLD | NEW |