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

Side by Side Diff: remoting/protocol/fake_desktop_capturer.cc

Issue 1542203002: Switch to standard integer types in remoting/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@int-remoting-host
Patch Set: Created 4 years, 12 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
« no previous file with comments | « remoting/protocol/fake_datagram_socket.h ('k') | remoting/protocol/fake_session.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/protocol/fake_desktop_capturer.h" 5 #include "remoting/protocol/fake_desktop_capturer.h"
6 6
7 #include <stdint.h>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h"
9 #include "base/time/time.h" 12 #include "base/time/time.h"
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 13 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
11 14
12 namespace remoting { 15 namespace remoting {
13 namespace protocol { 16 namespace protocol {
14 17
15 // FakeDesktopCapturer generates a white picture of size kWidth x kHeight 18 // FakeDesktopCapturer generates a white picture of size kWidth x kHeight
16 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed 19 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed
17 // pixels per frame along both axes, and bounces off the sides of the screen. 20 // pixels per frame along both axes, and bounces off the sides of the screen.
18 static const int kWidth = FakeDesktopCapturer::kWidth; 21 static const int kWidth = FakeDesktopCapturer::kWidth;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 box_pos_y_ += box_speed_y_; 85 box_pos_y_ += box_speed_y_;
83 if (box_pos_y_ + kBoxHeight >= kHeight || box_pos_y_ == 0) 86 if (box_pos_y_ + kBoxHeight >= kHeight || box_pos_y_ == 0)
84 box_speed_y_ = -box_speed_y_; 87 box_speed_y_ = -box_speed_y_;
85 88
86 memset(frame->data(), 0xff, kHeight * frame->stride()); 89 memset(frame->data(), 0xff, kHeight * frame->stride());
87 90
88 // Draw rectangle with the following colors in its corners: 91 // Draw rectangle with the following colors in its corners:
89 // cyan....yellow 92 // cyan....yellow
90 // .............. 93 // ..............
91 // blue.......red 94 // blue.......red
92 uint8* row = frame->data() + 95 uint8_t* row = frame->data() +
93 (box_pos_y_ * size_.width() + box_pos_x_) * kBytesPerPixel; 96 (box_pos_y_ * size_.width() + box_pos_x_) * kBytesPerPixel;
94 for (int y = 0; y < kBoxHeight; ++y) { 97 for (int y = 0; y < kBoxHeight; ++y) {
95 for (int x = 0; x < kBoxWidth; ++x) { 98 for (int x = 0; x < kBoxWidth; ++x) {
96 int r = x * 255 / kBoxWidth; 99 int r = x * 255 / kBoxWidth;
97 int g = y * 255 / kBoxHeight; 100 int g = y * 255 / kBoxHeight;
98 int b = 255 - (x * 255 / kBoxWidth); 101 int b = 255 - (x * 255 / kBoxWidth);
99 row[x * kBytesPerPixel] = r; 102 row[x * kBytesPerPixel] = r;
100 row[x * kBytesPerPixel + 1] = g; 103 row[x * kBytesPerPixel + 1] = g;
101 row[x * kBytesPerPixel + 2] = b; 104 row[x * kBytesPerPixel + 2] = b;
102 row[x * kBytesPerPixel + 3] = 0xff; 105 row[x * kBytesPerPixel + 3] = 0xff;
103 } 106 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_); 148 scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_);
146 if (frame) { 149 if (frame) {
147 frame->set_capture_time_ms( 150 frame->set_capture_time_ms(
148 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); 151 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp());
149 } 152 }
150 callback_->OnCaptureCompleted(frame.release()); 153 callback_->OnCaptureCompleted(frame.release());
151 } 154 }
152 155
153 } // namespace protocol 156 } // namespace protocol
154 } // namespace remoting 157 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/fake_datagram_socket.h ('k') | remoting/protocol/fake_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698