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

Side by Side Diff: include/codec/SkScaledCodec.h

Issue 1287423002: Scanline decoding for bmp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed nit Created 5 years, 3 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 | « dm/DMSrcSink.cpp ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #ifndef SkScaledCodec_DEFINED 7 #ifndef SkScaledCodec_DEFINED
8 #define SkScaledCodec_DEFINED 8 #define SkScaledCodec_DEFINED
9 9
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 22 matching lines...) Expand all
33 if (dstInfo.height() != srcInfo.height()) { 33 if (dstInfo.height() != srcInfo.height()) {
34 return false; 34 return false;
35 } 35 }
36 // only support down sampling, dstWidth cannot be larger that srcWidth 36 // only support down sampling, dstWidth cannot be larger that srcWidth
37 if(dstInfo.width() > srcInfo.width()) { 37 if(dstInfo.width() > srcInfo.width()) {
38 return false; 38 return false;
39 } 39 }
40 return true; 40 return true;
41 } 41 }
42 42
43 /*
44 * Returns the first coordinate that we will keep during sampling.
45 * The output can be interpreted as an x-coordinate or a y-coordinate.
46 *
47 * This does not need to be called and is not called when sampleFactor == 1.
djsollen 2015/08/28 20:21:03 not sure this comment makes sense when it is a pub
48 */
49 static int GetStartCoord(int sampleFactor) { return sampleFactor / 2; };
50
51 /*
52 * Given a coordinate in the original image, this returns the corresponding
53 * coordinate in the scaled image. This function is meaningless if
54 * IsCoordNecessary returns false.
55 * The output can be interpreted as an x-coordinate or a y-coordinate.
56 *
57 * This does not need to be called and is not called when sampleFactor == 1.
djsollen 2015/08/28 20:21:03 same here.
58 */
59 static int GetDstCoord(int srcCoord, int sampleFactor) { return srcCoord / s ampleFactor; };
djsollen 2015/08/28 20:21:02 why do these functions need to be in the public AP
60
61 /*
62 * When sampling, we will discard certain y-coordinates (rows) and
63 * x-coordinates (columns). This function returns true if we should keep th e
64 * coordinate and false otherwise.
65 * The inputs may be x-coordinates or y-coordinates.
66 *
67 * This does not need to be called and is not called when sampleFactor == 1.
68 */
69 static bool IsCoordNecessary(int srcCoord, int sampleFactor, int scaledDim);
70
43 static void ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo, 71 static void ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
44 int* sampleSizeX, int* sampleSizeY); 72 int* sampleSizeX, int* sampleSizeY);
45 73
46 protected: 74 protected:
47 /** 75 /**
48 * Recommend a set of destination dimensions given a requested scale 76 * Recommend a set of destination dimensions given a requested scale
49 */ 77 */
50 SkISize onGetScaledDimensions(float desiredScale) const override; 78 SkISize onGetScaledDimensions(float desiredScale) const override;
51 79
52 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*) 80 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*)
53 override; 81 override;
54 SkEncodedFormat onGetEncodedFormat() const override { 82 SkEncodedFormat onGetEncodedFormat() const override {
55 return fScanlineDecoder->getEncodedFormat(); 83 return fScanlineDecoder->getEncodedFormat();
56 } 84 }
57 85
58 bool onReallyHasAlpha() const override { 86 bool onReallyHasAlpha() const override {
59 return fScanlineDecoder->reallyHasAlpha(); 87 return fScanlineDecoder->reallyHasAlpha();
60 } 88 }
61 89
62 private: 90 private:
63 91
64 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder; 92 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder;
65 93
66 explicit SkScaledCodec(SkScanlineDecoder*); 94 explicit SkScaledCodec(SkScanlineDecoder*);
67 95
68 typedef SkCodec INHERITED; 96 typedef SkCodec INHERITED;
69 }; 97 };
70 #endif // SkScaledCodec_DEFINED 98 #endif // SkScaledCodec_DEFINED
OLDNEW
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698