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

Side by Side Diff: skia/ext/bitmap_platform_device_skia.cc

Issue 331283002: stop calling deprecated setConfig (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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,
11 bool is_opaque) { 11 bool is_opaque) {
12 SkBitmap bitmap; 12 SkBitmap bitmap;
13 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, 13 if (bitmap.allocN32Pixels(width, height, is_opaque)) {
14 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
15 if (bitmap.allocPixels()) {
16 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it 14 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it
17 // is not opaque. 15 // is not opaque.
18 if (!is_opaque) 16 if (!is_opaque)
19 bitmap.eraseARGB(0, 0, 0, 0); 17 bitmap.eraseARGB(0, 0, 0, 0);
20 return new BitmapPlatformDevice(bitmap); 18 return new BitmapPlatformDevice(bitmap);
21 } 19 }
22 return NULL; 20 return NULL;
23 } 21 }
24 22
25 BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width, 23 BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width,
26 int height, 24 int height,
27 bool is_opaque) { 25 bool is_opaque) {
28 BitmapPlatformDevice* device = Create(width, height, is_opaque); 26 BitmapPlatformDevice* device = Create(width, height, is_opaque);
29 if (!is_opaque) 27 if (!is_opaque)
30 device->clear(0); 28 device->clear(0);
31 return device; 29 return device;
32 } 30 }
33 31
34 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, 32 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
35 bool is_opaque, 33 bool is_opaque,
36 uint8_t* data) { 34 uint8_t* data) {
37 SkBitmap bitmap; 35 SkBitmap bitmap;
38 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, 36 bitmap.setInfo(SkImageInfo::MakeN32(width, height, is_opaque ? kOpaque_SkAlpha Type : kPremul_SkAlphaType);
39 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
40 if (data) 37 if (data)
41 bitmap.setPixels(data); 38 bitmap.setPixels(data);
42 else if (!bitmap.allocPixels()) 39 else if (!bitmap.allocPixels())
43 return NULL; 40 return NULL;
44 41
45 return new BitmapPlatformDevice(bitmap); 42 return new BitmapPlatformDevice(bitmap);
46 } 43 }
47 44
48 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap) 45 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap)
49 : SkBitmapDevice(bitmap) { 46 : SkBitmapDevice(bitmap) {
(...skipping 30 matching lines...) Expand all
80 BitmapPlatformDevice::Create(width, height, is_opaque, data)); 77 BitmapPlatformDevice::Create(width, height, is_opaque, data));
81 return CreateCanvas(dev, failureType); 78 return CreateCanvas(dev, failureType);
82 } 79 }
83 80
84 // Port of PlatformBitmap to android 81 // Port of PlatformBitmap to android
85 PlatformBitmap::~PlatformBitmap() { 82 PlatformBitmap::~PlatformBitmap() {
86 // Nothing to do. 83 // Nothing to do.
87 } 84 }
88 85
89 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { 86 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
90 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, 87 if (!bitmap_.allocN32Pixels(width, height, is_opaque))
91 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
92 if (!bitmap_.allocPixels())
93 return false; 88 return false;
94 89
95 surface_ = bitmap_.getPixels(); 90 surface_ = bitmap_.getPixels();
96 return true; 91 return true;
97 } 92 }
98 93
99 } // namespace skia 94 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698