OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_UTIL_H_ | 5 #ifndef REMOTING_BASE_UTIL_H_ |
6 #define REMOTING_BASE_UTIL_H_ | 6 #define REMOTING_BASE_UTIL_H_ |
7 | 7 |
8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
9 #include "third_party/skia/include/core/SkRect.h" | 9 #include "third_party/skia/include/core/SkRect.h" |
10 #include "ui/gfx/rect.h" | |
11 | 10 |
12 namespace remoting { | 11 namespace remoting { |
13 | 12 |
14 std::string GetTimestampString(); | 13 std::string GetTimestampString(); |
15 | 14 |
16 // TODO(sergeyu): Move these methods to media. | 15 // TODO(sergeyu): Move these methods to media. |
17 int GetBytesPerPixel(media::VideoFrame::Format format); | 16 int GetBytesPerPixel(media::VideoFrame::Format format); |
18 | 17 |
19 // Convert YUV to RGB32 on a specific rectangle. | 18 // Convert YUV to RGB32 on a specific rectangle. |
20 void ConvertYUVToRGB32WithRect(const uint8* y_plane, | 19 void ConvertYUVToRGB32WithRect(const uint8* y_plane, |
21 const uint8* u_plane, | 20 const uint8* u_plane, |
22 const uint8* v_plane, | 21 const uint8* v_plane, |
23 uint8* rgb_plane, | 22 uint8* rgb_plane, |
24 const gfx::Rect& rect, | 23 const SkIRect& rect, |
25 int y_stride, | 24 int y_stride, |
26 int uv_stride, | 25 int uv_stride, |
27 int rgb_stride); | 26 int rgb_stride); |
28 | 27 |
29 void ScaleYUVToRGB32WithRect(const uint8* y_plane, | 28 void ScaleYUVToRGB32WithRect(const uint8* y_plane, |
30 const uint8* u_plane, | 29 const uint8* u_plane, |
31 const uint8* v_plane, | 30 const uint8* v_plane, |
32 uint8* rgb_plane, | 31 uint8* rgb_plane, |
33 const gfx::Rect& source_rect, | 32 const SkIRect& source_rect, |
34 const gfx::Rect& dest_rect, | 33 const SkIRect& dest_rect, |
35 int y_stride, | 34 int y_stride, |
36 int uv_stride, | 35 int uv_stride, |
37 int rgb_stride); | 36 int rgb_stride); |
38 | 37 |
39 void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane, | 38 void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane, |
40 uint8* y_plane, | 39 uint8* y_plane, |
41 uint8* u_plane, | 40 uint8* u_plane, |
42 uint8* v_plane, | 41 uint8* v_plane, |
43 int x, | 42 int x, |
44 int y, | 43 int y, |
45 int width, | 44 int width, |
46 int height, | 45 int height, |
47 int rgb_stride, | 46 int rgb_stride, |
48 int y_stride, | 47 int y_stride, |
49 int uv_stride); | 48 int uv_stride); |
50 | 49 |
51 int RoundToTwosMultiple(int x); | 50 int RoundToTwosMultiple(int x); |
52 | 51 |
53 // Align the sides of the rectangle to multiples of 2 (expanding outwards). | 52 // Align the sides of the rectangle to multiples of 2 (expanding outwards). |
54 gfx::Rect AlignRect(const gfx::Rect& rect); | 53 SkIRect AlignRect(const SkIRect& rect); |
55 | 54 |
56 // Return a scaled rectangle using the horizontal and vertical scale | 55 // Return a scaled rectangle using the horizontal and vertical scale |
57 // factors. | 56 // factors. |
58 gfx::Rect ScaleRect(const gfx::Rect& rect, | 57 SkIRect ScaleRect(const SkIRect& rect, |
59 double horizontal_ratio, | 58 double horizontal_ratio, |
60 double vertical_ratio); | 59 double vertical_ratio); |
61 | 60 |
62 // Copy pixels in the rectangle from source to destination. | 61 // Copy pixels in the rectangle from source to destination. |
63 void CopyRect(const uint8* src_plane, | 62 void CopyRect(const uint8* src_plane, |
64 int src_plane_stride, | 63 int src_plane_stride, |
65 uint8* dest_plane, | 64 uint8* dest_plane, |
66 int dest_plane_stride, | 65 int dest_plane_stride, |
67 int bytes_per_pixel, | 66 int bytes_per_pixel, |
68 const SkIRect& rect); | 67 const SkIRect& rect); |
69 | 68 |
70 } // namespace remoting | 69 } // namespace remoting |
71 | 70 |
72 #endif // REMOTING_BASE_UTIL_H_ | 71 #endif // REMOTING_BASE_UTIL_H_ |
OLD | NEW |