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

Unified Diff: src/images/SkImageDecoder_pkm.cpp

Issue 297853005: Change the PKM decoder to adhere to sampler size (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove some whitespace Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_pkm.cpp
diff --git a/src/images/SkImageDecoder_pkm.cpp b/src/images/SkImageDecoder_pkm.cpp
index 3d843ddf2515d22abd7e9d4a4d595f7bd8264b2f..c299c23548d603c4c57e6a0e30ca884fc3bd9ff7 100644
--- a/src/images/SkImageDecoder_pkm.cpp
+++ b/src/images/SkImageDecoder_pkm.cpp
@@ -7,6 +7,7 @@
#include "SkColorPriv.h"
#include "SkImageDecoder.h"
+#include "SkScaledBitmapSampler.h"
#include "SkStream.h"
#include "SkStreamHelpers.h"
#include "SkTypes.h"
@@ -50,7 +51,12 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
return false;
}
- bm->setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, kOpaque_SkAlphaType);
+ // Setup the sampler...
+ SkScaledBitmapSampler sampler(width, height, this->getSampleSize());
+
+ // Set the config...
+ bm->setConfig(SkBitmap::kARGB_8888_Config, sampler.scaledWidth(), sampler.scaledHeight(),
+ 0, kOpaque_SkAlphaType);
if (SkImageDecoder::kDecodeBounds_Mode == mode) {
return true;
}
@@ -62,6 +68,10 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
// Lock the pixels, since we're about to write to them...
SkAutoLockPixels alp(*bm);
+ if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) {
+ return false;
+ }
+
// Advance buffer past the header
buf += ETC_PKM_HEADER_SIZE;
@@ -76,14 +86,13 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
}
// Set each of the pixels...
- const uint8_t *src = reinterpret_cast<uint8_t *>(outRGBDataPtr);
- uint8_t *dst = reinterpret_cast<uint8_t *>(bm->getPixels());
- for (int i = 0; i < width*height; ++i) {
- *dst++ = src[2]; // B
- *dst++ = src[1]; // G
- *dst++ = src[0]; // R
- *dst++ = 0xFF; // Opaque alpha...
- src += 3;
+ const int srcRowBytes = width * 3;
+ const int dstHeight = sampler.scaledHeight();
+ const uint8_t *srcRow = reinterpret_cast<uint8_t *>(outRGBDataPtr);
+ srcRow += sampler.srcY0() * srcRowBytes;
+ for (int y = 0; y < dstHeight; ++y) {
+ sampler.next(srcRow);
+ srcRow += sampler.srcDY() * srcRowBytes;
}
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698