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

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: 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') | 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 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"
19 #include "SkPurgeableImageCache.h"
caryclark 2013/07/12 18:29:39 this may be correct but why is it required? I don'
sglez 2013/07/13 04:11:27 Good catch. I was using it when trying to implemen
18 #include "SkTypes.h" 20 #include "SkTypes.h"
19 21
20 class SkStream; 22 class SkStream;
21 23
22 /** \class SkImageDecoder 24 /** \class SkImageDecoder
23 25
24 Base class for decoding compressed images into a SkBitmap 26 Base class for decoding compressed images into a SkBitmap
25 */ 27 */
26 class SkImageDecoder : public SkNoncopyable { 28 class SkImageDecoder : public SkNoncopyable {
27 public: 29 public:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 */ 92 */
91 void setRequireUnpremultipliedColors(bool request) { 93 void setRequireUnpremultipliedColors(bool request) {
92 fRequireUnpremultipliedColors = request; 94 fRequireUnpremultipliedColors = request;
93 } 95 }
94 96
95 /** Returns true if the decoder will only return bitmaps with unpremultiplie d 97 /** Returns true if the decoder will only return bitmaps with unpremultiplie d
96 colors. 98 colors.
97 */ 99 */
98 bool getRequireUnpremultipliedColors() const { return fRequireUnpremultiplie dColors; } 100 bool getRequireUnpremultipliedColors() const { return fRequireUnpremultiplie dColors; }
99 101
102 /**
103 * Returns a pointer to the LRU cache used by LazyDecodeBitmap.
104 */
105 static SkLruImageCache* getLruImageCache() {
106 return &fLruImageCache;
107 }
108
100 /** \class Peeker 109 /** \class Peeker
101 110
102 Base class for optional callbacks to retrieve meta/chunk data out of 111 Base class for optional callbacks to retrieve meta/chunk data out of
103 an image as it is being decoded. 112 an image as it is being decoded.
104 */ 113 */
105 class Peeker : public SkRefCnt { 114 class Peeker : public SkRefCnt {
106 public: 115 public:
107 SK_DECLARE_INST_COUNT(Peeker) 116 SK_DECLARE_INST_COUNT(Peeker)
108 117
109 /** Return true to continue decoding, or false to indicate an error, whi ch 118 /** 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 */ 310 */
302 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap, 311 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
303 SkBitmap::Config prefConfig, Mode, 312 SkBitmap::Config prefConfig, Mode,
304 Format* format = NULL); 313 Format* format = NULL);
305 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){ 314 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){
306 return DecodeMemory(buffer, size, bitmap, SkBitmap::kNo_Config, 315 return DecodeMemory(buffer, size, bitmap, SkBitmap::kNo_Config,
307 kDecodePixels_Mode, NULL); 316 kDecodePixels_Mode, NULL);
308 } 317 }
309 318
310 /** 319 /**
320 * Decode the image with DecodeMemoryToTarget but defer the process until it is needed.
321 */
322 static bool LazyDecodeBitmap(const void* buffer, size_t size, SkBitmap* bitm ap);
323
324 /**
311 * Decode memory. 325 * Decode memory.
312 * @param info Output parameter. Returns info about the encoded image. 326 * @param info Output parameter. Returns info about the encoded image.
313 * @param target Contains the address of pixel memory to decode into 327 * @param target Contains the address of pixel memory to decode into
314 * (which must be large enough to hold the width in info) and 328 * (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 329 * the row bytes to use. If NULL, returns info and does not
316 * decode pixels. 330 * decode pixels.
317 * @return bool Whether the function succeeded. 331 * @return bool Whether the function succeeded.
318 * 332 *
319 * Sample usage: 333 * Sample usage:
320 * <code> 334 * <code>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 Chooser* fChooser; 475 Chooser* fChooser;
462 SkBitmap::Allocator* fAllocator; 476 SkBitmap::Allocator* fAllocator;
463 int fSampleSize; 477 int fSampleSize;
464 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false 478 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
465 SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true 479 SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true
466 bool fDitherImage; 480 bool fDitherImage;
467 bool fUsePrefTable; 481 bool fUsePrefTable;
468 mutable bool fShouldCancelDecode; 482 mutable bool fShouldCancelDecode;
469 bool fPreferQualityOverSpeed; 483 bool fPreferQualityOverSpeed;
470 bool fRequireUnpremultipliedColors; 484 bool fRequireUnpremultipliedColors;
485
486 static SkLruImageCache fLruImageCache;
487 static SkBitmapFactory fLazyBitmapFactory;
488
471 }; 489 };
472 490
473 /** Calling newDecoder with a stream returns a new matching imagedecoder 491 /** 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 492 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 493 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 494 decoder may have called ref() (and if so, the decoder is responsible for
477 balancing its ownership when it is destroyed). 495 balancing its ownership when it is destroyed).
478 */ 496 */
479 class SkImageDecoderFactory : public SkRefCnt { 497 class SkImageDecoderFactory : public SkRefCnt {
480 public: 498 public:
(...skipping 29 matching lines...) Expand all
510 // not all of these will be available 528 // not all of these will be available
511 DECLARE_DECODER_CREATOR(BMPImageDecoder); 529 DECLARE_DECODER_CREATOR(BMPImageDecoder);
512 DECLARE_DECODER_CREATOR(GIFImageDecoder); 530 DECLARE_DECODER_CREATOR(GIFImageDecoder);
513 DECLARE_DECODER_CREATOR(ICOImageDecoder); 531 DECLARE_DECODER_CREATOR(ICOImageDecoder);
514 DECLARE_DECODER_CREATOR(JPEGImageDecoder); 532 DECLARE_DECODER_CREATOR(JPEGImageDecoder);
515 DECLARE_DECODER_CREATOR(PNGImageDecoder); 533 DECLARE_DECODER_CREATOR(PNGImageDecoder);
516 DECLARE_DECODER_CREATOR(WBMPImageDecoder); 534 DECLARE_DECODER_CREATOR(WBMPImageDecoder);
517 DECLARE_DECODER_CREATOR(WEBPImageDecoder); 535 DECLARE_DECODER_CREATOR(WEBPImageDecoder);
518 536
519 #endif 537 #endif
OLDNEW
« no previous file with comments | « no previous file | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698