OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "remoting/host/encoder_verbatim.h" | 5 #include "remoting/host/encoder_verbatim.h" |
6 | 6 |
7 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
9 #include "remoting/base/protocol/chromotocol.pb.h" | 9 #include "remoting/base/protocol_util.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 using media::DataBuffer; | 13 using media::DataBuffer; |
14 | 14 |
15 void EncoderVerbatim::Encode(const DirtyRects& dirty_rects, | 15 void EncoderVerbatim::Encode(const DirtyRects& dirty_rects, |
16 const uint8* const* input_data, | 16 const uint8* const* input_data, |
17 const int* strides, | 17 const int* strides, |
18 bool key_frame, | 18 bool key_frame, |
19 DataAvailableCallback* data_available_callback) { | 19 DataAvailableCallback* data_available_callback) { |
(...skipping 21 matching lines...) Expand all Loading... |
41 | 41 |
42 delete data_available_callback; | 42 delete data_available_callback; |
43 } | 43 } |
44 | 44 |
45 void EncoderVerbatim::SetSize(int width, int height) { | 45 void EncoderVerbatim::SetSize(int width, int height) { |
46 width_ = width; | 46 width_ = width; |
47 height_ = height; | 47 height_ = height; |
48 } | 48 } |
49 | 49 |
50 void EncoderVerbatim::SetPixelFormat(PixelFormat pixel_format) { | 50 void EncoderVerbatim::SetPixelFormat(PixelFormat pixel_format) { |
51 // These are sorted so that the most common formats are checked first. | 51 bytes_per_pixel_ = GetBytesPerPixel(pixel_format); |
52 // TODO(hclam): Extract this into a util function. | |
53 if (pixel_format == PixelFormatRgb24) { | |
54 bytes_per_pixel_ = 3; | |
55 } else if (pixel_format == PixelFormatRgb565) { | |
56 bytes_per_pixel_ = 2; | |
57 } else if (pixel_format == PixelFormatRgb32) { | |
58 bytes_per_pixel_ = 4; | |
59 } else if (pixel_format != PixelFormatAscii) { | |
60 bytes_per_pixel_ = 1; | |
61 } else { | |
62 NOTREACHED() << "Pixel format not supported"; | |
63 } | |
64 pixel_format_ = pixel_format; | 52 pixel_format_ = pixel_format; |
65 } | 53 } |
66 | 54 |
67 bool EncoderVerbatim::EncodeRect(const gfx::Rect& dirty, | 55 bool EncoderVerbatim::EncodeRect(const gfx::Rect& dirty, |
68 const uint8* const* input_data, | 56 const uint8* const* input_data, |
69 const int* strides, | 57 const int* strides, |
70 UpdateStreamPacketHeader *header, | 58 UpdateStreamPacketHeader *header, |
71 scoped_refptr<DataBuffer>* output_data) { | 59 scoped_refptr<DataBuffer>* output_data) { |
72 const int kPlanes = 3; | 60 const int kPlanes = 3; |
73 | 61 |
(...skipping 26 matching lines...) Expand all Loading... |
100 DCHECK_LE(row_size, strides[i]); | 88 DCHECK_LE(row_size, strides[i]); |
101 memcpy(out, in, row_size); | 89 memcpy(out, in, row_size); |
102 in += strides[i]; | 90 in += strides[i]; |
103 out += row_size; | 91 out += row_size; |
104 } | 92 } |
105 } | 93 } |
106 return true; | 94 return true; |
107 } | 95 } |
108 | 96 |
109 } // namespace remoting | 97 } // namespace remoting |
OLD | NEW |