| OLD | NEW | 
|   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 SkSampler_DEFINED |   7 #ifndef SkSampler_DEFINED | 
|   8 #define SkSampler_DEFINED |   8 #define SkSampler_DEFINED | 
|   9  |   9  | 
|  10 #include "SkCodec.h" |  10 #include "SkCodec.h" | 
 |  11 #include "SkCodecPriv.h" | 
|  11 #include "SkTypes.h" |  12 #include "SkTypes.h" | 
|  12  |  13  | 
|  13 class SkSampler : public SkNoncopyable { |  14 class SkSampler : public SkNoncopyable { | 
|  14 public: |  15 public: | 
|  15     /** |  16     /** | 
|  16      *  Update the sampler to sample every sampleX'th pixel. Returns the |  17      *  Update the sampler to sample every sampleX'th pixel. Returns the | 
|  17      *  width after sampling. |  18      *  width after sampling. | 
|  18      */ |  19      */ | 
|  19     int setSampleX(int sampleX) { |  20     int setSampleX(int sampleX) { | 
|  20         return this->onSetSampleX(sampleX); |  21         return this->onSetSampleX(sampleX); | 
|  21     } |  22     } | 
|  22  |  23  | 
|  23     /** |  24     /** | 
|  24      *  Update the sampler to sample every sampleY'th row. |  25      *  Update the sampler to sample every sampleY'th row. | 
|  25      */ |  26      */ | 
|  26     void setSampleY(int sampleY) { |  27     void setSampleY(int sampleY) { | 
|  27         fSampleY = sampleY; |  28         fSampleY = sampleY; | 
|  28     } |  29     } | 
|  29  |  30  | 
|  30     /** |  31     /** | 
|  31      *  Retrieve the value set for sampleY. |  32      *  Retrieve the value set for sampleY. | 
|  32      */ |  33      */ | 
|  33     int sampleY() const { |  34     int sampleY() const { | 
|  34         return fSampleY; |  35         return fSampleY; | 
|  35     } |  36     } | 
|  36  |  37  | 
|  37     /** |  38     /** | 
|  38      *  Based on fSampleY, return whether this row belongs in the output. |  39      *  Based on fSampleY, return whether this row belongs in the output. | 
|  39      * |  40      * | 
|  40      *  @param row Row of the image, starting with the first row used in the |  41      *  @param row Row of the image, starting with the first row in the subset. | 
|  41      *      output. |  | 
|  42      */ |  42      */ | 
|  43     bool rowNeeded(int row) const { |  43     bool rowNeeded(int row) const { | 
|  44         return row % fSampleY == 0; |  44         return (row + get_start_coord(fSampleY)) % fSampleY == 0; | 
|  45     } |  45     } | 
|  46  |  46  | 
|  47     /** |  47     /** | 
|  48      * Fill the remainder of the destination with a single color |  48      * Fill the remainder of the destination with a single color | 
|  49      * |  49      * | 
|  50      * @param info |  50      * @param info | 
|  51      * Contains the color type of the rows to fill. |  51      * Contains the color type of the rows to fill. | 
|  52      * Contains the width of the destination rows to fill |  52      * Contains the width of the destination rows to fill | 
|  53      * Contains the number of rows that we need to fill. |  53      * Contains the number of rows that we need to fill. | 
|  54      * |  54      * | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  84     {} |  84     {} | 
|  85  |  85  | 
|  86     virtual ~SkSampler() {} |  86     virtual ~SkSampler() {} | 
|  87 private: |  87 private: | 
|  88     int fSampleY; |  88     int fSampleY; | 
|  89  |  89  | 
|  90     virtual int onSetSampleX(int) = 0; |  90     virtual int onSetSampleX(int) = 0; | 
|  91 }; |  91 }; | 
|  92  |  92  | 
|  93 #endif // SkSampler_DEFINED |  93 #endif // SkSampler_DEFINED | 
| OLD | NEW |