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

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

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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 | 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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/capturer_fake.h"
6
7 #include "gfx/rect.h"
8
9 namespace remoting {
10
11 static const int kWidth = 640;
12 static const int kHeight = 480;
13 static const int kBytesPerPixel = 3; // 24 bit RGB is 3 bytes per pixel.
14 static const int kMaxColorChannelValue = 255;
15
16 CapturerFake::CapturerFake()
17 : seed_(0) {
18 // Dimensions of screen.
19 width_ = kWidth;
20 height_ = kHeight;
21 pixel_format_ = chromotocol_pb::PixelFormatRgb24;
22 bytes_per_pixel_ = kBytesPerPixel;
23 bytes_per_row_ = width_ * bytes_per_pixel_;
24
25 // Create memory for the buffers.
26 int buffer_size = height_ * bytes_per_row_;
27 for (int i = 0; i < kNumBuffers; i++) {
28 buffers_[i].reset(new uint8[buffer_size]);
29 }
30 }
31
32 CapturerFake::~CapturerFake() {
33 }
34
35 void CapturerFake::CaptureFullScreen(Task* done_task) {
36 dirty_rects_.clear();
37
38 GenerateImage();
39 dirty_rects_.push_back(gfx::Rect(width_, height_));
40
41 FinishCapture(done_task);
42 }
43
44 void CapturerFake::CaptureDirtyRects(Task* done_task) {
45 dirty_rects_.clear();
46
47 GenerateImage();
48 // TODO(garykac): Diff old/new images and generate |dirty_rects_|.
49 // Currently, this just marks the entire screen as dirty.
50 dirty_rects_.push_back(gfx::Rect(width_, height_));
51
52 FinishCapture(done_task);
53 }
54
55 void CapturerFake::CaptureRect(const gfx::Rect& rect, Task* done_task) {
56 dirty_rects_.clear();
57
58 GenerateImage();
59 dirty_rects_.push_back(rect);
60
61 FinishCapture(done_task);
62 }
63
64 void CapturerFake::GetData(const uint8* planes[]) const {
65 planes[0] = buffers_[current_buffer_].get();
66 planes[1] = planes[2] = NULL;
67 }
68
69 void CapturerFake::GetDataStride(int strides[]) const {
70 // Only the first plane has data.
71 strides[0] = bytes_per_row_;
72 strides[1] = strides[2] = 0;
73 }
74
75 void CapturerFake::GenerateImage() {
76 uint8* row = buffers_[current_buffer_].get();
77 for (int y = 0; y < height_; ++y) {
78 for (int x = 0; x < width_; ++x) {
79 row[x] = seed_++;
80 seed_ &= kMaxColorChannelValue;
81 }
82 row += bytes_per_row_;
83 }
84 }
85
86 } // 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