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 "SkMatrixConvolutionImageFilter.h" | 8 #include "SkMatrixConvolutionImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 fTileMode(tileMode), | 40 fTileMode(tileMode), |
41 fConvolveAlpha(convolveAlpha) { | 41 fConvolveAlpha(convolveAlpha) { |
42 size_t size = (size_t) sk_64_mul(fKernelSize.width(), fKernelSize.height()); | 42 size_t size = (size_t) sk_64_mul(fKernelSize.width(), fKernelSize.height()); |
43 fKernel = new SkScalar[size]; | 43 fKernel = new SkScalar[size]; |
44 memcpy(fKernel, kernel, size * sizeof(SkScalar)); | 44 memcpy(fKernel, kernel, size * sizeof(SkScalar)); |
45 SkASSERT(kernelSize.fWidth >= 1 && kernelSize.fHeight >= 1); | 45 SkASSERT(kernelSize.fWidth >= 1 && kernelSize.fHeight >= 1); |
46 SkASSERT(kernelOffset.fX >= 0 && kernelOffset.fX < kernelSize.fWidth); | 46 SkASSERT(kernelOffset.fX >= 0 && kernelOffset.fX < kernelSize.fWidth); |
47 SkASSERT(kernelOffset.fY >= 0 && kernelOffset.fY < kernelSize.fHeight); | 47 SkASSERT(kernelOffset.fY >= 0 && kernelOffset.fY < kernelSize.fHeight); |
48 } | 48 } |
49 | 49 |
50 SkMatrixConvolutionImageFilter* SkMatrixConvolutionImageFilter::Create( | 50 SkImageFilter* SkMatrixConvolutionImageFilter::Create( |
51 const SkISize& kernelSize, | 51 const SkISize& kernelSize, |
52 const SkScalar* kernel, | 52 const SkScalar* kernel, |
53 SkScalar gain, | 53 SkScalar gain, |
54 SkScalar bias, | 54 SkScalar bias, |
55 const SkIPoint& kernelOffset, | 55 const SkIPoint& kernelOffset, |
56 TileMode tileMode, | 56 TileMode tileMode, |
57 bool convolveAlpha, | 57 bool convolveAlpha, |
58 SkImageFilter* input, | 58 SkImageFilter* input, |
59 const CropRect* cropRect) { | 59 const CropRect* cropRect) { |
60 if (kernelSize.width() < 1 || kernelSize.height() < 1) { | 60 if (kernelSize.width() < 1 || kernelSize.height() < 1) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 str->appendf("%f ", fKernel[y * fKernelSize.width() + x]); | 388 str->appendf("%f ", fKernel[y * fKernelSize.width() + x]); |
389 } | 389 } |
390 } | 390 } |
391 str->appendf(")"); | 391 str->appendf(")"); |
392 str->appendf("gain: %f bias: %f ", fGain, fBias); | 392 str->appendf("gain: %f bias: %f ", fGain, fBias); |
393 str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY); | 393 str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY); |
394 str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false"); | 394 str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false"); |
395 str->append(")"); | 395 str->append(")"); |
396 } | 396 } |
397 #endif | 397 #endif |
OLD | NEW |