blob: 5fca203bf294695c6ce0b3e5d29cbae5f5fc435f [file] [log] [blame]
[email protected]a101cf32012-01-14 00:34:231// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c3af26f332010-10-06 22:46:002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef REMOTING_BASE_UTIL_H_
6#define REMOTING_BASE_UTIL_H_
7
[email protected]82156e82011-12-20 07:09:018#include <string>
9
[email protected]3adf1b22010-11-09 23:22:2010#include "media/base/video_frame.h"
[email protected]dc454a7c2011-08-12 22:01:1311#include "third_party/skia/include/core/SkRect.h"
[email protected]c3af26f332010-10-06 22:46:0012
13namespace remoting {
14
[email protected]a101cf32012-01-14 00:34:2315// Return a string that contains the current date formatted as 'MMDD/HHMMSS:'.
[email protected]82d105e2011-08-04 03:19:3516std::string GetTimestampString();
17
[email protected]50686142011-02-04 02:08:3218// TODO(sergeyu): Move these methods to media.
[email protected]3adf1b22010-11-09 23:22:2019int GetBytesPerPixel(media::VideoFrame::Format format);
[email protected]c3af26f332010-10-06 22:46:0020
[email protected]50686142011-02-04 02:08:3221// Convert YUV to RGB32 on a specific rectangle.
22void ConvertYUVToRGB32WithRect(const uint8* y_plane,
23 const uint8* u_plane,
24 const uint8* v_plane,
25 uint8* rgb_plane,
[email protected]bcad2682011-09-30 20:35:2626 const SkIRect& rect,
[email protected]50686142011-02-04 02:08:3227 int y_stride,
28 int uv_stride,
29 int rgb_stride);
30
[email protected]47379e92011-07-26 15:33:1531void ScaleYUVToRGB32WithRect(const uint8* y_plane,
32 const uint8* u_plane,
33 const uint8* v_plane,
34 uint8* rgb_plane,
[email protected]bcad2682011-09-30 20:35:2635 const SkIRect& source_rect,
36 const SkIRect& dest_rect,
[email protected]47379e92011-07-26 15:33:1537 int y_stride,
38 int uv_stride,
39 int rgb_stride);
40
[email protected]50686142011-02-04 02:08:3241void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
42 uint8* y_plane,
43 uint8* u_plane,
44 uint8* v_plane,
45 int x,
46 int y,
47 int width,
48 int height,
49 int rgb_stride,
50 int y_stride,
51 int uv_stride);
52
[email protected]47379e92011-07-26 15:33:1553int RoundToTwosMultiple(int x);
54
55// Align the sides of the rectangle to multiples of 2 (expanding outwards).
[email protected]bcad2682011-09-30 20:35:2656SkIRect AlignRect(const SkIRect& rect);
[email protected]47379e92011-07-26 15:33:1557
[email protected]15e7b6c2011-12-22 10:20:3358// Scales the supplied rectangle from |in_size| coordinates to |out_size|.
59// If the result has non-integer coordinates then the smallest integer-
60// coordinate rectangle that wholly encloses it is returned.
[email protected]bcad2682011-09-30 20:35:2661SkIRect ScaleRect(const SkIRect& rect,
[email protected]15e7b6c2011-12-22 10:20:3362 const SkISize& in_size,
63 const SkISize& out_size);
[email protected]47379e92011-07-26 15:33:1564
[email protected]2cc0ec842011-08-01 19:59:4265// Copy pixels in the rectangle from source to destination.
66void CopyRect(const uint8* src_plane,
67 int src_plane_stride,
68 uint8* dest_plane,
69 int dest_plane_stride,
70 int bytes_per_pixel,
[email protected]dc454a7c2011-08-12 22:01:1371 const SkIRect& rect);
[email protected]2cc0ec842011-08-01 19:59:4272
[email protected]c3af26f332010-10-06 22:46:0073} // namespace remoting
74
75#endif // REMOTING_BASE_UTIL_H_