Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / remoting / host / chromeos / skia_bitmap_desktop_frame.cc
blobd32f387e2cf14426f64cdba7052488d1d16e101d
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
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "remoting/host/chromeos/skia_bitmap_desktop_frame.h"
8 namespace remoting {
10 // static
11 SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create(
12 scoped_ptr<SkBitmap> bitmap) {
14 webrtc::DesktopSize size(bitmap->width(), bitmap->height());
15 DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType())
16 << "DesktopFrame objects always hold RGBA data.";
18 bitmap->lockPixels();
19 uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels());
20 bitmap->unlockPixels();
22 SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame(
23 size, bitmap->rowBytes(), bitmap_data, bitmap.Pass());
25 return result;
28 SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size,
29 int stride,
30 uint8_t* data,
31 scoped_ptr<SkBitmap> bitmap)
32 : DesktopFrame(size, stride, data, nullptr), bitmap_(bitmap.Pass()) {
35 SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {
38 } // namespace remoting