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

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

Issue 1017293002: guarded change to SkImageGenerator to make getInfo() const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkDecodingImageGenerator.h" 9 #include "SkDecodingImageGenerator.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 20 matching lines...) Expand all
31 const bool fDitherImage; 31 const bool fDitherImage;
32 32
33 DecodingImageGenerator(SkData* data, 33 DecodingImageGenerator(SkData* data,
34 SkStreamRewindable* stream, 34 SkStreamRewindable* stream,
35 const SkImageInfo& info, 35 const SkImageInfo& info,
36 int sampleSize, 36 int sampleSize,
37 bool ditherImage); 37 bool ditherImage);
38 38
39 protected: 39 protected:
40 SkData* onRefEncodedData() SK_OVERRIDE; 40 SkData* onRefEncodedData() SK_OVERRIDE;
41 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
41 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { 42 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
scroggo 2015/03/19 13:27:47 Again, I think you can remove this, if you make Sk
reed1 2015/03/19 15:20:46 deferring until I can remove the guard
42 *info = fInfo; 43 *info = fInfo;
43 return true; 44 return true;
44 } 45 }
46 #endif
45 virtual Result onGetPixels(const SkImageInfo& info, 47 virtual Result onGetPixels(const SkImageInfo& info,
46 void* pixels, size_t rowBytes, const Options&, 48 void* pixels, size_t rowBytes, const Options&,
47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE ; 49 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE ;
48 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 50 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
49 SkYUVColorSpace* colorSpace) SK_OVERRIDE; 51 SkYUVColorSpace* colorSpace) SK_OVERRIDE;
50 52
51 private: 53 private:
52 typedef SkImageGenerator INHERITED; 54 typedef SkImageGenerator INHERITED;
53 }; 55 };
54 56
(...skipping 22 matching lines...) Expand all
77 // TODO(halcanary): verify that all callers of this function 79 // TODO(halcanary): verify that all callers of this function
78 // will respect new RowBytes. Will be moot once rowbytes belongs 80 // will respect new RowBytes. Will be moot once rowbytes belongs
79 // to PixelRef. 81 // to PixelRef.
80 bm->installPixels(fInfo, fTarget, fRowBytes, ct, NULL, NULL); 82 bm->installPixels(fInfo, fTarget, fRowBytes, ct, NULL, NULL);
81 83
82 fTarget = NULL; // never alloc same pixels twice! 84 fTarget = NULL; // never alloc same pixels twice!
83 return true; 85 return true;
84 } 86 }
85 87
86 private: 88 private:
87 const SkImageInfo fInfo; 89 const SkImageInfo fInfo;
scroggo 2015/03/19 13:27:47 Can query getInfo when needed.
reed1 2015/03/19 15:20:46 ?
88 void* fTarget; // Block of memory to be supplied as pixel memory 90 void* fTarget; // Block of memory to be supplied as pixel memory
89 // in allocPixelRef. Must be large enough to hold 91 // in allocPixelRef. Must be large enough to hold
90 // a bitmap described by fInfo and fRowBytes 92 // a bitmap described by fInfo and fRowBytes
91 const size_t fRowBytes; // rowbytes for the destination bitmap 93 const size_t fRowBytes; // rowbytes for the destination bitmap
92 94
93 typedef SkBitmap::Allocator INHERITED; 95 typedef SkBitmap::Allocator INHERITED;
94 }; 96 };
95 97
96 // TODO(halcanary): Give this macro a better name and move it into SkTypes.h 98 // TODO(halcanary): Give this macro a better name and move it into SkTypes.h
97 #ifdef SK_DEBUG 99 #ifdef SK_DEBUG
(...skipping 11 matching lines...) Expand all
109 #endif // SK_DEBUG 111 #endif // SK_DEBUG
110 112
111 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
112 114
113 DecodingImageGenerator::DecodingImageGenerator( 115 DecodingImageGenerator::DecodingImageGenerator(
114 SkData* data, 116 SkData* data,
115 SkStreamRewindable* stream, 117 SkStreamRewindable* stream,
116 const SkImageInfo& info, 118 const SkImageInfo& info,
117 int sampleSize, 119 int sampleSize,
118 bool ditherImage) 120 bool ditherImage)
119 : fData(data) 121 : INHERITED(info)
122 , fData(data)
120 , fStream(stream) 123 , fStream(stream)
121 , fInfo(info) 124 , fInfo(info)
122 , fSampleSize(sampleSize) 125 , fSampleSize(sampleSize)
123 , fDitherImage(ditherImage) 126 , fDitherImage(ditherImage)
124 { 127 {
125 SkASSERT(stream != NULL); 128 SkASSERT(stream != NULL);
126 SkSafeRef(fData); // may be NULL. 129 SkSafeRef(fData); // may be NULL.
127 } 130 }
128 131
129 DecodingImageGenerator::~DecodingImageGenerator() { 132 DecodingImageGenerator::~DecodingImageGenerator() {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 294
292 SkImageGenerator* SkDecodingImageGenerator::Create( 295 SkImageGenerator* SkDecodingImageGenerator::Create(
293 SkStreamRewindable* stream, 296 SkStreamRewindable* stream,
294 const SkDecodingImageGenerator::Options& opts) { 297 const SkDecodingImageGenerator::Options& opts) {
295 SkASSERT(stream != NULL); 298 SkASSERT(stream != NULL);
296 if (stream == NULL) { 299 if (stream == NULL) {
297 return NULL; 300 return NULL;
298 } 301 }
299 return CreateDecodingImageGenerator(NULL, stream, opts); 302 return CreateDecodingImageGenerator(NULL, stream, opts);
300 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698