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

Side by Side Diff: remoting/host/chromeos/skia_bitmap_desktop_frame.cc

Issue 1216403004: Avoid unspecified behavior in SkiaBitmapDesktopFrame::Create (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "remoting/host/chromeos/skia_bitmap_desktop_frame.h" 6 #include "remoting/host/chromeos/skia_bitmap_desktop_frame.h"
7 7
8 namespace remoting { 8 namespace remoting {
9 9
10 // static 10 // static
11 SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create( 11 SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create(
12 scoped_ptr<SkBitmap> bitmap) { 12 scoped_ptr<SkBitmap> bitmap) {
13 13
14 webrtc::DesktopSize size(bitmap->width(), bitmap->height()); 14 webrtc::DesktopSize size(bitmap->width(), bitmap->height());
15 DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType()) 15 DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType())
16 << "DesktopFrame objects always hold RGBA data."; 16 << "DesktopFrame objects always hold RGBA data.";
17 17
18 bitmap->lockPixels(); 18 bitmap->lockPixels();
19 uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels()); 19 uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels());
20 bitmap->unlockPixels(); 20 bitmap->unlockPixels();
21 21
22 const size_t row_bytes = bitmap->rowBytes();
22 SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame( 23 SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame(
23 size, bitmap->rowBytes(), bitmap_data, bitmap.Pass()); 24 size, row_bytes, bitmap_data, bitmap.Pass());
24 25
25 return result; 26 return result;
26 } 27 }
27 28
28 SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size, 29 SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size,
29 int stride, 30 int stride,
30 uint8_t* data, 31 uint8_t* data,
31 scoped_ptr<SkBitmap> bitmap) 32 scoped_ptr<SkBitmap> bitmap)
32 : DesktopFrame(size, stride, data, nullptr), bitmap_(bitmap.Pass()) { 33 : DesktopFrame(size, stride, data, nullptr), bitmap_(bitmap.Pass()) {
33 } 34 }
34 35
35 SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() { 36 SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {
36 } 37 }
37 38
38 } // namespace remoting 39 } // namespace remoting
OLDNEW
« 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