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

Side by Side Diff: remoting/host/capturer_fake_ascii.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_ascii.h ('k') | remoting/host/capturer_gdi.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_ascii.h"
6
7 #include "gfx/rect.h"
8
9 namespace remoting {
10
11 static const int kWidth = 32;
12 static const int kHeight = 20;
13 static const int kBytesPerPixel = 1;
14
15 CapturerFakeAscii::CapturerFakeAscii() {
16 // Dimensions of screen.
17 width_ = kWidth;
18 height_ = kHeight;
19 pixel_format_ = chromotocol_pb::PixelFormatAscii;
20 bytes_per_pixel_ = kBytesPerPixel;
21 bytes_per_row_ = width_ * bytes_per_pixel_;
22
23 // Create memory for the buffers.
24 int buffer_size = height_ * bytes_per_row_;
25 for (int i = 0; i < kNumBuffers; i++) {
26 buffers_[i].reset(new uint8[buffer_size]);
27 }
28 }
29
30 CapturerFakeAscii::~CapturerFakeAscii() {
31 }
32
33 void CapturerFakeAscii::CaptureFullScreen(Task* done_task) {
34 dirty_rects_.clear();
35
36 GenerateImage();
37
38 // Return a single dirty rect that includes the entire screen.
39 dirty_rects_.push_back(gfx::Rect(width_, height_));
40
41 FinishCapture(done_task);
42 }
43
44 void CapturerFakeAscii::CaptureDirtyRects(Task* done_task) {
45 dirty_rects_.clear();
46
47 GenerateImage();
48 // TODO(garykac): Diff old/new screen.
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 CapturerFakeAscii::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 CapturerFakeAscii::GetData(const uint8* planes[]) const {
65 planes[0] = buffers_[current_buffer_].get();
66 planes[1] = planes[2] = NULL;
67 }
68
69 void CapturerFakeAscii::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 CapturerFakeAscii::GenerateImage() {
76 for (int y = 0; y < height_; ++y) {
77 uint8* row = buffers_[current_buffer_].get() + bytes_per_row_ * y;
78 for (int x = 0; x < bytes_per_row_; ++x) {
79 if (y == 0 || x == 0 || x == (width_ - 1) || y == (height_ - 1)) {
80 row[x] = '*';
81 } else {
82 row[x] = ' ';
83 }
84 }
85 }
86 }
87
88 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/capturer_fake_ascii.h ('k') | remoting/host/capturer_gdi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698