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

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

Issue 2622713002: Remove bitmap_platform_device_skia (Closed)
Patch Set: Win build fix Created 3 years, 11 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_skia.h ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "skia/ext/bitmap_platform_device_skia.h"
6 #include "skia/ext/platform_canvas.h"
7
8 namespace skia {
9
10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
11 bool is_opaque) {
12 return Create(width, height, is_opaque, nullptr);
13 }
14
15 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
16 bool is_opaque,
17 uint8_t* data) {
18 SkBitmap bitmap;
19 bitmap.setInfo(SkImageInfo::MakeN32(width, height,
20 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType));
21
22 if (data) {
23 bitmap.setPixels(data);
24 } else {
25 if (!bitmap.tryAllocPixels())
26 return nullptr;
27 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if
28 // it is not opaque.
29 if (!is_opaque)
30 bitmap.eraseARGB(0, 0, 0, 0);
31 }
32
33 return new BitmapPlatformDevice(bitmap);
34 }
35
36 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap)
37 : SkBitmapDevice(bitmap) {
38 SetPlatformDevice(this, this);
39 }
40
41 BitmapPlatformDevice::~BitmapPlatformDevice() {
42 }
43
44 SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const CreateInfo& info,
45 const SkPaint*) {
46 SkASSERT(info.fInfo.colorType() == kN32_SkColorType);
47 return BitmapPlatformDevice::Create(info.fInfo.width(), info.fInfo.height(),
48 info.fInfo.isOpaque());
49 }
50
51 // PlatformCanvas impl
52
53 std::unique_ptr<SkCanvas> CreatePlatformCanvasWithPixels(
54 int width,
55 int height,
56 bool is_opaque,
57 uint8_t* data,
58 OnFailureType failureType) {
59 sk_sp<SkBaseDevice> dev(
60 BitmapPlatformDevice::Create(width, height, is_opaque, data));
61 return CreateCanvas(dev, failureType);
62 }
63
64 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_skia.h ('k') | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698