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

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

Issue 3013015: Initial pass at integrating Differ into the chromoting host code.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/capturer_fake.h ('k') | remoting/host/capturer_fake_ascii.h » ('j') | 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/capturer_fake.h" 5 #include "remoting/host/capturer_fake.h"
6 6
7 #include "gfx/rect.h" 7 #include "gfx/rect.h"
8 8
9 namespace remoting { 9 namespace remoting {
10 10
11 static const int kWidth = 320; 11 static const int kWidth = 320;
12 static const int kHeight = 240; 12 static const int kHeight = 240;
13 static const int kBytesPerPixel = 4; // 32 bit RGB is 4 bytes per pixel. 13 static const int kBytesPerPixel = 4; // 32 bit RGB is 4 bytes per pixel.
14 static const int kMaxColorChannelValue = 255; 14 static const int kMaxColorChannelValue = 255;
15 15
16 CapturerFake::CapturerFake() 16 CapturerFake::CapturerFake()
17 : seed_(0) { 17 : seed_(0) {
18 } 18 }
19 19
20 CapturerFake::~CapturerFake() { 20 CapturerFake::~CapturerFake() {
21 } 21 }
22 22
23 void CapturerFake::CaptureRects(const RectVector& rects, 23 void CapturerFake::ScreenConfigurationChanged() {
24 width_ = kWidth;
25 height_ = kHeight;
26 pixel_format_ = PixelFormatRgb32;
27 bytes_per_row_ = width_ * kBytesPerPixel;
28
29 // Create memory for the buffers.
30 int buffer_size = height_ * bytes_per_row_;
31 for (int i = 0; i < kNumBuffers; i++) {
32 buffers_[i].reset(new uint8[buffer_size]);
33 }
34 }
35
36 void CapturerFake::CalculateInvalidRects() {
37 GenerateImage();
38 InvalidateFullScreen();
39 }
40
41 void CapturerFake::CaptureRects(const InvalidRects& rects,
24 CaptureCompletedCallback* callback) { 42 CaptureCompletedCallback* callback) {
25 GenerateImage();
26 DataPlanes planes; 43 DataPlanes planes;
27 planes.data[0] = buffers_[current_buffer_].get(); 44 planes.data[0] = buffers_[current_buffer_].get();
28 planes.strides[0] = bytes_per_row_; 45 planes.strides[0] = bytes_per_row_;
29 46
30 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, 47 scoped_refptr<CaptureData> capture_data(new CaptureData(planes,
31 width_, 48 width_,
32 height_, 49 height_,
33 pixel_format_)); 50 pixel_format_));
34 capture_data->mutable_dirty_rects() = rects; 51 capture_data->mutable_dirty_rects() = rects;
35 FinishCapture(capture_data, callback); 52 FinishCapture(capture_data, callback);
36 } 53 }
37 54
38 void CapturerFake::ScreenConfigurationChanged() {
39 width_ = kWidth;
40 height_ = kHeight;
41 pixel_format_ = PixelFormatRgb32;
42 bytes_per_row_ = width_ * kBytesPerPixel;
43
44 // Create memory for the buffers.
45 int buffer_size = height_ * bytes_per_row_;
46 for (int i = 0; i < kNumBuffers; i++) {
47 buffers_[i].reset(new uint8[buffer_size]);
48 }
49 }
50
51 void CapturerFake::GenerateImage() { 55 void CapturerFake::GenerateImage() {
52 uint8* row = buffers_[current_buffer_].get(); 56 uint8* row = buffers_[current_buffer_].get();
53 for (int y = 0; y < height_; ++y) { 57 for (int y = 0; y < height_; ++y) {
54 int offset = y % 3; 58 int offset = y % 3;
55 for (int x = 0; x < width_; ++x) { 59 for (int x = 0; x < width_; ++x) {
56 row[x * kBytesPerPixel + offset] = seed_++; 60 row[x * kBytesPerPixel + offset] = seed_++;
57 seed_ &= kMaxColorChannelValue; 61 seed_ &= kMaxColorChannelValue;
58 } 62 }
59 row += bytes_per_row_; 63 row += bytes_per_row_;
60 } 64 }
61 ++seed_; 65 ++seed_;
62 } 66 }
63 67
64 } // namespace remoting 68 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/capturer_fake.h ('k') | remoting/host/capturer_fake_ascii.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698