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

Side by Side Diff: remoting/base/encoder_row_based.cc

Issue 7622002: Revert 96327 - Switch over to using SkRegions to calculate dirty areas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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/base/encoder_row_based.h ('k') | remoting/base/encoder_vp8.cc » ('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) 2011 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/base/encoder_row_based.h" 5 #include "remoting/base/encoder_row_based.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "remoting/base/capture_data.h" 8 #include "remoting/base/capture_data.h"
9 #include "remoting/base/compressor_verbatim.h" 9 #include "remoting/base/compressor_verbatim.h"
10 #include "remoting/base/compressor_zlib.h" 10 #include "remoting/base/compressor_zlib.h"
11 #include "remoting/base/util.h" 11 #include "remoting/base/util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 void EncoderRowBased::Encode(scoped_refptr<CaptureData> capture_data, 60 void EncoderRowBased::Encode(scoped_refptr<CaptureData> capture_data,
61 bool key_frame, 61 bool key_frame,
62 DataAvailableCallback* data_available_callback) { 62 DataAvailableCallback* data_available_callback) {
63 CHECK(capture_data->pixel_format() == media::VideoFrame::RGB32) 63 CHECK(capture_data->pixel_format() == media::VideoFrame::RGB32)
64 << "RowBased Encoder only works with RGB32. Got " 64 << "RowBased Encoder only works with RGB32. Got "
65 << capture_data->pixel_format(); 65 << capture_data->pixel_format();
66 capture_data_ = capture_data; 66 capture_data_ = capture_data;
67 callback_.reset(data_available_callback); 67 callback_.reset(data_available_callback);
68 68
69 const SkRegion& region = capture_data->dirty_region(); 69 const InvalidRects& rects = capture_data->dirty_rects();
70 SkRegion::Iterator iter(region); 70 for (InvalidRects::const_iterator r = rects.begin(); r != rects.end(); ++r) {
71 while (!iter.done()) { 71 EncodeRect(*r, r == --rects.end());
72 SkIRect rect = iter.rect();
73 iter.next();
74 EncodeRect(rect, iter.done());
75 } 72 }
76 73
77 capture_data_ = NULL; 74 capture_data_ = NULL;
78 callback_.reset(); 75 callback_.reset();
79 } 76 }
80 77
81 void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) { 78 void EncoderRowBased::EncodeRect(const gfx::Rect& rect, bool last) {
82 CHECK(capture_data_->data_planes().data[0]); 79 CHECK(capture_data_->data_planes().data[0]);
83 const int strides = capture_data_->data_planes().strides[0]; 80 const int strides = capture_data_->data_planes().strides[0];
84 const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format()); 81 const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format());
85 const int row_size = bytes_per_pixel * rect.width(); 82 const int row_size = bytes_per_pixel * rect.width();
86 83
87 compressor_->Reset(); 84 compressor_->Reset();
88 85
89 VideoPacket* packet = new VideoPacket(); 86 VideoPacket* packet = new VideoPacket();
90 PrepareUpdateStart(rect, packet); 87 PrepareUpdateStart(rect, packet);
91 const uint8* in = capture_data_->data_planes().data[0] + 88 const uint8* in = capture_data_->data_planes().data[0] +
92 rect.fTop * strides + rect.fLeft * bytes_per_pixel; 89 rect.y() * strides + rect.x() * bytes_per_pixel;
93 // TODO(hclam): Fill in the sequence number. 90 // TODO(hclam): Fill in the sequence number.
94 uint8* out = GetOutputBuffer(packet, packet_size_); 91 uint8* out = GetOutputBuffer(packet, packet_size_);
95 int filled = 0; 92 int filled = 0;
96 int row_pos = 0; // Position in the current row in bytes. 93 int row_pos = 0; // Position in the current row in bytes.
97 int row_y = 0; // Current row. 94 int row_y = 0; // Current row.
98 bool compress_again = true; 95 bool compress_again = true;
99 while (compress_again) { 96 while (compress_again) {
100 // Prepare a message for sending out. 97 // Prepare a message for sending out.
101 if (!packet) { 98 if (!packet) {
102 packet = new VideoPacket(); 99 packet = new VideoPacket();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 135
139 // Reached the end of input row and we're not at the last row. 136 // Reached the end of input row and we're not at the last row.
140 if (row_pos == row_size && row_y < rect.height() - 1) { 137 if (row_pos == row_size && row_y < rect.height() - 1) {
141 row_pos = 0; 138 row_pos = 0;
142 in += strides; 139 in += strides;
143 ++row_y; 140 ++row_y;
144 } 141 }
145 } 142 }
146 } 143 }
147 144
148 void EncoderRowBased::PrepareUpdateStart(const SkIRect& rect, 145 void EncoderRowBased::PrepareUpdateStart(const gfx::Rect& rect,
149 VideoPacket* packet) { 146 VideoPacket* packet) {
150 packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET); 147 packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET);
151 148
152 VideoPacketFormat* format = packet->mutable_format(); 149 VideoPacketFormat* format = packet->mutable_format();
153 format->set_x(rect.fLeft); 150 format->set_x(rect.x());
154 format->set_y(rect.fTop); 151 format->set_y(rect.y());
155 format->set_width(rect.width()); 152 format->set_width(rect.width());
156 format->set_height(rect.height()); 153 format->set_height(rect.height());
157 format->set_encoding(encoding_); 154 format->set_encoding(encoding_);
158 if (capture_data_->size() != screen_size_) { 155 if (capture_data_->size() != screen_size_) {
159 screen_size_ = capture_data_->size(); 156 screen_size_ = capture_data_->size();
160 format->set_screen_width(screen_size_.width()); 157 format->set_screen_width(screen_size_.width());
161 format->set_screen_height(screen_size_.height()); 158 format->set_screen_height(screen_size_.height());
162 } 159 }
163 } 160 }
164 161
165 uint8* EncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) { 162 uint8* EncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) {
166 packet->mutable_data()->resize(size); 163 packet->mutable_data()->resize(size);
167 // TODO(ajwong): Is there a better way to do this at all??? 164 // TODO(ajwong): Is there a better way to do this at all???
168 return const_cast<uint8*>(reinterpret_cast<const uint8*>( 165 return const_cast<uint8*>(reinterpret_cast<const uint8*>(
169 packet->mutable_data()->data())); 166 packet->mutable_data()->data()));
170 } 167 }
171 168
172 169
173 } // namespace remoting 170 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/encoder_row_based.h ('k') | remoting/base/encoder_vp8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698