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

Side by Side Diff: src/core/SkRasterCanvasLayerAllocator.cpp

Issue 2309483002: WIP RasterCanvasLayerAllocator experiment 2
Patch Set: vend smart pointers to SkCanvas Created 4 years, 2 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 | « src/core/SkManagedBitmapDevice.cpp ('k') | src/gpu/SkGpuDevice.h » ('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 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkRasterCanvasLayerAllocator.h"
9
10 #include "SkBitmap.h"
11 #include "SkCanvas.h"
12 #include "SkManagedBitmapDevice.h"
13
14 SkRasterCanvasLayerAllocator::SkRasterCanvasLayerAllocator() { }
15
16 SkRasterCanvasLayerAllocator::~SkRasterCanvasLayerAllocator() { }
17
18 sk_sp<SkCanvas> SkRasterCanvasLayerAllocator::createCanvas(const SkImageInfo& in fo,
19 const SkSurfaceProps& props,
20 void* initialData) {
21 SkBaseDevice* device = makeDevice(info, props, initialData);
22 if (!device) {
23 return nullptr;
24 }
25 return sk_make_sp<SkCanvas>(device, this);
26 }
27
28
29 SkBaseDevice* SkRasterCanvasLayerAllocator::makeDevice(
30 const SkImageInfo& info,
31 const SkSurfaceProps& props,
32 void* initialData) {
33 SkBitmap bitmap;
34 size_t rowBytes;
35 void (*deallocator)(void*) = nullptr;
36 void* payload = nullptr;
37 void* pixels = this->allocateLayer(info, &rowBytes,
38 &deallocator, &payload,
39 initialData);
40 if (!pixels) {
41 return nullptr;
42 }
43 if (!bitmap.installPixels(info, pixels, rowBytes)) {
44 deallocator(payload);
45 return nullptr;
46 };
47
48 return new SkManagedBitmapDevice(bitmap, props, deallocator, payload);
49 }
50
OLDNEW
« no previous file with comments | « src/core/SkManagedBitmapDevice.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698