diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-10-12 16:24:03 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:05 +0100 |
commit | 478f290e45c9cbf49576889088ea4dd71972d64b (patch) | |
tree | ded03f7b1915015956f85581da68d83d05de8520 /external/skia/source | |
parent | 3a6f270edfffb97763927b2732feacedbdac1e80 (diff) |
initial build of the Skia library
Not quite complete yet, missing e.g. Vulkan sources, and the setup
is not completely correct either.
Change-Id: I2283bf12f0d226ff8a34554deae5a7bd69045971
Diffstat (limited to 'external/skia/source')
-rw-r--r-- | external/skia/source/SkMemory_malloc.cxx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/external/skia/source/SkMemory_malloc.cxx b/external/skia/source/SkMemory_malloc.cxx new file mode 100644 index 000000000000..9e2da3c20023 --- /dev/null +++ b/external/skia/source/SkMemory_malloc.cxx @@ -0,0 +1,68 @@ +/* + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/core/SkTypes.h" +#include "include/private/SkMalloc.h" + +#include <sal/log.hxx> +#include <rtl/alloc.h> + +// Based on SkMemory_malloc.cpp : + +static inline void sk_out_of_memory(size_t size) +{ + SAL_WARN("skia", "sk_out_of_memory (asked for " << size << " bytes)"); + abort(); +} + +static inline void* throw_on_failure(size_t size, void* p) +{ + if (size > 0 && p == nullptr) + { + // If we've got a nullptr here, the only reason we should have failed is running out of RAM. + sk_out_of_memory(size); + } + return p; +} + +void sk_abort_no_print() +{ + SAL_WARN("skia", "sk_abort_no_print"); + abort(); +} + +void sk_out_of_memory(void) +{ + SAL_WARN("skia", "sk_out_of_memory"); + abort(); +} + +void* sk_realloc_throw(void* addr, size_t size) +{ + return throw_on_failure(size, rtl_reallocateMemory(addr, size)); +} + +void sk_free(void* p) { rtl_freeMemory(p); } + +void* sk_malloc_flags(size_t size, unsigned flags) +{ + void* p; + if (flags & SK_MALLOC_ZERO_INITIALIZE) + { + p = rtl_allocateZeroMemory(size); + } + else + { + p = rtl_allocateMemory(size); + } + if (flags & SK_MALLOC_THROW) + { + return throw_on_failure(size, p); + } + else + { + return p; + } +} |