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

Side by Side Diff: include/core/SkImageDecoder.h

Issue 19109002: Add the lazy decoder from PictureFlags to SkImageDecoder (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove unnecessary dependency Created 7 years, 5 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.cpp » ('j') | src/images/SkImageDecoder.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 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 #ifndef SkImageDecoder_DEFINED 10 #ifndef SkImageDecoder_DEFINED
11 #define SkImageDecoder_DEFINED 11 #define SkImageDecoder_DEFINED
12 12
13 #include "SkBitmap.h" 13 #include "SkBitmap.h"
14 #include "SkBitmapFactory.h" 14 #include "SkBitmapFactory.h"
15 #include "SkImage.h" 15 #include "SkImage.h"
16 #include "SkLruImageCache.h"
16 #include "SkRect.h" 17 #include "SkRect.h"
17 #include "SkRefCnt.h" 18 #include "SkRefCnt.h"
18 #include "SkTypes.h" 19 #include "SkTypes.h"
19 20
20 class SkStream; 21 class SkStream;
21 22
22 /** \class SkImageDecoder 23 /** \class SkImageDecoder
23 24
24 Base class for decoding compressed images into a SkBitmap 25 Base class for decoding compressed images into a SkBitmap
25 */ 26 */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 */ 91 */
91 void setRequireUnpremultipliedColors(bool request) { 92 void setRequireUnpremultipliedColors(bool request) {
92 fRequireUnpremultipliedColors = request; 93 fRequireUnpremultipliedColors = request;
93 } 94 }
94 95
95 /** Returns true if the decoder will only return bitmaps with unpremultiplie d 96 /** Returns true if the decoder will only return bitmaps with unpremultiplie d
96 colors. 97 colors.
97 */ 98 */
98 bool getRequireUnpremultipliedColors() const { return fRequireUnpremultiplie dColors; } 99 bool getRequireUnpremultipliedColors() const { return fRequireUnpremultiplie dColors; }
99 100
101 /**
102 * Returns a pointer to the LRU cache used by LazyDecodeBitmap.
103 */
104 static SkLruImageCache* getLruImageCache() {
scroggo 2013/07/15 15:09:28 This does not generally relate to SkImageDecoder,
105 return &fLruImageCache;
scroggo 2013/07/15 15:09:28 SkImageDecoder.h is built by chromium, but SkImage
106 }
107
100 /** \class Peeker 108 /** \class Peeker
101 109
102 Base class for optional callbacks to retrieve meta/chunk data out of 110 Base class for optional callbacks to retrieve meta/chunk data out of
103 an image as it is being decoded. 111 an image as it is being decoded.
104 */ 112 */
105 class Peeker : public SkRefCnt { 113 class Peeker : public SkRefCnt {
106 public: 114 public:
107 SK_DECLARE_INST_COUNT(Peeker) 115 SK_DECLARE_INST_COUNT(Peeker)
108 116
109 /** Return true to continue decoding, or false to indicate an error, whi ch 117 /** Return true to continue decoding, or false to indicate an error, whi ch
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 */ 309 */
302 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap, 310 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
303 SkBitmap::Config prefConfig, Mode, 311 SkBitmap::Config prefConfig, Mode,
304 Format* format = NULL); 312 Format* format = NULL);
305 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){ 313 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){
306 return DecodeMemory(buffer, size, bitmap, SkBitmap::kNo_Config, 314 return DecodeMemory(buffer, size, bitmap, SkBitmap::kNo_Config,
307 kDecodePixels_Mode, NULL); 315 kDecodePixels_Mode, NULL);
308 } 316 }
309 317
310 /** 318 /**
319 * Decode the image with DecodeMemoryToTarget but defer the process until it is needed.
320 */
321 static bool LazyDecodeBitmap(const void* buffer, size_t size, SkBitmap* bitm ap);
scroggo 2013/07/15 15:09:28 I support moving LazyDecodeBitmap to a header file
322
323 /**
311 * Decode memory. 324 * Decode memory.
312 * @param info Output parameter. Returns info about the encoded image. 325 * @param info Output parameter. Returns info about the encoded image.
313 * @param target Contains the address of pixel memory to decode into 326 * @param target Contains the address of pixel memory to decode into
314 * (which must be large enough to hold the width in info) and 327 * (which must be large enough to hold the width in info) and
315 * the row bytes to use. If NULL, returns info and does not 328 * the row bytes to use. If NULL, returns info and does not
316 * decode pixels. 329 * decode pixels.
317 * @return bool Whether the function succeeded. 330 * @return bool Whether the function succeeded.
318 * 331 *
319 * Sample usage: 332 * Sample usage:
320 * <code> 333 * <code>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 Chooser* fChooser; 474 Chooser* fChooser;
462 SkBitmap::Allocator* fAllocator; 475 SkBitmap::Allocator* fAllocator;
463 int fSampleSize; 476 int fSampleSize;
464 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false 477 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
465 SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true 478 SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true
466 bool fDitherImage; 479 bool fDitherImage;
467 bool fUsePrefTable; 480 bool fUsePrefTable;
468 mutable bool fShouldCancelDecode; 481 mutable bool fShouldCancelDecode;
469 bool fPreferQualityOverSpeed; 482 bool fPreferQualityOverSpeed;
470 bool fRequireUnpremultipliedColors; 483 bool fRequireUnpremultipliedColors;
484
485 static SkLruImageCache fLruImageCache;
486 static SkBitmapFactory fLazyBitmapFactory;
487
471 }; 488 };
472 489
473 /** Calling newDecoder with a stream returns a new matching imagedecoder 490 /** Calling newDecoder with a stream returns a new matching imagedecoder
474 instance, or NULL if none can be found. The caller must manage its ownership 491 instance, or NULL if none can be found. The caller must manage its ownership
475 of the stream as usual, calling unref() when it is done, as the returned 492 of the stream as usual, calling unref() when it is done, as the returned
476 decoder may have called ref() (and if so, the decoder is responsible for 493 decoder may have called ref() (and if so, the decoder is responsible for
477 balancing its ownership when it is destroyed). 494 balancing its ownership when it is destroyed).
478 */ 495 */
479 class SkImageDecoderFactory : public SkRefCnt { 496 class SkImageDecoderFactory : public SkRefCnt {
480 public: 497 public:
(...skipping 29 matching lines...) Expand all
510 // not all of these will be available 527 // not all of these will be available
511 DECLARE_DECODER_CREATOR(BMPImageDecoder); 528 DECLARE_DECODER_CREATOR(BMPImageDecoder);
512 DECLARE_DECODER_CREATOR(GIFImageDecoder); 529 DECLARE_DECODER_CREATOR(GIFImageDecoder);
513 DECLARE_DECODER_CREATOR(ICOImageDecoder); 530 DECLARE_DECODER_CREATOR(ICOImageDecoder);
514 DECLARE_DECODER_CREATOR(JPEGImageDecoder); 531 DECLARE_DECODER_CREATOR(JPEGImageDecoder);
515 DECLARE_DECODER_CREATOR(PNGImageDecoder); 532 DECLARE_DECODER_CREATOR(PNGImageDecoder);
516 DECLARE_DECODER_CREATOR(WBMPImageDecoder); 533 DECLARE_DECODER_CREATOR(WBMPImageDecoder);
517 DECLARE_DECODER_CREATOR(WEBPImageDecoder); 534 DECLARE_DECODER_CREATOR(WEBPImageDecoder);
518 535
519 #endif 536 #endif
OLDNEW
« no previous file with comments | « no previous file | src/images/SkImageDecoder.cpp » ('j') | src/images/SkImageDecoder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698