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

Side by Side Diff: trunk/src/remoting/base/util.h

Issue 24217003: Revert 224101 "Remove dependency on Skia from chromoting client." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/remoting/DEPS ('k') | trunk/src/remoting/base/util.cc » ('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 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 <string> 8 #include <string>
9 9
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 11 #include "third_party/skia/include/core/SkRect.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 14
15 // Return a string that contains the current date formatted as 'MMDD/HHMMSS:'. 15 // Return a string that contains the current date formatted as 'MMDD/HHMMSS:'.
16 std::string GetTimestampString(); 16 std::string GetTimestampString();
17 17
18 // Calculate the offset of a specific pixel in an RGB32 buffer. 18 // Calculate the offset of a specific pixel in an RGB32 buffer.
19 int CalculateRGBOffset(int x, int y, int stride); 19 int CalculateRGBOffset(int x, int y, int stride);
20 20
21 // Calculate the offset of a specific pixel in a YV12/YUV420 buffer. Note that 21 // Calculate the offset of a specific pixel in a YV12/YUV420 buffer. Note that
22 // the X and Y coordinates must both be even owing to the YV12 buffer layout. 22 // the X and Y coordinates must both be even owing to the YV12 buffer layout.
23 int CalculateYOffset(int x, int y, int stride); 23 int CalculateYOffset(int x, int y, int stride);
24 int CalculateUVOffset(int x, int y, int stride); 24 int CalculateUVOffset(int x, int y, int stride);
25 25
26 // Convert and scale YUV to RGB32 on a specific rectangle. The source and 26 // Convert and scale YUV to RGB32 on a specific rectangle. The source and
27 // destination buffers are assumed to contain only |source_buffer_rect| and 27 // destination buffers are assumed to contain only |source_buffer_rect| and
28 // |dest_buffer_rect| areas correspondingly. The scaling factor is determined 28 // |dest_buffer_rect| areas correspondingly. The scaling factor is determined
29 // as ratio between |dest_size| and |source_size|. The target rectangle 29 // as ratio between |dest_size| and |source_size|. The target rectangle
30 // |dect_rect| is specified in the destination coordinates. 30 // |dect_rect| is specified in the destination coordinates.
31 // 31 //
32 // |source_buffer_rect| and |dest_buffer_rect| must fall entirely within 32 // |source_buffer_rect| and |dest_buffer_rect| must fall entirely within
33 // the source and destination dimensions, respectively. |dest_rect| must be 33 // the source and destination dimensions, respectively. |dest_rect| must be
34 // completely contained within the source and destinations buffers boundaries 34 // completely contained within the source and destinations buffers boundaries
35 // including the case when scaling is requested. 35 // including the case when scaling is requested.
36 // 36 //
37 // N.B. The top left corner coordinates of YUV buffer should have even X and Y 37 // N.B. The top left corner coordinates of YUV buffer should have even X and Y
38 // coordinates. 38 // coordinates.
39 void ConvertAndScaleYUVToRGB32Rect( 39 void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
40 const uint8* source_yplane, 40 const uint8* source_uplane,
41 const uint8* source_uplane, 41 const uint8* source_vplane,
42 const uint8* source_vplane, 42 int source_ystride,
43 int source_ystride, 43 int source_uvstride,
44 int source_uvstride, 44 const SkISize& source_size,
45 const webrtc::DesktopSize& source_size, 45 const SkIRect& source_buffer_rect,
46 const webrtc::DesktopRect& source_buffer_rect, 46 uint8* dest_buffer,
47 uint8* dest_buffer, 47 int dest_stride,
48 int dest_stride, 48 const SkISize& dest_size,
49 const webrtc::DesktopSize& dest_size, 49 const SkIRect& dest_buffer_rect,
50 const webrtc::DesktopRect& dest_buffer_rect, 50 const SkIRect& dest_rect);
51 const webrtc::DesktopRect& dest_rect);
52 51
53 // Convert RGB32 to YUV on a specific rectangle. 52 // Convert RGB32 to YUV on a specific rectangle.
54 void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane, 53 void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
55 uint8* y_plane, 54 uint8* y_plane,
56 uint8* u_plane, 55 uint8* u_plane,
57 uint8* v_plane, 56 uint8* v_plane,
58 int x, 57 int x,
59 int y, 58 int y,
60 int width, 59 int width,
61 int height, 60 int height,
62 int rgb_stride, 61 int rgb_stride,
63 int y_stride, 62 int y_stride,
64 int uv_stride); 63 int uv_stride);
65 64
66 int RoundToTwosMultiple(int x); 65 int RoundToTwosMultiple(int x);
67 66
68 // Align the sides of the rectangle to multiples of 2 (expanding outwards). 67 // Align the sides of the rectangle to multiples of 2 (expanding outwards).
69 webrtc::DesktopRect AlignRect(const webrtc::DesktopRect& rect); 68 SkIRect AlignRect(const SkIRect& rect);
70 69
71 // Scales the supplied rectangle from |in_size| coordinates to |out_size|. 70 // Scales the supplied rectangle from |in_size| coordinates to |out_size|.
72 // If the result has non-integer coordinates then the smallest integer- 71 // If the result has non-integer coordinates then the smallest integer-
73 // coordinate rectangle that wholly encloses it is returned. 72 // coordinate rectangle that wholly encloses it is returned.
74 webrtc::DesktopRect ScaleRect(const webrtc::DesktopRect& rect, 73 SkIRect ScaleRect(const SkIRect& rect,
75 const webrtc::DesktopSize& in_size, 74 const SkISize& in_size,
76 const webrtc::DesktopSize& out_size); 75 const SkISize& out_size);
77 76
78 // Copy content of a rectangle in a RGB32 image. 77 // Copy content of a rectangle in a RGB32 image.
79 void CopyRGB32Rect(const uint8* source_buffer, 78 void CopyRGB32Rect(const uint8* source_buffer,
80 int source_stride, 79 int source_stride,
81 const webrtc::DesktopRect& source_buffer_rect, 80 const SkIRect& source_buffer_rect,
82 uint8* dest_buffer, 81 uint8* dest_buffer,
83 int dest_stride, 82 int dest_stride,
84 const webrtc::DesktopRect& dest_buffer_rect, 83 const SkIRect& dest_buffer_rect,
85 const webrtc::DesktopRect& dest_rect); 84 const SkIRect& dest_rect);
86 85
87 // Replaces every occurrence of "\n" in a string by "\r\n". 86 // Replaces every occurrence of "\n" in a string by "\r\n".
88 std::string ReplaceLfByCrLf(const std::string& in); 87 std::string ReplaceLfByCrLf(const std::string& in);
89 88
90 // Replaces every occurrence of "\r\n" in a string by "\n". 89 // Replaces every occurrence of "\r\n" in a string by "\n".
91 std::string ReplaceCrLfByLf(const std::string& in); 90 std::string ReplaceCrLfByLf(const std::string& in);
92 91
93 // Checks if the given string is a valid UTF-8 string. 92 // Checks if the given string is a valid UTF-8 string.
94 bool StringIsUtf8(const char* data, size_t length); 93 bool StringIsUtf8(const char* data, size_t length);
95 94
96 // Returns the username associated with this process, or the empty string on 95 // Returns the username associated with this process, or the empty string on
97 // error or if not implemented. 96 // error or if not implemented.
98 std::string GetUsername(); 97 std::string GetUsername();
99 98
100 bool DoesRectContain(const webrtc::DesktopRect& a,
101 const webrtc::DesktopRect& b);
102
103 } // namespace remoting 99 } // namespace remoting
104 100
105 #endif // REMOTING_BASE_UTIL_H_ 101 #endif // REMOTING_BASE_UTIL_H_
OLDNEW
« no previous file with comments | « trunk/src/remoting/DEPS ('k') | trunk/src/remoting/base/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698