OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/host/chromeos/skia_bitmap_desktop_frame.h" | 5 #include "remoting/host/chromeos/skia_bitmap_desktop_frame.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 | 14 |
15 // static | 15 // static |
16 SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create( | 16 SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create( |
17 std::unique_ptr<SkBitmap> bitmap) { | 17 std::unique_ptr<SkBitmap> bitmap) { |
18 webrtc::DesktopSize size(bitmap->width(), bitmap->height()); | 18 webrtc::DesktopSize size(bitmap->width(), bitmap->height()); |
19 DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType()) | 19 DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType()) |
20 << "DesktopFrame objects always hold RGBA data."; | 20 << "DesktopFrame objects always hold RGBA data."; |
21 | 21 |
22 bitmap->lockPixels(); | |
23 uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels()); | 22 uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels()); |
24 bitmap->unlockPixels(); | |
25 | |
26 const size_t row_bytes = bitmap->rowBytes(); | 23 const size_t row_bytes = bitmap->rowBytes(); |
27 SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame( | 24 SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame( |
28 size, row_bytes, bitmap_data, std::move(bitmap)); | 25 size, row_bytes, bitmap_data, std::move(bitmap)); |
29 | 26 |
30 return result; | 27 return result; |
31 } | 28 } |
32 | 29 |
33 SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size, | 30 SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size, |
34 int stride, | 31 int stride, |
35 uint8_t* data, | 32 uint8_t* data, |
36 std::unique_ptr<SkBitmap> bitmap) | 33 std::unique_ptr<SkBitmap> bitmap) |
37 : DesktopFrame(size, stride, data, nullptr), bitmap_(std::move(bitmap)) {} | 34 : DesktopFrame(size, stride, data, nullptr), bitmap_(std::move(bitmap)) {} |
38 | 35 |
39 SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {} | 36 SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {} |
40 | 37 |
41 } // namespace remoting | 38 } // namespace remoting |
OLD | NEW |