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

Unified Diff: src/codec/SkCodec_wbmp.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use aligned memory in swizzler test Created 5 years, 2 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 | « src/codec/SkCodec_wbmp.h ('k') | src/codec/SkJpegCodec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_wbmp.cpp
diff --git a/src/codec/SkCodec_wbmp.cpp b/src/codec/SkCodec_wbmp.cpp
index d7f446bb5766558eb2f4e5f91f2f99071ec7f740..14b720988f8b554ed8b73382f66da53f83d32405 100644
--- a/src/codec/SkCodec_wbmp.cpp
+++ b/src/codec/SkCodec_wbmp.cpp
@@ -86,11 +86,8 @@ SkSwizzler* SkWbmpCodec::initializeSwizzler(const SkImageInfo& info,
opts.fZeroInitialized);
}
-SkCodec::Result SkWbmpCodec::readRow(uint8_t* row) {
- if (this->stream()->read(row, fSrcRowBytes) != fSrcRowBytes) {
- return kIncompleteInput;
- }
- return kSuccess;
+bool SkWbmpCodec::readRow(uint8_t* row) {
+ return this->stream()->read(row, fSrcRowBytes) == fSrcRowBytes;
}
SkWbmpCodec::SkWbmpCodec(const SkImageInfo& info, SkStream* stream)
@@ -109,7 +106,8 @@ SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
size_t rowBytes,
const Options& options,
SkPMColor ctable[],
- int* ctableCount) {
+ int* ctableCount,
+ int* rowsDecoded) {
if (options.fSubset) {
// Subsets are not supported.
return kUnimplemented;
@@ -133,9 +131,9 @@ SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
SkAutoTMalloc<uint8_t> src(fSrcRowBytes);
void* dstRow = dst;
for (int y = 0; y < size.height(); ++y) {
- Result rowResult = this->readRow(src.get());
- if (kSuccess != rowResult) {
- return rowResult;
+ if (!this->readRow(src.get())) {
+ *rowsDecoded = y;
+ return kIncompleteInput;
}
swizzler->swizzle(dstRow, src.get());
dstRow = SkTAddOffset<void>(dstRow, rowBytes);
@@ -158,17 +156,16 @@ SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) {
return new SkWbmpCodec(info, streamDeleter.detach());
}
-SkCodec::Result SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
+int SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
void* dstRow = dst;
for (int y = 0; y < count; ++y) {
- Result rowResult = this->readRow(fSrcBuffer.get());
- if (kSuccess != rowResult) {
- return rowResult;
+ if (!this->readRow(fSrcBuffer.get())) {
+ return y;
}
fSwizzler->swizzle(dstRow, fSrcBuffer.get());
dstRow = SkTAddOffset<void>(dstRow, dstRowBytes);
}
- return kSuccess;
+ return count;
}
SkCodec::Result SkWbmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
@@ -201,4 +198,3 @@ SkCodec::Result SkWbmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
return kSuccess;
}
-
« no previous file with comments | « src/codec/SkCodec_wbmp.h ('k') | src/codec/SkJpegCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698