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

Unified Diff: remoting/test/frame_generator_util.cc

Issue 2798413002: stop using copyPixelsTo -- deprecated (Closed)
Patch Set: support dst_stride being signed Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/test/frame_generator_util.cc
diff --git a/remoting/test/frame_generator_util.cc b/remoting/test/frame_generator_util.cc
index bf78b0f14ae415af1c2a53d9d4c7a46d4efded32..bef4040390f6956b541964e95cdf05f99a1d495a 100644
--- a/remoting/test/frame_generator_util.cc
+++ b/remoting/test/frame_generator_util.cc
@@ -12,6 +12,26 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "ui/gfx/codec/png_codec.h"
+namespace {
+// dst_stride is int, not size_t, as it may be negative for inverted (in Y)
+// images.
+void CopyPixelsToBuffer(const SkBitmap& src,
+ uint8_t* dst_pixels,
+ int dst_stride) {
+ SkBitmap tmp(src);
+ tmp.lockPixels();
+ const char* src_pixels = static_cast<const char*>(tmp.getPixels());
+ size_t src_stride = tmp.rowBytes();
+ // Only need to copy the important parts of the row.
+ size_t bytes_per_row = tmp.width() * tmp.bytesPerPixel();
+ for (int y = 0; y < tmp.height(); ++y) {
+ memcpy(dst_pixels, src_pixels, bytes_per_row);
+ src_pixels += src_stride;
+ dst_pixels += dst_stride;
+ }
+}
+} // namespace
+
namespace remoting {
namespace test {
@@ -33,9 +53,7 @@ std::unique_ptr<webrtc::DesktopFrame> LoadDesktopFrameFromPng(
file_content.size(), &bitmap);
std::unique_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame(
webrtc::DesktopSize(bitmap.width(), bitmap.height())));
- bitmap.copyPixelsTo(frame->data(),
- frame->stride() * frame->size().height(),
- frame->stride());
+ CopyPixelsToBuffer(bitmap, frame->data(), frame->stride());
return frame;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698