OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "skia/ext/bitmap_platform_device_skia.h" | 5 #include "skia/ext/bitmap_platform_device_skia.h" |
6 #include "skia/ext/platform_canvas.h" | 6 #include "skia/ext/platform_canvas.h" |
7 | 7 |
8 namespace skia { | 8 namespace skia { |
9 | 9 |
10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, | 10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, |
(...skipping 13 matching lines...) Expand all Loading... |
24 bool is_opaque, | 24 bool is_opaque, |
25 uint8_t* data) { | 25 uint8_t* data) { |
26 SkBitmap bitmap; | 26 SkBitmap bitmap; |
27 bitmap.setInfo(SkImageInfo::MakeN32(width, height, | 27 bitmap.setInfo(SkImageInfo::MakeN32(width, height, |
28 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); | 28 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); |
29 if (data) | 29 if (data) |
30 bitmap.setPixels(data); | 30 bitmap.setPixels(data); |
31 else if (!bitmap.tryAllocPixels()) | 31 else if (!bitmap.tryAllocPixels()) |
32 return NULL; | 32 return NULL; |
33 | 33 |
| 34 if (!is_opaque) |
| 35 bitmap.eraseARGB(0, 0, 0, 0); |
34 return new BitmapPlatformDevice(bitmap); | 36 return new BitmapPlatformDevice(bitmap); |
35 } | 37 } |
36 | 38 |
37 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap) | 39 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap) |
38 : SkBitmapDevice(bitmap) { | 40 : SkBitmapDevice(bitmap) { |
39 SetPlatformDevice(this, this); | 41 SetPlatformDevice(this, this); |
40 } | 42 } |
41 | 43 |
42 BitmapPlatformDevice::~BitmapPlatformDevice() { | 44 BitmapPlatformDevice::~BitmapPlatformDevice() { |
43 } | 45 } |
(...skipping 27 matching lines...) Expand all Loading... |
71 | 73 |
72 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 74 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
73 if (!bitmap_.tryAllocN32Pixels(width, height, is_opaque)) | 75 if (!bitmap_.tryAllocN32Pixels(width, height, is_opaque)) |
74 return false; | 76 return false; |
75 | 77 |
76 surface_ = bitmap_.getPixels(); | 78 surface_ = bitmap_.getPixels(); |
77 return true; | 79 return true; |
78 } | 80 } |
79 | 81 |
80 } // namespace skia | 82 } // namespace skia |
OLD | NEW |