OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 } | 94 } |
95 SkRect rect; | 95 SkRect rect; |
96 buffer.readRect(&rect); | 96 buffer.readRect(&rect); |
97 if (!buffer.isValid() || !buffer.validate(SkIsValidRect(rect))) { | 97 if (!buffer.isValid() || !buffer.validate(SkIsValidRect(rect))) { |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
101 uint32_t flags = buffer.readUInt(); | 101 uint32_t flags = buffer.readUInt(); |
102 fCropRect = CropRect(rect, flags); | 102 fCropRect = CropRect(rect, flags); |
103 // FIXME: this is now unused; and should be made conditional on the next SkP
icture version bump. | 103 if (buffer.isVersionLT(SkReadBuffer::kImageFilterNoUniqueID_Version)) { |
104 // See skbug.com/3559. | 104 |
105 (void) buffer.readUInt(); | 105 (void) buffer.readUInt(); |
| 106 } |
106 return buffer.isValid(); | 107 return buffer.isValid(); |
107 } | 108 } |
108 | 109 |
109 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 110 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
110 | 111 |
111 SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropR
ect* cropRect) | 112 SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropR
ect* cropRect) |
112 : fInputCount(inputCount), | 113 : fInputCount(inputCount), |
113 fInputs(new SkImageFilter*[inputCount]), | 114 fInputs(new SkImageFilter*[inputCount]), |
114 fUsesSrcInput(false), | 115 fUsesSrcInput(false), |
115 fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)), | 116 fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 buffer.writeInt(fInputCount); | 155 buffer.writeInt(fInputCount); |
155 for (int i = 0; i < fInputCount; i++) { | 156 for (int i = 0; i < fInputCount; i++) { |
156 SkImageFilter* input = getInput(i); | 157 SkImageFilter* input = getInput(i); |
157 buffer.writeBool(input != NULL); | 158 buffer.writeBool(input != NULL); |
158 if (input != NULL) { | 159 if (input != NULL) { |
159 buffer.writeFlattenable(input); | 160 buffer.writeFlattenable(input); |
160 } | 161 } |
161 } | 162 } |
162 buffer.writeRect(fCropRect.rect()); | 163 buffer.writeRect(fCropRect.rect()); |
163 buffer.writeUInt(fCropRect.flags()); | 164 buffer.writeUInt(fCropRect.flags()); |
164 // FIXME: this is now unused; and should be removed on the next SkPicture ve
rsion bump. | |
165 // See skbug.com/3559. | |
166 buffer.writeUInt(0); | |
167 } | 165 } |
168 | 166 |
169 bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, | 167 bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, |
170 const Context& context, | 168 const Context& context, |
171 SkBitmap* result, SkIPoint* offset) const { | 169 SkBitmap* result, SkIPoint* offset) const { |
172 SkASSERT(result); | 170 SkASSERT(result); |
173 SkASSERT(offset); | 171 SkASSERT(offset); |
174 uint32_t srcGenID = fUsesSrcInput ? src.getGenerationID() : 0; | 172 uint32_t srcGenID = fUsesSrcInput ? src.getGenerationID() : 0; |
175 Cache::Key key(fUniqueID, context.ctm(), context.clipBounds(), srcGenID); | 173 Cache::Key key(fUniqueID, context.ctm(), context.clipBounds(), srcGenID); |
176 if (context.cache()) { | 174 if (context.cache()) { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 487 |
490 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { | 488 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { |
491 return SkNEW_ARGS(CacheImpl, (maxBytes)); | 489 return SkNEW_ARGS(CacheImpl, (maxBytes)); |
492 } | 490 } |
493 | 491 |
494 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); | 492 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); |
495 | 493 |
496 SkImageFilter::Cache* SkImageFilter::Cache::Get() { | 494 SkImageFilter::Cache* SkImageFilter::Cache::Get() { |
497 return cache.get(); | 495 return cache.get(); |
498 } | 496 } |
OLD | NEW |