| 1 | /* | 
|---|
| 2 | * Copyright 2008 The Android Open Source Project | 
|---|
| 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 | #ifndef SkMallocPixelRef_DEFINED | 
|---|
| 9 | #define SkMallocPixelRef_DEFINED | 
|---|
| 10 |  | 
|---|
| 11 | #include "include/core/SkPixelRef.h" | 
|---|
| 12 | #include "include/core/SkRefCnt.h" | 
|---|
| 13 | #include "include/core/SkTypes.h" | 
|---|
| 14 | class SkData; | 
|---|
| 15 | struct SkImageInfo; | 
|---|
| 16 |  | 
|---|
| 17 | /** We explicitly use the same allocator for our pixels that SkMask does, | 
|---|
| 18 | so that we can freely assign memory allocated by one class to the other. | 
|---|
| 19 | */ | 
|---|
| 20 | namespace SkMallocPixelRef { | 
|---|
| 21 | /** | 
|---|
| 22 | *  Return a new SkMallocPixelRef, automatically allocating storage for the | 
|---|
| 23 | *  pixels. If rowBytes are 0, an optimal value will be chosen automatically. | 
|---|
| 24 | *  If rowBytes is > 0, then it will be respected, or NULL will be returned | 
|---|
| 25 | *  if rowBytes is invalid for the specified info. | 
|---|
| 26 | * | 
|---|
| 27 | *  All pixel bytes are zeroed. | 
|---|
| 28 | * | 
|---|
| 29 | *  Returns NULL on failure. | 
|---|
| 30 | */ | 
|---|
| 31 | SK_API sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes); | 
|---|
| 32 |  | 
|---|
| 33 | /** | 
|---|
| 34 | *  Return a new SkMallocPixelRef that will use the provided SkData and | 
|---|
| 35 | *  rowBytes as pixel storage.  The SkData will be ref()ed and on | 
|---|
| 36 | *  destruction of the PixelRef, the SkData will be unref()ed. | 
|---|
| 37 | * | 
|---|
| 38 | *  Returns NULL on failure. | 
|---|
| 39 | */ | 
|---|
| 40 | SK_API sk_sp<SkPixelRef> MakeWithData(const SkImageInfo&, size_t rowBytes, sk_sp<SkData> data); | 
|---|
| 41 | }  // namespace SkMallocPixelRef | 
|---|
| 42 | #endif | 
|---|
| 43 |  | 
|---|