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 | 7 |
8 /* | 8 /* |
9 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 9 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
10 * | 10 * |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 if (firstAttempt) { | 286 if (firstAttempt) { |
287 // rowsDecoded reports how many rows have been initialized, so a layer a
bove | 287 // rowsDecoded reports how many rows have been initialized, so a layer a
bove |
288 // can fill the rest. In some cases, we fill the background before decod
ing | 288 // can fill the rest. In some cases, we fill the background before decod
ing |
289 // (or it is already filled for us), so we report rowsDecoded to be the
full | 289 // (or it is already filled for us), so we report rowsDecoded to be the
full |
290 // height. | 290 // height. |
291 bool filledBackground = false; | 291 bool filledBackground = false; |
292 if (frameContext->getRequiredFrame() == kNone) { | 292 if (frameContext->getRequiredFrame() == kNone) { |
293 // We may need to clear to transparent for one of the following reas
ons: | 293 // We may need to clear to transparent for one of the following reas
ons: |
294 // - The frameRect does not cover the full bounds. haveDecodedRow wi
ll | 294 // - The frameRect does not cover the full bounds. haveDecodedRow wi
ll |
295 // only draw inside the frameRect, so we need to clear the rest. | 295 // only draw inside the frameRect, so we need to clear the rest. |
296 // - There is a valid transparent pixel value. (FIXME: I'm assuming | |
297 // writeTransparentPixels will be false in this case, based on | |
298 // Chromium's assumption that it would already be zeroed. If we | |
299 // change that behavior, could we skip Filling here?) | |
300 // - The frame is interlaced. There is no obvious way to fill | 296 // - The frame is interlaced. There is no obvious way to fill |
301 // afterwards for an incomplete image. (FIXME: Does the first pass | 297 // afterwards for an incomplete image. (FIXME: Does the first pass |
302 // cover all rows? If so, we do not have to fill here.) | 298 // cover all rows? If so, we do not have to fill here.) |
303 // - There is no color table for this frame. In that case will not | 299 // - There is no color table for this frame. In that case will not |
304 // draw anything, so we need to fill. | 300 // draw anything, so we need to fill. |
305 if (frameContext->frameRect() != this->getInfo().bounds() | 301 if (frameContext->frameRect() != this->getInfo().bounds() |
306 || frameContext->transparentPixel() < SK_MAX_COLORS | |
307 || frameContext->interlaced() || !fCurrColorTableIsReal) { | 302 || frameContext->interlaced() || !fCurrColorTableIsReal) { |
308 // fill ignores the width (replaces it with the actual, scaled w
idth). | 303 // fill ignores the width (replaces it with the actual, scaled w
idth). |
309 // But we need to scale in Y. | 304 // But we need to scale in Y. |
310 const int scaledHeight = get_scaled_dimension(dstInfo.height(), | 305 const int scaledHeight = get_scaled_dimension(dstInfo.height(), |
311 fSwizzler->sampleY
()); | 306 fSwizzler->sampleY
()); |
312 auto fillInfo = dstInfo.makeWH(0, scaledHeight); | 307 auto fillInfo = dstInfo.makeWH(0, scaledHeight); |
313 fSwizzler->fill(fillInfo, fDst, fDstRowBytes, this->getFillValue
(dstInfo), | 308 fSwizzler->fill(fillInfo, fDst, fDstRowBytes, this->getFillValue
(dstInfo), |
314 opts.fZeroInitialized); | 309 opts.fZeroInitialized); |
315 filledBackground = true; | 310 filledBackground = true; |
316 } | 311 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 if (!fCurrColorTableIsReal) { | 477 if (!fCurrColorTableIsReal) { |
483 // No color table, so nothing to draw this frame. | 478 // No color table, so nothing to draw this frame. |
484 // FIXME: We can abort even earlier - no need to decode this frame. | 479 // FIXME: We can abort even earlier - no need to decode this frame. |
485 return true; | 480 return true; |
486 } | 481 } |
487 | 482 |
488 // The swizzler takes care of offsetting into the dst width-wise. | 483 // The swizzler takes care of offsetting into the dst width-wise. |
489 void* dstLine = SkTAddOffset<void>(fDst, dstRow * fDstRowBytes); | 484 void* dstLine = SkTAddOffset<void>(fDst, dstRow * fDstRowBytes); |
490 | 485 |
491 // We may or may not need to write transparent pixels to the buffer. | 486 // We may or may not need to write transparent pixels to the buffer. |
492 // If we're compositing against a previous image, it's wrong, and if | 487 // If we're compositing against a previous image, it's wrong, but if |
493 // we're writing atop a cleared, fully transparent buffer, it's | 488 // we're decoding an interlaced gif and displaying it "Haeberli"-style, |
494 // unnecessary; but if we're decoding an interlaced gif and | 489 // we must write these for passes beyond the first, or the initial passes |
495 // displaying it "Haeberli"-style, we must write these for passes | 490 // will "show through" the later ones. |
496 // beyond the first, or the initial passes will "show through" the | |
497 // later ones. | |
498 const auto dstInfo = this->dstInfo(); | 491 const auto dstInfo = this->dstInfo(); |
499 if (writeTransparentPixels || dstInfo.colorType() == kRGB_565_SkColorType) { | 492 if (writeTransparentPixels || dstInfo.colorType() == kRGB_565_SkColorType) { |
500 fSwizzler->swizzle(dstLine, rowBegin); | 493 fSwizzler->swizzle(dstLine, rowBegin); |
501 } else { | 494 } else { |
502 // We cannot swizzle directly into the dst, since that will write the tr
ansparent pixels. | 495 // We cannot swizzle directly into the dst, since that will write the tr
ansparent pixels. |
503 // Instead, swizzle into a temporary buffer, and copy that into the dst. | 496 // Instead, swizzle into a temporary buffer, and copy that into the dst. |
504 { | 497 { |
505 void* const memsetDst = fTmpBuffer.get(); | 498 void* const memsetDst = fTmpBuffer.get(); |
506 // Although onGetFillValue returns a uint64_t, we only use the low e
ight bits. The | 499 // Although onGetFillValue returns a uint64_t, we only use the low e
ight bits. The |
507 // return value is either an 8 bit index (for index8) or SK_ColorTRA
NSPARENT, which is | 500 // return value is either an 8 bit index (for index8) or SK_ColorTRA
NSPARENT, which is |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 void* copiedLine = SkTAddOffset<void>(dstLine, fSwizzler->swizzleOffsetB
ytes()); | 555 void* copiedLine = SkTAddOffset<void>(dstLine, fSwizzler->swizzleOffsetB
ytes()); |
563 void* dst = copiedLine; | 556 void* dst = copiedLine; |
564 for (unsigned i = 1; i < repeatCount; i++) { | 557 for (unsigned i = 1; i < repeatCount; i++) { |
565 dst = SkTAddOffset<void>(dst, fDstRowBytes); | 558 dst = SkTAddOffset<void>(dst, fDstRowBytes); |
566 memcpy(dst, copiedLine, bytesToCopy); | 559 memcpy(dst, copiedLine, bytesToCopy); |
567 } | 560 } |
568 } | 561 } |
569 | 562 |
570 return true; | 563 return true; |
571 } | 564 } |
OLD | NEW |