Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkAutoPixmapStorage.cpp
Go to the documentation of this file.
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 */
8
12
13#include <utility>
14
16
18 this->freeStorage();
19}
20
22 *this = std::move(other);
23}
24
26 this->fStorage = other.fStorage;
27 this->INHERITED::reset(other.info(), this->fStorage, other.rowBytes());
28
29 other.fStorage = nullptr;
30 other.INHERITED::reset();
31
32 return *this;
33}
34
35size_t SkAutoPixmapStorage::AllocSize(const SkImageInfo& info, size_t* rowBytes) {
36 size_t rb = info.minRowBytes();
37 if (rowBytes) {
38 *rowBytes = rb;
39 }
40 return info.computeByteSize(rb);
41}
42
44 this->freeStorage();
45
46 size_t rb;
47 size_t size = AllocSize(info, &rb);
49 return false;
50 }
51 void* pixels = sk_malloc_canfail(size);
52 if (nullptr == pixels) {
53 return false;
54 }
55 this->reset(info, pixels, rb);
56 fStorage = pixels;
57 return true;
58}
59
63
65 if (!fStorage) {
66 return nullptr;
67 }
68
69 void* data = fStorage;
70 fStorage = nullptr;
71 this->INHERITED::reset();
72
73 return data;
74}
75
77 if (!fStorage) {
78 return nullptr;
79 }
80
82 fStorage = nullptr;
83 this->INHERITED::reset();
84
85 return data;
86}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define SkASSERT_RELEASE(cond)
Definition SkAssert.h:100
static void * sk_malloc_canfail(size_t size)
Definition SkMalloc.h:93
static size_t AllocSize(const SkImageInfo &info, size_t *rowBytes)
bool tryAlloc(const SkImageInfo &)
void alloc(const SkImageInfo &)
SkAutoPixmapStorage & operator=(SkAutoPixmapStorage &&other)
sk_sp< SkData > detachPixelsAsData()
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
Definition SkData.cpp:107
size_t rowBytes() const
Definition SkPixmap.h:145
const SkImageInfo & info() const
Definition SkPixmap.h:135
size_t computeByteSize() const
Definition SkPixmap.h:231
void reset()
Definition SkPixmap.cpp:32
static bool ByteSizeOverflowed(size_t byteSize)
size_t minRowBytes() const
size_t computeByteSize(size_t rowBytes) const