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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 }; | 58 }; |
59 | 59 |
60 SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, | 60 SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, |
61 SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) { | 61 SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) { |
62 SkASSERT(cf); | 62 SkASSERT(cf); |
63 SkScalar colorMatrix[20], inputMatrix[20]; | 63 SkScalar colorMatrix[20], inputMatrix[20]; |
64 SkColorFilter* inputColorFilter; | 64 SkColorFilter* inputColorFilter; |
65 if (input && cf->asColorMatrix(colorMatrix) | 65 if (input && cf->asColorMatrix(colorMatrix) |
66 && input->asColorFilter(&inputColorFilter) | 66 && input->asColorFilter(&inputColorFilter) |
67 && (NULL != inputColorFilter)) { | 67 && (inputColorFilter)) { |
68 SkAutoUnref autoUnref(inputColorFilter); | 68 SkAutoUnref autoUnref(inputColorFilter); |
69 if (inputColorFilter->asColorMatrix(inputMatrix) && !matrix_needs_clampi
ng(inputMatrix)) { | 69 if (inputColorFilter->asColorMatrix(inputMatrix) && !matrix_needs_clampi
ng(inputMatrix)) { |
70 SkScalar combinedMatrix[20]; | 70 SkScalar combinedMatrix[20]; |
71 mult_color_matrix(colorMatrix, inputMatrix, combinedMatrix); | 71 mult_color_matrix(colorMatrix, inputMatrix, combinedMatrix); |
72 SkAutoTUnref<SkColorFilter> newCF(SkColorMatrixFilter::Create(combin
edMatrix)); | 72 SkAutoTUnref<SkColorFilter> newCF(SkColorMatrixFilter::Create(combin
edMatrix)); |
73 return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(
0), cropRect, 0)); | 73 return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(
0), cropRect, 0)); |
74 } | 74 } |
75 } | 75 } |
76 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect, uniqueID))
; | 76 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect, uniqueID))
; |
77 } | 77 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { | 140 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { |
141 if (!cropRectIsSet()) { | 141 if (!cropRectIsSet()) { |
142 if (filter) { | 142 if (filter) { |
143 *filter = fColorFilter; | 143 *filter = fColorFilter; |
144 fColorFilter->ref(); | 144 fColorFilter->ref(); |
145 } | 145 } |
146 return true; | 146 return true; |
147 } | 147 } |
148 return false; | 148 return false; |
149 } | 149 } |
OLD | NEW |