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

Unified Diff: remoting/test/frame_generator_util.cc

Issue 2798413002: stop using copyPixelsTo -- deprecated (Closed)
Patch Set: 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..bb52daeff68772891e8e35f7dc7ff2acc01e3d1e 100644
--- a/remoting/test/frame_generator_util.cc
+++ b/remoting/test/frame_generator_util.cc
@@ -12,6 +12,25 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "ui/gfx/codec/png_codec.h"
+namespace {
+void CopyPixelsToBuffer(const SkBitmap& src,
+ void* dst_pixels,
+ size_t dst_stride) {
Sergey Ulanov 2017/04/06 19:04:28 In webrtc::DesktopFrame stride may be negative, so
reed1 2017/04/07 12:28:13 The old logic cast it to size_t when it called cop
Sergey Ulanov 2017/04/07 18:05:12 It's used for the case when rows are stored from b
reed1 2017/04/07 21:11:25 Got it. The old code-path (the method being deprec
+ 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
Sergey Ulanov 2017/04/06 19:04:28 I don't think this comment is necessary, but if yo
reed1 2017/04/07 12:28:13 Done.
+ size_t bytes_per_row = tmp.width() * tmp.bytesPerPixel();
+ DCHECK(bytes_per_row <= dst_stride);
Sergey Ulanov 2017/04/06 19:04:28 stride may be negative for webrtc::DesktopFrame, s
reed1 2017/04/07 12:28:13 Should this fail if it sees a negative?
Sergey Ulanov 2017/04/07 18:05:12 No.
reed1 2017/04/07 21:11:25 Done.
+ for (int y = 0; y < tmp.height(); ++y) {
+ memcpy(dst_pixels, src_pixels, bytes_per_row);
+ src_pixels += src_stride;
+ dst_pixels = (char*)dst_pixels + dst_stride;
Sergey Ulanov 2017/04/06 19:04:28 I don't think you need the cast here. dst_pixel
reed1 2017/04/07 12:28:13 dst_pixels is void*, so it cannot perform += witho
Sergey Ulanov 2017/04/07 18:05:12 Maybe change it to uint8_t*? It's the type used fo
reed1 2017/04/07 21:11:25 Done.
+ }
+}
+}
Sergey Ulanov 2017/04/06 19:04:28 // namespace
reed1 2017/04/07 12:28:13 Done.
+
namespace remoting {
namespace test {
@@ -33,9 +52,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