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

Unified Diff: src/codec/SkCodecPriv.h

Issue 1321433002: Add subsetting to SkScaledCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@gif-scan
Patch Set: Rebase - it compiles but I'm sure everything is broken 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.cpp ('k') | src/codec/SkCodec_libgif.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodecPriv.h
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index ea4aa0e092197429e183aac9bf83461c50210301..b4ccf369d4004327982e03f633bbe0d0653e7a3e 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -31,6 +31,18 @@
#define COMPUTE_RESULT_ALPHA \
SkSwizzler::GetResult(zeroAlpha, maxAlpha);
+inline bool is_valid_subset(const SkIRect* subset, const SkISize& imageDims) {
+ if (0 > subset->left() || subset->left() >= imageDims.width() ||
+ 0 > subset->top() || subset->top() >= imageDims.height() ||
+ 0 > subset->width() || subset->left() + subset->width() > imageDims.width() ||
+ 0 > subset->height() || subset->top() + subset->height() > imageDims.height()) {
+ return false;
+ }
+ return true;
+}
+
+inline float get_scale(uint32_t sampleSize) { return 1.0f / (float) sampleSize; }
+
/*
* returns a scaled dimension based on the original dimension and the sampleSize
* NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder
@@ -68,12 +80,13 @@ inline int get_dst_coord(int srcCoord, int sampleFactor) { return srcCoord / sam
*
* This does not need to be called and is not called when sampleFactor == 1.
*/
-inline bool is_coord_necessary(int srcCoord, int sampleFactor, int scaledDim) {
+inline bool is_coord_necessary(int srcCoord, int sampleFactor, int scaledDim, int subsetOffset) {
// Get the first coordinate that we want to keep
- int startCoord = get_start_coord(sampleFactor);
+ int startCoord = get_start_coord(sampleFactor) + subsetOffset;
// Return false on edge cases
- if (srcCoord < startCoord || get_dst_coord(srcCoord, sampleFactor) >= scaledDim) {
+ if (srcCoord < startCoord ||
+ get_dst_coord(srcCoord - subsetOffset, sampleFactor) >= scaledDim) {
return false;
}
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libgif.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698