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

Side by Side Diff: remoting/host/encoder_verbatim.cc

Issue 2863028: remoting: Use GetBytesPerPixel util function in one more place. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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) 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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698