diff options
author | Matt Sarett <msarett@google.com> | 2017-04-27 20:08:39 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-27 20:08:45 +0000 |
commit | 0122af08f6af0dee490e1a4f35b552377d0d4753 (patch) | |
tree | dc2a227b525f067fe8c837cc8d4c5c3480cb69de /include/core/SkBitmap.h | |
parent | 4b32ab1b7cac09f42b0867f6c63cd8656dd9918d (diff) |
Revert "Delete copyTo(Allocator), hide copyTo() behind flag"
This reverts commit d4a338f4d0a0cdc08d7d3668931c60997f0fa971.
Reason for revert: Looks like I missed something I was supposed to delete in Android.
Original change's description:
> Delete copyTo(Allocator), hide copyTo() behind flag
>
> Replace uses of copyTo() in Skia.
>
> Bug: skia:6464
> Change-Id: I921dc53a1c29a5176d18f05741f7c0b5a008e548
> Reviewed-on: https://skia-review.googlesource.com/14502
> Commit-Queue: Matt Sarett <msarett@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
>
TBR=msarett@google.com,reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I4d252940cc6a2462b030007055ea6c229471fc6e
Reviewed-on: https://skia-review.googlesource.com/14602
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'include/core/SkBitmap.h')
-rw-r--r-- | include/core/SkBitmap.h | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index d38898ccef..8818829a41 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -552,15 +552,39 @@ public: */ bool extractSubset(SkBitmap* dst, const SkIRect& subset) const; -#ifdef SK_SUPPORT_LEGACY_BITMAP_COPYTO +#ifdef SK_BUILD_FOR_ANDROID + /** Makes a deep copy of this bitmap, respecting the requested colorType, + * and allocating the dst pixels on the cpu. + * Returns false if either there is an error (i.e. the src does not have + * pixels) or the request cannot be satisfied (e.g. the src has per-pixel + * alpha, and the requested colortype does not support alpha). + * @param dst The bitmap to be sized and allocated + * @param ct The desired colorType for dst + * @param allocator Allocator used to allocate the pixelref for the dst + * bitmap. If this is null, the standard HeapAllocator + * will be used. + * @return true if the copy was made. + */ + bool copyTo(SkBitmap* dst, SkColorType ct, Allocator*) const; + + bool copyTo(SkBitmap* dst, Allocator* allocator) const { + return this->copyTo(dst, this->colorType(), allocator); + } +#endif + + /** Makes a deep copy of this bitmap, respecting the requested colorType. + * Returns false if either there is an error (i.e. the src does not have + * pixels) or the request cannot be satisfied (e.g. the src has per-pixel + * alpha, and the requested colortype does not support alpha). + * @param dst The bitmap to be sized and allocated + * @param ct The desired colorType for dst + * @return true if the copy was made. + */ bool copyTo(SkBitmap* dst, SkColorType ct) const; + bool copyTo(SkBitmap* dst) const { return this->copyTo(dst, this->colorType()); } - bool deepCopyTo(SkBitmap* dst) const { - return this->copyTo(dst, this->colorType()); - } -#endif /** * Copy the bitmap's pixels into the specified buffer (pixels + rowBytes), @@ -601,6 +625,20 @@ public: return this->writePixels(src, 0, 0); } + /** + * Returns true if this bitmap's pixels can be converted into the requested + * colorType, such that copyTo() could succeed. + */ + bool canCopyTo(SkColorType colorType) const; + + /** Makes a deep copy of this bitmap, keeping the copied pixels + * in the same domain as the source: If the src pixels are allocated for + * the cpu, then so will the dst. If the src pixels are allocated on the + * gpu (typically as a texture), the it will do the same for the dst. + * If the request cannot be fulfilled, returns false and dst is unmodified. + */ + bool deepCopyTo(SkBitmap* dst) const; + #ifdef SK_BUILD_FOR_ANDROID bool hasHardwareMipMap() const { return (fFlags & kHasHardwareMipMap_Flag) != 0; @@ -698,8 +736,7 @@ private: uint8_t fFlags; bool writePixels(const SkPixmap& src, int x, int y, SkTransferFunctionBehavior behavior); - - bool canCopyTo(SkColorType colorType) const; + bool internalCopyTo(SkBitmap* dst, SkColorType ct, Allocator*) const; /* Unreference any pixelrefs or colortables */ |