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

Side by Side Diff: src/codec/SkBmpRLECodec.cpp

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 | « src/codec/SkBmpMaskCodec.cpp ('k') | src/codec/SkBmpStandardCodec.cpp » ('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 7
8 #include "SkBmpRLECodec.h" 8 #include "SkBmpRLECodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 fRLEBytes = remainingBytes + additionalBytes; 189 fRLEBytes = remainingBytes + additionalBytes;
190 return fRLEBytes; 190 return fRLEBytes;
191 } 191 }
192 192
193 /* 193 /*
194 * Set an RLE pixel using the color table 194 * Set an RLE pixel using the color table
195 */ 195 */
196 void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes, 196 void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes,
197 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, 197 const SkImageInfo& dstInfo, uint32_t x, uint32_t y,
198 uint8_t index) { 198 uint8_t index) {
199 if (is_coord_necessary(x, fSampleX, dstInfo.width())) { 199 if (is_coord_necessary(x, fSampleX, this->subsetWidth(), this->subsetLeft()) ) {
200 // Set the row 200 // Set the row
201 uint32_t row = this->getDstRow(y, dstInfo.height()); 201 uint32_t row = this->getDstRow(y, dstInfo.height());
202 202
203 // Set the pixel based on destination color type 203 // Set the pixel based on destination color type
204 const int dstX = get_dst_coord(x, fSampleX); 204 const int dstX = get_dst_coord(x, fSampleX);
205 switch (dstInfo.colorType()) { 205 switch (dstInfo.colorType()) {
206 case kN32_SkColorType: { 206 case kN32_SkColorType: {
207 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst RowBytes); 207 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst RowBytes);
208 dstRow[dstX] = fColorTable->operator[](index); 208 dstRow[dstX] = fColorTable->operator[](index);
209 break; 209 break;
(...skipping 12 matching lines...) Expand all
222 } 222 }
223 } 223 }
224 224
225 /* 225 /*
226 * Set an RLE pixel from R, G, B values 226 * Set an RLE pixel from R, G, B values
227 */ 227 */
228 void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes, 228 void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes,
229 const SkImageInfo& dstInfo, uint32_t x, 229 const SkImageInfo& dstInfo, uint32_t x,
230 uint32_t y, uint8_t red, uint8_t green, 230 uint32_t y, uint8_t red, uint8_t green,
231 uint8_t blue) { 231 uint8_t blue) {
232 if (is_coord_necessary(x, fSampleX, dstInfo.width())) { 232 if (is_coord_necessary(x, fSampleX, this->subsetWidth(), this->subsetLeft()) ) {
233 // Set the row 233 // Set the row
234 uint32_t row = this->getDstRow(y, dstInfo.height()); 234 uint32_t row = this->getDstRow(y, dstInfo.height());
235 235
236 // Set the pixel based on destination color type 236 // Set the pixel based on destination color type
237 const int dstX = get_dst_coord(x, fSampleX); 237 const int dstX = get_dst_coord(x, fSampleX);
238 switch (dstInfo.colorType()) { 238 switch (dstInfo.colorType()) {
239 case kN32_SkColorType: { 239 case kN32_SkColorType: {
240 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst RowBytes); 240 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst RowBytes);
241 dstRow[dstX] = SkPackARGB32NoCheck(0xFF, red, green, blue); 241 dstRow[dstX] = SkPackARGB32NoCheck(0xFF, red, green, blue);
242 break; 242 break;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 fSampler.reset(new SkBmpRLESampler(this)); 506 fSampler.reset(new SkBmpRLESampler(this));
507 } 507 }
508 508
509 return fSampler; 509 return fSampler;
510 } 510 }
511 511
512 int SkBmpRLECodec::setSampleX(int sampleX) { 512 int SkBmpRLECodec::setSampleX(int sampleX) {
513 fSampleX = sampleX; 513 fSampleX = sampleX;
514 return get_scaled_dimension(this->getInfo().width(), sampleX); 514 return get_scaled_dimension(this->getInfo().width(), sampleX);
515 } 515 }
OLDNEW
« no previous file with comments | « src/codec/SkBmpMaskCodec.cpp ('k') | src/codec/SkBmpStandardCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698