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

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

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) Created 4 years, 9 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/SkAndroidCodec.cpp ('k') | src/codec/SkCodec.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 "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkBmpMaskCodec.h" 9 #include "SkBmpMaskCodec.h"
10 #include "SkBmpRLECodec.h" 10 #include "SkBmpRLECodec.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 *codecOut = new SkBmpStandardCodec(imageInfo, stream, bitsPerPix el, numColors, 502 *codecOut = new SkBmpStandardCodec(imageInfo, stream, bitsPerPix el, numColors,
503 bytesPerColor, offset - bytesRead, rowOrder, isOpaque, i nIco); 503 bytesPerColor, offset - bytesRead, rowOrder, isOpaque, i nIco);
504 return true; 504 return true;
505 case kBitMask_BmpInputFormat: 505 case kBitMask_BmpInputFormat:
506 // Bmp-in-Ico must be standard mode 506 // Bmp-in-Ico must be standard mode
507 if (inIco) { 507 if (inIco) {
508 SkCodecPrintf("Error: Icos may not use bit mask format.\n"); 508 SkCodecPrintf("Error: Icos may not use bit mask format.\n");
509 return false; 509 return false;
510 } 510 }
511 511
512 *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.detach(), 512 *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.release(),
513 rowOrder); 513 rowOrder);
514 return true; 514 return true;
515 case kRLE_BmpInputFormat: 515 case kRLE_BmpInputFormat:
516 // Bmp-in-Ico must be standard mode 516 // Bmp-in-Ico must be standard mode
517 // When inIco is true, this line cannot be reached, since we 517 // When inIco is true, this line cannot be reached, since we
518 // require that RLE Bmps have a valid number of totalBytes, and 518 // require that RLE Bmps have a valid number of totalBytes, and
519 // Icos skip the header that contains totalBytes. 519 // Icos skip the header that contains totalBytes.
520 SkASSERT(!inIco); 520 SkASSERT(!inIco);
521 *codecOut = new SkBmpRLECodec(imageInfo, stream, bitsPerPixel, n umColors, 521 *codecOut = new SkBmpRLECodec(imageInfo, stream, bitsPerPixel, n umColors,
522 bytesPerColor, offset - bytesRead, rowOrder, RLEBytes); 522 bytesPerColor, offset - bytesRead, rowOrder, RLEBytes);
(...skipping 11 matching lines...) Expand all
534 * Creates a bmp decoder 534 * Creates a bmp decoder
535 * Reads enough of the stream to determine the image format 535 * Reads enough of the stream to determine the image format
536 */ 536 */
537 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream, bool inIco) { 537 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream, bool inIco) {
538 SkAutoTDelete<SkStream> streamDeleter(stream); 538 SkAutoTDelete<SkStream> streamDeleter(stream);
539 SkCodec* codec = nullptr; 539 SkCodec* codec = nullptr;
540 if (ReadHeader(stream, inIco, &codec)) { 540 if (ReadHeader(stream, inIco, &codec)) {
541 // codec has taken ownership of stream, so we do not need to 541 // codec has taken ownership of stream, so we do not need to
542 // delete it. 542 // delete it.
543 SkASSERT(codec); 543 SkASSERT(codec);
544 streamDeleter.detach(); 544 streamDeleter.release();
545 return codec; 545 return codec;
546 } 546 }
547 return nullptr; 547 return nullptr;
548 } 548 }
549 549
550 SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream, 550 SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream,
551 uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder) 551 uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder)
552 : INHERITED(info, stream) 552 : INHERITED(info, stream)
553 , fBitsPerPixel(bitsPerPixel) 553 , fBitsPerPixel(bitsPerPixel)
554 , fRowOrder(rowOrder) 554 , fRowOrder(rowOrder)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 586 }
587 587
588 bool SkBmpCodec::skipRows(int count) { 588 bool SkBmpCodec::skipRows(int count) {
589 const size_t bytesToSkip = count * fSrcRowBytes; 589 const size_t bytesToSkip = count * fSrcRowBytes;
590 return this->stream()->skip(bytesToSkip) == bytesToSkip; 590 return this->stream()->skip(bytesToSkip) == bytesToSkip;
591 } 591 }
592 592
593 bool SkBmpCodec::onSkipScanlines(int count) { 593 bool SkBmpCodec::onSkipScanlines(int count) {
594 return this->skipRows(count); 594 return this->skipRows(count);
595 } 595 }
OLDNEW
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698