Flutter Engine
The Flutter Engine
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
61 SkASSERT_RELEASE(this->tryAlloc(info));
62}
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
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
static bool ByteSizeOverflowed(size_t byteSize)
Definition: SkImageInfo.h:588
size_t minRowBytes() const
Definition: SkImageInfo.h:517
size_t computeByteSize(size_t rowBytes) const
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63