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

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

Issue 14567011: Test region decoding in skimage, plus fixes. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Small comment fix. Created 7 years, 7 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 | « src/images/SkImageDecoder_libpng.cpp ('k') | tools/skimage_main.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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 virtual ~SkWEBPImageDecoder() { 104 virtual ~SkWEBPImageDecoder() {
105 SkSafeUnref(fInputStream); 105 SkSafeUnref(fInputStream);
106 } 106 }
107 107
108 virtual Format getFormat() const SK_OVERRIDE { 108 virtual Format getFormat() const SK_OVERRIDE {
109 return kWEBP_Format; 109 return kWEBP_Format;
110 } 110 }
111 111
112 protected: 112 protected:
113 virtual bool onBuildTileIndex(SkStream *stream, int *width, int *height) SK_ OVERRIDE; 113 virtual bool onBuildTileIndex(SkStream *stream, int *width, int *height) SK_ OVERRIDE;
114 virtual bool onDecodeRegion(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRI DE; 114 virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRI DE;
115 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; 115 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
116 116
117 private: 117 private:
118 bool setDecodeConfig(SkBitmap* decodedBitmap, int width, int height); 118 bool setDecodeConfig(SkBitmap* decodedBitmap, int width, int height);
119 SkStream* fInputStream; 119 SkStream* fInputStream;
120 int fOrigWidth; 120 int fOrigWidth;
121 int fOrigHeight; 121 int fOrigHeight;
122 int fHasAlpha; 122 int fHasAlpha;
123 123
124 typedef SkImageDecoder INHERITED; 124 typedef SkImageDecoder INHERITED;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return true; 314 return true;
315 } 315 }
316 316
317 static bool is_config_compatible(const SkBitmap& bitmap) { 317 static bool is_config_compatible(const SkBitmap& bitmap) {
318 SkBitmap::Config config = bitmap.config(); 318 SkBitmap::Config config = bitmap.config();
319 return config == SkBitmap::kARGB_4444_Config || 319 return config == SkBitmap::kARGB_4444_Config ||
320 config == SkBitmap::kRGB_565_Config || 320 config == SkBitmap::kRGB_565_Config ||
321 config == SkBitmap::kARGB_8888_Config; 321 config == SkBitmap::kARGB_8888_Config;
322 } 322 }
323 323
324 bool SkWEBPImageDecoder::onDecodeRegion(SkBitmap* decodedBitmap, 324 bool SkWEBPImageDecoder::onDecodeSubset(SkBitmap* decodedBitmap,
325 const SkIRect& region) { 325 const SkIRect& region) {
326 SkIRect rect = SkIRect::MakeWH(fOrigWidth, fOrigHeight); 326 SkIRect rect = SkIRect::MakeWH(fOrigWidth, fOrigHeight);
327 327
328 if (!rect.intersect(region)) { 328 if (!rect.intersect(region)) {
329 // If the requested region is entirely outsides the image, return false 329 // If the requested region is entirely outsides the image, return false
330 return false; 330 return false;
331 } 331 }
332 332
333 const int sampleSize = this->getSampleSize(); 333 const int sampleSize = this->getSampleSize();
334 SkScaledBitmapSampler sampler(rect.width(), rect.height(), sampleSize); 334 SkScaledBitmapSampler sampler(rect.width(), rect.height(), sampleSize);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return SkImageDecoder::kUnknown_Format; 595 return SkImageDecoder::kUnknown_Format;
596 } 596 }
597 597
598 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 598 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
599 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 599 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
600 } 600 }
601 601
602 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory); 602 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory);
603 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp ); 603 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp );
604 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact ory); 604 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact ory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | tools/skimage_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698