Index: include/core/SkBitmap.h |
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h |
index c0e299ab94ba8bc3c3caeefb3796b4d24e12de5a..2b900bef341ddbc678714c758b8c7d81e9abec0c 100644 |
--- a/include/core/SkBitmap.h |
+++ b/include/core/SkBitmap.h |
@@ -1,4 +1,3 @@ |
- |
/* |
* Copyright 2006 The Android Open Source Project |
* |
@@ -6,17 +5,19 @@ |
* found in the LICENSE file. |
*/ |
- |
#ifndef SkBitmap_DEFINED |
#define SkBitmap_DEFINED |
-#include "Sk64.h" |
#include "SkColor.h" |
#include "SkColorTable.h" |
#include "SkImageInfo.h" |
#include "SkPoint.h" |
#include "SkRefCnt.h" |
+#ifdef SK_SUPPORT_LEGACY_SK64 |
+ #include "Sk64.h" |
+#endif |
+ |
struct SkIRect; |
struct SkRect; |
class SkPaint; |
@@ -149,19 +150,37 @@ public: |
*/ |
size_t getSafeSize() const ; |
- /** Return the byte size of the pixels, based on the height and rowBytes. |
- This routine is slightly slower than getSize(), but does not truncate |
- the answer to 32bits. |
- */ |
+ /** |
+ * Return the full size of the bitmap, in bytes. |
+ */ |
+ int64_t computeSize64() const { |
+ return sk_64_mul(fHeight, fRowBytes); |
+ } |
+ |
+ /** |
+ * Return the number of bytes from the pointer returned by getPixels() |
+ * to the end of the allocated space in the buffer. This may be smaller |
+ * than computeSize64() if there is any rowbytes padding beyond the width. |
+ */ |
+ int64_t computeSafeSize64() const { |
+ return ComputeSafeSize64((Config)fConfig, fWidth, fHeight, fRowBytes); |
+ } |
+ |
+#ifdef SK_SUPPORT_LEGACY_SK64 |
+ SK_ATTR_DEPRECATED("use getSize64()") |
Sk64 getSize64() const { |
Sk64 size; |
- size.setMul(fHeight, fRowBytes); |
+ size.set64(this->computeSize64()); |
return size; |
} |
- /** Same as getSafeSize(), but does not truncate the answer to 32bits. |
- */ |
- Sk64 getSafeSize64() const ; |
+ SK_ATTR_DEPRECATED("use getSafeSize64()") |
+ Sk64 getSafeSize64() const { |
+ Sk64 size; |
+ size.set64(this->computeSafeSize64()); |
+ return size; |
+ } |
+#endif |
/** Returns true if this bitmap is marked as immutable, meaning that the |
contents of its pixels will not change for the lifetime of the bitmap. |
@@ -217,7 +236,7 @@ public: |
return ComputeBytesPerPixel(c) >> 1; |
} |
- static Sk64 ComputeSize64(Config, int width, int height); |
+ static int64_t ComputeSize64(Config, int width, int height); |
static size_t ComputeSize(Config, int width, int height); |
/** |
@@ -678,10 +697,10 @@ private: |
/* Internal computations for safe size. |
*/ |
- static Sk64 ComputeSafeSize64(Config config, |
- uint32_t width, |
- uint32_t height, |
- size_t rowBytes); |
+ static int64_t ComputeSafeSize64(Config config, |
+ uint32_t width, |
+ uint32_t height, |
+ size_t rowBytes); |
static size_t ComputeSafeSize(Config config, |
uint32_t width, |
uint32_t height, |