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

Unified Diff: src/core/SkBitmap.cpp

Issue 15489004: New API for encoding bitmaps during serialization. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments. Created 7 years, 7 months 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
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index fe4255d9b5e2ac41d267f62dfc178d48a12e3098..547f9acd3b7ca33afe41e8cd1e66d35cb93e7e47 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -866,18 +866,18 @@ static size_t getSubOffset(const SkBitmap& bm, int x, int y) {
* upper left corner of bm relative to its SkPixelRef.
* x and y must be non-NULL.
*/
-static bool getUpperLeftFromOffset(const SkBitmap& bm, int32_t* x, int32_t* y) {
+bool getUpperLeftFromOffset(SkBitmap::Config config, size_t offset, size_t rowBytes,
+ int32_t* x, int32_t* y) {
SkASSERT(x != NULL && y != NULL);
- const size_t offset = bm.pixelRefOffset();
if (0 == offset) {
*x = *y = 0;
return true;
}
// Use integer division to find the correct y position.
- *y = SkToS32(offset / bm.rowBytes());
+ *y = SkToS32(offset / rowBytes);
// The remainder will be the x position, after we reverse getSubOffset.
- *x = SkToS32(offset % bm.rowBytes());
- switch (bm.getConfig()) {
+ *x = SkToS32(offset % rowBytes);
+ switch (config) {
case SkBitmap::kA8_Config:
// Fall through.
case SkBitmap::kIndex8_Config:
@@ -904,6 +904,10 @@ static bool getUpperLeftFromOffset(const SkBitmap& bm, int32_t* x, int32_t* y) {
return true;
}
+static bool getUpperLeftFromOffset(const SkBitmap& bm, int32_t* x, int32_t* y) {
djsollen 2013/05/21 14:10:44 according to our style guide static methods should
scroggo 2013/05/21 16:14:15 Done.
+ return getUpperLeftFromOffset(bm.config(), bm.pixelRefOffset(), bm.rowBytes(), x, y);
+}
+
bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
SkDEBUGCODE(this->validate();)

Powered by Google App Engine
This is Rietveld 408576698