diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-26 03:58:37 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-26 03:58:37 +0000 |
commit | 0bf0ce3331ea4e597b47126dd71c6448fdc4fc5f (patch) | |
tree | e4ef214610266318497ec72d64aa4e0f53d792f8 /remoting/base | |
parent | 193b0b89b4b49f8e8eb985b8f1a16e3c8506ee66 (diff) | |
download | chromium_src-0bf0ce3331ea4e597b47126dd71c6448fdc4fc5f.zip chromium_src-0bf0ce3331ea4e597b47126dd71c6448fdc4fc5f.tar.gz chromium_src-0bf0ce3331ea4e597b47126dd71c6448fdc4fc5f.tar.bz2 |
remoting: Extract the utility to get the BytesPerPixel from PixelFormat into a function.
Note: That was a TODO for hclam.
BUG=None
TEST=trybots
Review URL: http://codereview.chromium.org/2865019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r-- | remoting/base/protocol_util.cc | 15 | ||||
-rw-r--r-- | remoting/base/protocol_util.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/remoting/base/protocol_util.cc b/remoting/base/protocol_util.cc index 3ac738c5..508ae44a 100644 --- a/remoting/base/protocol_util.cc +++ b/remoting/base/protocol_util.cc @@ -24,4 +24,19 @@ scoped_refptr<media::DataBuffer> SerializeAndFrameMessage( return buffer; } +int GetBytesPerPixel(PixelFormat format) { + // Note: The order is important here for performace. This is sorted from the + // most common to the less common (PixelFormatAscii is mostly used + // just for testing). + switch (format) { + case PixelFormatRgb24: return 3; + case PixelFormatRgb565: return 2; + case PixelFormatRgb32: return 4; + case PixelFormatAscii: return 1; + default: + NOTREACHED() << "Pixel format not supported"; + return 0; + } +} + } // namespace remoting diff --git a/remoting/base/protocol_util.h b/remoting/base/protocol_util.h index 16781eb..94cdc2f 100644 --- a/remoting/base/protocol_util.h +++ b/remoting/base/protocol_util.h @@ -7,6 +7,7 @@ #include "google/protobuf/message_lite.h" #include "media/base/data_buffer.h" +#include "remoting/base/protocol/chromotocol.pb.h" // This file defines utility methods used for encoding and decoding the protocol // used in Chromoting. @@ -19,6 +20,8 @@ namespace remoting { scoped_refptr<media::DataBuffer> SerializeAndFrameMessage( const google::protobuf::MessageLite& msg); +int GetBytesPerPixel(PixelFormat format); + } // namespace remoting #endif // REMOTING_BASE_PROTOCOL_UTIL_H_ |