OLD | NEW |
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 "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 SkDELETE(fImageIndex); | 111 SkDELETE(fImageIndex); |
112 } | 112 } |
113 | 113 |
114 virtual Format getFormat() const { | 114 virtual Format getFormat() const { |
115 return kJPEG_Format; | 115 return kJPEG_Format; |
116 } | 116 } |
117 | 117 |
118 protected: | 118 protected: |
119 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 119 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
120 virtual bool onBuildTileIndex(SkStream *stream, int *width, int *height) SK_
OVERRIDE; | 120 virtual bool onBuildTileIndex(SkStream *stream, int *width, int *height) SK_
OVERRIDE; |
121 virtual bool onDecodeRegion(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRI
DE; | 121 virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRI
DE; |
122 #endif | 122 #endif |
123 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; | 123 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; |
124 | 124 |
125 private: | 125 private: |
126 SkJPEGImageIndex* fImageIndex; | 126 SkJPEGImageIndex* fImageIndex; |
127 int fImageWidth; | 127 int fImageWidth; |
128 int fImageHeight; | 128 int fImageHeight; |
129 | 129 |
130 typedef SkImageDecoder INHERITED; | 130 typedef SkImageDecoder INHERITED; |
131 }; | 131 }; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 *width = cinfo->output_width; | 549 *width = cinfo->output_width; |
550 fImageWidth = *width; | 550 fImageWidth = *width; |
551 fImageHeight = *height; | 551 fImageHeight = *height; |
552 | 552 |
553 SkDELETE(fImageIndex); | 553 SkDELETE(fImageIndex); |
554 fImageIndex = imageIndex; | 554 fImageIndex = imageIndex; |
555 | 555 |
556 return true; | 556 return true; |
557 } | 557 } |
558 | 558 |
559 bool SkJPEGImageDecoder::onDecodeRegion(SkBitmap* bm, const SkIRect& region) { | 559 bool SkJPEGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) { |
560 if (NULL == fImageIndex) { | 560 if (NULL == fImageIndex) { |
561 return false; | 561 return false; |
562 } | 562 } |
563 jpeg_decompress_struct* cinfo = fImageIndex->cinfo(); | 563 jpeg_decompress_struct* cinfo = fImageIndex->cinfo(); |
564 | 564 |
565 SkIRect rect = SkIRect::MakeWH(fImageWidth, fImageHeight); | 565 SkIRect rect = SkIRect::MakeWH(fImageWidth, fImageHeight); |
566 if (!rect.intersect(region)) { | 566 if (!rect.intersect(region)) { |
567 // If the requested region is entirely outside the image return false | 567 // If the requested region is entirely outside the image return false |
568 return false; | 568 return false; |
569 } | 569 } |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1031 } |
1032 | 1032 |
1033 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1033 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
1034 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1034 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
1035 } | 1035 } |
1036 | 1036 |
1037 | 1037 |
1038 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory); | 1038 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory); |
1039 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_jpeg
); | 1039 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_jpeg
); |
1040 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact
ory); | 1040 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact
ory); |
OLD | NEW |