2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2008 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkMallocPixelRef_DEFINED
|
|
|
|
#define SkMallocPixelRef_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPixelRef.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
2018-06-26 15:32:40 +00:00
|
|
|
class SkData;
|
|
|
|
struct SkImageInfo;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** We explicitly use the same allocator for our pixels that SkMask does,
|
|
|
|
so that we can freely assign memory allocated by one class to the other.
|
|
|
|
*/
|
2019-08-13 20:00:53 +00:00
|
|
|
namespace SkMallocPixelRef {
|
2013-12-13 19:45:58 +00:00
|
|
|
/**
|
|
|
|
* Return a new SkMallocPixelRef, automatically allocating storage for the
|
2014-01-06 17:08:27 +00:00
|
|
|
* pixels. If rowBytes are 0, an optimal value will be chosen automatically.
|
|
|
|
* If rowBytes is > 0, then it will be respected, or NULL will be returned
|
|
|
|
* if rowBytes is invalid for the specified info.
|
2013-12-13 19:45:58 +00:00
|
|
|
*
|
2019-04-12 16:50:39 +00:00
|
|
|
* All pixel bytes are zeroed.
|
2013-12-13 19:45:58 +00:00
|
|
|
*
|
|
|
|
* Returns NULL on failure.
|
|
|
|
*/
|
2019-08-13 20:00:53 +00:00
|
|
|
SK_API sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes);
|
2013-12-16 07:01:40 +00:00
|
|
|
|
2014-01-02 17:29:28 +00:00
|
|
|
/**
|
2019-04-05 15:33:04 +00:00
|
|
|
* Return a new SkMallocPixelRef that will use the provided SkData and
|
|
|
|
* rowBytes as pixel storage. The SkData will be ref()ed and on
|
|
|
|
* destruction of the PixelRef, the SkData will be unref()ed.
|
2014-01-02 17:29:28 +00:00
|
|
|
*
|
|
|
|
* Returns NULL on failure.
|
|
|
|
*/
|
2019-08-13 20:00:53 +00:00
|
|
|
SK_API sk_sp<SkPixelRef> MakeWithData(const SkImageInfo&, size_t rowBytes, sk_sp<SkData> data);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
#endif
|