| 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 "SkColorFilterImageFilter.h" | 8 #include "SkColorFilterImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect, uniqueID))
; | 79 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect, uniqueID))
; |
| 80 } | 80 } |
| 81 | 81 |
| 82 SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, | 82 SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, |
| 83 SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) | 83 SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) |
| 84 : INHERITED(1, &input, cropRect, uniqueID), fColorFilter(SkRef(cf)) { | 84 : INHERITED(1, &input, cropRect, uniqueID), fColorFilter(SkRef(cf)) { |
| 85 } | 85 } |
| 86 | 86 |
| 87 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 87 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 88 SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer) | 88 SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer) : INHER
ITED(1, buffer) { |
| 89 : INHERITED(1, buffer) { | |
| 90 fColorFilter = buffer.readColorFilter(); | 89 fColorFilter = buffer.readColorFilter(); |
| 90 // we aren't prepared for this to be NULL, and it can't ever be when we're N
OT supporting |
| 91 // SK_SUPPORT_LEGACY_DEEPFLATTENING, as we always go through a factory which
can detect |
| 92 // NULL. However, since here we're in the legacy code, we assign a dummy fil
ter so we |
| 93 // don't crash with a null-ptr. |
| 94 if (NULL == fColorFilter) { |
| 95 // colormatrix identity is effectively a no-op |
| 96 fColorFilter = SkColorMatrixFilter::Create(SkColorMatrix()); |
| 97 SkASSERT(fColorFilter); |
| 98 } |
| 91 } | 99 } |
| 92 #endif | 100 #endif |
| 93 | 101 |
| 94 SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) { | 102 SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 95 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 103 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 96 SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter()); | 104 SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter()); |
| 97 return Create(cf, common.getInput(0), &common.cropRect(), common.uniqueID())
; | 105 return Create(cf, common.getInput(0), &common.cropRect(), common.uniqueID())
; |
| 98 } | 106 } |
| 99 | 107 |
| 100 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { | 108 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { | 149 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { |
| 142 if (!cropRectIsSet()) { | 150 if (!cropRectIsSet()) { |
| 143 if (filter) { | 151 if (filter) { |
| 144 *filter = fColorFilter; | 152 *filter = fColorFilter; |
| 145 fColorFilter->ref(); | 153 fColorFilter->ref(); |
| 146 } | 154 } |
| 147 return true; | 155 return true; |
| 148 } | 156 } |
| 149 return false; | 157 return false; |
| 150 } | 158 } |
| OLD | NEW |