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

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

Issue 168833002: call clear() instead of using deprecated API accessBitmap() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 | « skia/ext/bitmap_platform_device_mac.cc ('k') | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
14 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); 14 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
15 if (bitmap.allocPixels()) { 15 if (bitmap.allocPixels()) {
16 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it 16 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it
17 // is not opaque. 17 // is not opaque.
18 if (!is_opaque) 18 if (!is_opaque)
19 bitmap.eraseARGB(0, 0, 0, 0); 19 bitmap.eraseARGB(0, 0, 0, 0);
20 return new BitmapPlatformDevice(bitmap); 20 return new BitmapPlatformDevice(bitmap);
21 } 21 }
22 return NULL; 22 return NULL;
23 } 23 }
24 24
25 BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width, 25 BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width,
26 int height, 26 int height,
27 bool is_opaque) { 27 bool is_opaque) {
28 BitmapPlatformDevice* device = Create(width, height, is_opaque); 28 BitmapPlatformDevice* device = Create(width, height, is_opaque);
29 if (!is_opaque) 29 if (!is_opaque)
30 device->accessBitmap(true).eraseARGB(0, 0, 0, 0); 30 device->clear(0);
31 return device; 31 return device;
32 } 32 }
33 33
34 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, 34 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
35 bool is_opaque, 35 bool is_opaque,
36 uint8_t* data) { 36 uint8_t* data) {
37 SkBitmap bitmap; 37 SkBitmap bitmap;
38 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, 38 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
39 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); 39 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
40 if (data) 40 if (data)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, 90 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
91 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); 91 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
92 if (!bitmap_.allocPixels()) 92 if (!bitmap_.allocPixels())
93 return false; 93 return false;
94 94
95 surface_ = bitmap_.getPixels(); 95 surface_ = bitmap_.getPixels();
96 return true; 96 return true;
97 } 97 }
98 98
99 } // namespace skia 99 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_mac.cc ('k') | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698