Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: include/core/SkBitmap.h

Issue 113823003: remove Sk64 from public API, and start to remove usage internally (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/Sk64.h ('k') | include/core/SkMath.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « include/core/Sk64.h ('k') | include/core/SkMath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698