| 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" |
| 11 #include "SkColorMatrixFilter.h" | 11 #include "SkColorMatrixFilter.h" |
| 12 #include "SkDevice.h" | 12 #include "SkDevice.h" |
| 13 #include "SkColorFilter.h" | 13 #include "SkColorFilter.h" |
| 14 #include "SkReadBuffer.h" | 14 #include "SkReadBuffer.h" |
| 15 #include "SkTableColorFilter.h" | 15 #include "SkTableColorFilter.h" |
| 16 #include "SkWriteBuffer.h" | 16 #include "SkWriteBuffer.h" |
| 17 | 17 |
| 18 SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, | 18 SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, |
| 19 SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) { | 19 SkImageFilter* input, const CropRect* cropRect) { |
| 20 if (NULL == cf) { | 20 if (NULL == cf) { |
| 21 return NULL; | 21 return NULL; |
| 22 } | 22 } |
| 23 | 23 |
| 24 SkColorFilter* inputCF; | 24 SkColorFilter* inputCF; |
| 25 if (input && input->isColorFilterNode(&inputCF)) { | 25 if (input && input->isColorFilterNode(&inputCF)) { |
| 26 // This is an optimization, as it collapses the hierarchy by just combin
ing the two | 26 // This is an optimization, as it collapses the hierarchy by just combin
ing the two |
| 27 // colorfilters into a single one, which the new imagefilter will wrap. | 27 // colorfilters into a single one, which the new imagefilter will wrap. |
| 28 SkAutoUnref autoUnref(inputCF); | 28 SkAutoUnref autoUnref(inputCF); |
| 29 SkAutoTUnref<SkColorFilter> newCF(SkColorFilter::CreateComposeFilter(cf,
inputCF)); | 29 SkAutoTUnref<SkColorFilter> newCF(SkColorFilter::CreateComposeFilter(cf,
inputCF)); |
| 30 if (newCF) { | 30 if (newCF) { |
| 31 return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(
0), cropRect, 0)); | 31 return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(
0), cropRect)); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect, uniqueID))
; | 35 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, | 38 SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, |
| 39 SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) | 39 SkImageFilter* input, const CropRect* cropRect) |
| 40 : INHERITED(1, &input, cropRect, uniqueID), fColorFilter(SkRef(cf)) { | 40 : INHERITED(1, &input, cropRect), fColorFilter(SkRef(cf)) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) { | 43 SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 44 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 44 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 45 SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter()); | 45 SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter()); |
| 46 return Create(cf, common.getInput(0), &common.cropRect(), common.uniqueID())
; | 46 return Create(cf, common.getInput(0), &common.cropRect()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { | 49 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 50 this->INHERITED::flatten(buffer); | 50 this->INHERITED::flatten(buffer); |
| 51 buffer.writeFlattenable(fColorFilter); | 51 buffer.writeFlattenable(fColorFilter); |
| 52 } | 52 } |
| 53 | 53 |
| 54 SkColorFilterImageFilter::~SkColorFilterImageFilter() { | 54 SkColorFilterImageFilter::~SkColorFilterImageFilter() { |
| 55 fColorFilter->unref(); | 55 fColorFilter->unref(); |
| 56 } | 56 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (this->getInput(0)) { | 107 if (this->getInput(0)) { |
| 108 this->getInput(0)->toString(str); | 108 this->getInput(0)->toString(str); |
| 109 } | 109 } |
| 110 | 110 |
| 111 str->appendf(") color filter: "); | 111 str->appendf(") color filter: "); |
| 112 fColorFilter->toString(str); | 112 fColorFilter->toString(str); |
| 113 | 113 |
| 114 str->append(")"); | 114 str->append(")"); |
| 115 } | 115 } |
| 116 #endif | 116 #endif |
| OLD | NEW |