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

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

Issue 1472123002: Make SkCodec support peek() and read() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years 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/SkBmpCodec.h ('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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 enum BmpInputFormat { 49 enum BmpInputFormat {
50 kStandard_BmpInputFormat, 50 kStandard_BmpInputFormat,
51 kRLE_BmpInputFormat, 51 kRLE_BmpInputFormat,
52 kBitMask_BmpInputFormat, 52 kBitMask_BmpInputFormat,
53 kUnknown_BmpInputFormat 53 kUnknown_BmpInputFormat
54 }; 54 };
55 55
56 /* 56 /*
57 * Checks the start of the stream to see if the image is a bitmap 57 * Checks the start of the stream to see if the image is a bitmap
58 */ 58 */
59 bool SkBmpCodec::IsBmp(SkStream* stream) { 59 bool SkBmpCodec::IsBmp(const void* buffer, size_t bytesRead) {
60 // TODO: Support "IC", "PT", "CI", "CP", "BA" 60 // TODO: Support "IC", "PT", "CI", "CP", "BA"
61 const char bmpSig[] = { 'B', 'M' }; 61 const char bmpSig[] = { 'B', 'M' };
62 char buffer[sizeof(bmpSig)]; 62 return bytesRead >= sizeof(bmpSig) && !memcmp(buffer, bmpSig, sizeof(bmpSig) );
63 return stream->read(buffer, sizeof(bmpSig)) == sizeof(bmpSig) &&
64 !memcmp(buffer, bmpSig, sizeof(bmpSig));
65 } 63 }
66 64
67 /* 65 /*
68 * Assumes IsBmp was called and returned true 66 * Assumes IsBmp was called and returned true
69 * Creates a bmp decoder 67 * Creates a bmp decoder
70 * Reads enough of the stream to determine the image format 68 * Reads enough of the stream to determine the image format
71 */ 69 */
72 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream) { 70 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream) {
73 return SkBmpCodec::NewFromStream(stream, false); 71 return SkBmpCodec::NewFromStream(stream, false);
74 } 72 }
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); 558 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
561 } 559 }
562 560
563 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { 561 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
564 // Create a new image info representing the portion of the image to decode 562 // Create a new image info representing the portion of the image to decode
565 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ; 563 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ;
566 564
567 // Decode the requested rows 565 // Decode the requested rows
568 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); 566 return this->decodeRows(rowInfo, dst, rowBytes, this->options());
569 } 567 }
OLDNEW
« no previous file with comments | « src/codec/SkBmpCodec.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698