diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 22:23:08 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 22:23:08 +0000 |
commit | 4e758b649512b9e6ab5c6c67f38572894062139d (patch) | |
tree | 5322a791926a0218d78c8d41afe03705a8a95e54 /remoting/host/capturer_fake.cc | |
parent | 715126056fa8080cd3c5b21e513dd417ddd6c66f (diff) | |
download | chromium_src-4e758b649512b9e6ab5c6c67f38572894062139d.zip chromium_src-4e758b649512b9e6ab5c6c67f38572894062139d.tar.gz chromium_src-4e758b649512b9e6ab5c6c67f38572894062139d.tar.bz2 |
Cleanups in the video encoding decoding code. Reenable VP8.
1. Moved video-related protobuf messages from event.proto to video.proto. Removed those that we don't need anymore
2. Fixed naming for enums and some types.
3. Reenabled VP8.
4. Proper RGB-YUV converter for VP8 encoder.
5. Changed the capturer_fake to show more meaningful picture.
BUG=57374
TEST=unittests
Review URL: http://codereview.chromium.org/4136010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/capturer_fake.cc')
-rw-r--r-- | remoting/host/capturer_fake.cc | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/remoting/host/capturer_fake.cc b/remoting/host/capturer_fake.cc index 56b43cf..072f19a 100644 --- a/remoting/host/capturer_fake.cc +++ b/remoting/host/capturer_fake.cc @@ -8,13 +8,27 @@ namespace remoting { -static const int kWidth = 320; -static const int kHeight = 240; +// CapturerFake generates a white picture of size kWidth x kHeight with a +// rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed pixels +// per frame along both axes, and bounces off the sides of the screen. +static const int kWidth = 800; +static const int kHeight = 600; +static const int kBoxWidth = 140; +static const int kBoxHeight = 140; +static const int kSpeed = 20; + +COMPILE_ASSERT(kBoxWidth < kWidth && kBoxHeight < kHeight, bad_box_size); +COMPILE_ASSERT((kBoxWidth % kSpeed == 0) && (kWidth % kSpeed == 0) && + (kBoxHeight % kSpeed == 0) && (kHeight % kSpeed == 0), + sizes_must_be_multiple_of_kSpeed); + static const int kBytesPerPixel = 4; // 32 bit RGB is 4 bytes per pixel. -static const int kMaxColorChannelValue = 255; CapturerFake::CapturerFake() - : seed_(0) { + : box_pos_x_(0), + box_pos_y_(0), + box_speed_x_(kSpeed), + box_speed_y_(kSpeed) { ScreenConfigurationChanged(); } @@ -24,7 +38,7 @@ CapturerFake::~CapturerFake() { void CapturerFake::ScreenConfigurationChanged() { width_ = kWidth; height_ = kHeight; - pixel_format_ = PixelFormatRgb32; + pixel_format_ = PIXEL_FORMAT_RGB32; bytes_per_row_ = width_ * kBytesPerPixel; // Create memory for the buffers. @@ -54,16 +68,36 @@ void CapturerFake::CaptureRects(const InvalidRects& rects, } void CapturerFake::GenerateImage() { - uint8* row = buffers_[current_buffer_].get(); - for (int y = 0; y < height_; ++y) { - int offset = y % 3; - for (int x = 0; x < width_; ++x) { - row[x * kBytesPerPixel + offset] = seed_++; - seed_ &= kMaxColorChannelValue; + memset(buffers_[current_buffer_].get(), 0xff, + width_ * height_ * kBytesPerPixel); + + uint8* row = buffers_[current_buffer_].get() + + (box_pos_y_ * width_ + box_pos_x_) * kBytesPerPixel; + + box_pos_x_ += box_speed_x_; + if (box_pos_x_ + kBoxWidth >= width_ || box_pos_x_ == 0) + box_speed_x_ = -box_speed_x_; + + box_pos_y_ += box_speed_y_; + if (box_pos_y_ + kBoxHeight >= height_ || box_pos_y_ == 0) + box_speed_y_ = -box_speed_y_; + + // Draw rectangle with the following colors in it's corners: + // cyan....yellow + // .............. + // blue.......red + for (int y = 0; y < kBoxHeight; ++y) { + for (int x = 0; x < kBoxWidth; ++x) { + int r = x * 255 / kBoxWidth; + int g = y * 255 / kBoxHeight; + int b = 255 - (x * 255 / kBoxWidth); + row[x * kBytesPerPixel] = r; + row[x * kBytesPerPixel+1] = g; + row[x * kBytesPerPixel+2] = b; + row[x * kBytesPerPixel+3] = 0xff; } row += bytes_per_row_; } - ++seed_; } } // namespace remoting |