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

Side by Side Diff: tools/SkBitmapRegionDecoderPriv.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 unified diff | Download patch
« no previous file with comments | « tools/SkBitmapRegionDecoderInterface.cpp ('k') | tools/SkBitmapRegionSampler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkBitmapRegionDecoderPriv_DEFINED
9 #define SkBitmapRegionDecoderPriv_DEFINED
10
11 /*
12 * Chooses the correct image subset offsets and dimensions for the partial decod e.
13 *
14 * @return true if the subset is completely contained within the image
15 * false otherwise
16 */
17 inline bool set_subset_region(int inputOffset, int inputDimension,
18 int imageOriginalDimension, int* imageSubsetOffset, int* outOffset,
19 int* imageSubsetDimension) {
20
21 // This must be at least zero, we can't start decoding the image at a negati ve coordinate.
22 *imageSubsetOffset = SkTMax(0, inputOffset);
23
24 // If inputOffset is less than zero, we decode to an offset location in the output bitmap.
25 *outOffset = *imageSubsetOffset - inputOffset;
26
27 // Use imageSusetOffset to make sure we don't decode pixels past the edge of the image.
28 // Use outOffset to make sure we don't decode pixels past the edge of the re gion.
29 *imageSubsetDimension = SkTMin(imageOriginalDimension - *imageSubsetOffset,
30 inputDimension - *outOffset);
31
32 return (*outOffset == 0) && (*imageSubsetDimension == inputDimension);
33 }
34
35 #endif // SkBitmapRegionDecoderPriv_DEFINED
OLDNEW
« no previous file with comments | « tools/SkBitmapRegionDecoderInterface.cpp ('k') | tools/SkBitmapRegionSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698