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

Side by Side Diff: remoting/test/frame_generator_util.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/test/frame_generator_util.h" 5 #include "remoting/test/frame_generator_util.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 12 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
13 #include "ui/gfx/codec/png_codec.h" 13 #include "ui/gfx/codec/png_codec.h"
14 14
15 namespace { 15 namespace {
16 // dst_stride is int, not size_t, as it may be negative for inverted (in Y) 16 // dst_stride is int, not size_t, as it may be negative for inverted (in Y)
17 // images. 17 // images.
18 void CopyPixelsToBuffer(const SkBitmap& src, 18 void CopyPixelsToBuffer(const SkBitmap& src,
19 uint8_t* dst_pixels, 19 uint8_t* dst_pixels,
20 int dst_stride) { 20 int dst_stride) {
21 SkBitmap tmp(src); 21 const char* src_pixels = static_cast<const char*>(src.getPixels());
22 tmp.lockPixels(); 22 size_t src_stride = src.rowBytes();
23 const char* src_pixels = static_cast<const char*>(tmp.getPixels());
24 size_t src_stride = tmp.rowBytes();
25 // Only need to copy the important parts of the row. 23 // Only need to copy the important parts of the row.
26 size_t bytes_per_row = tmp.width() * tmp.bytesPerPixel(); 24 size_t bytes_per_row = src.width() * src.bytesPerPixel();
27 for (int y = 0; y < tmp.height(); ++y) { 25 for (int y = 0; y < src.height(); ++y) {
28 memcpy(dst_pixels, src_pixels, bytes_per_row); 26 memcpy(dst_pixels, src_pixels, bytes_per_row);
29 src_pixels += src_stride; 27 src_pixels += src_stride;
30 dst_pixels += dst_stride; 28 dst_pixels += dst_stride;
31 } 29 }
32 } 30 }
33 } // namespace 31 } // namespace
34 32
35 namespace remoting { 33 namespace remoting {
36 namespace test { 34 namespace test {
37 35
(...skipping 26 matching lines...) Expand all
64 uint32_t* data = reinterpret_cast<uint32_t*>( 62 uint32_t* data = reinterpret_cast<uint32_t*>(
65 frame->GetFrameDataAtPos(webrtc::DesktopVector(rect.left(), y))); 63 frame->GetFrameDataAtPos(webrtc::DesktopVector(rect.left(), y)));
66 for (int x = 0; x < rect.width(); ++x) { 64 for (int x = 0; x < rect.width(); ++x) {
67 data[x] = color; 65 data[x] = color;
68 } 66 }
69 } 67 }
70 } 68 }
71 69
72 } // namespace test 70 } // namespace test
73 } // namespace remoting 71 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698