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

Side by Side Diff: src/images/SkImageDecoder_libbmp.cpp

Issue 12834012: Update code to use helper function for better readability/searching. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/images/SkImageDecoder_libico.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 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "bmpdecoderhelper.h" 10 #include "bmpdecoderhelper.h"
(...skipping 19 matching lines...) Expand all
30 typedef SkImageDecoder INHERITED; 30 typedef SkImageDecoder INHERITED;
31 }; 31 };
32 32
33 /////////////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////////////
34 DEFINE_DECODER_CREATOR(BMPImageDecoder); 34 DEFINE_DECODER_CREATOR(BMPImageDecoder);
35 /////////////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////////////
36 36
37 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { 37 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) {
38 static const char kBmpMagic[] = { 'B', 'M' }; 38 static const char kBmpMagic[] = { 'B', 'M' };
39 39
40 size_t len = stream->getLength(); 40
41 char buffer[sizeof(kBmpMagic)]; 41 char buffer[sizeof(kBmpMagic)];
42 42
43 if (len > sizeof(kBmpMagic) && 43 if (stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) &&
44 stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) && 44 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) {
45 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) {
46 return SkNEW(SkBMPImageDecoder); 45 return SkNEW(SkBMPImageDecoder);
47 } 46 }
48 return NULL; 47 return NULL;
49 } 48 }
50 49
51 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory); 50 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory);
52 51
53 /////////////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////////////
54 53
55 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { 54 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const int dstHeight = sampler.scaledHeight(); 144 const int dstHeight = sampler.scaledHeight();
146 const uint8_t* srcRow = callback.rgb(); 145 const uint8_t* srcRow = callback.rgb();
147 146
148 srcRow += sampler.srcY0() * srcRowBytes; 147 srcRow += sampler.srcY0() * srcRowBytes;
149 for (int y = 0; y < dstHeight; y++) { 148 for (int y = 0; y < dstHeight; y++) {
150 sampler.next(srcRow); 149 sampler.next(srcRow);
151 srcRow += sampler.srcDY() * srcRowBytes; 150 srcRow += sampler.srcDY() * srcRowBytes;
152 } 151 }
153 return true; 152 return true;
154 } 153 }
OLDNEW
« no previous file with comments | « no previous file | src/images/SkImageDecoder_libico.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698