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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 return GrTextureDomain::kRepeat_Mode; | 341 return GrTextureDomain::kRepeat_Mode; |
342 case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode: | 342 case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode: |
343 return GrTextureDomain::kDecal_Mode; | 343 return GrTextureDomain::kDecal_Mode; |
344 default: | 344 default: |
345 SkASSERT(false); | 345 SkASSERT(false); |
346 } | 346 } |
347 return GrTextureDomain::kIgnore_Mode; | 347 return GrTextureDomain::kIgnore_Mode; |
348 } | 348 } |
349 | 349 |
350 bool SkMatrixConvolutionImageFilter::asFragmentProcessor(GrFragmentProcessor** f
p, | 350 bool SkMatrixConvolutionImageFilter::asFragmentProcessor(GrFragmentProcessor** f
p, |
351 GrProcessorDataManager*
, | 351 GrProcessorDataManager*
procDataManager, |
352 GrTexture* texture, | 352 GrTexture* texture, |
353 const SkMatrix&, | 353 const SkMatrix&, |
354 const SkIRect& bounds)
const { | 354 const SkIRect& bounds)
const { |
355 if (!fp) { | 355 if (!fp) { |
356 return fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE; | 356 return fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE; |
357 } | 357 } |
358 SkASSERT(fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE); | 358 SkASSERT(fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE); |
359 *fp = GrMatrixConvolutionEffect::Create(texture, | 359 *fp = GrMatrixConvolutionEffect::Create(procDataManager, |
| 360 texture, |
360 bounds, | 361 bounds, |
361 fKernelSize, | 362 fKernelSize, |
362 fKernel, | 363 fKernel, |
363 fGain, | 364 fGain, |
364 fBias, | 365 fBias, |
365 fKernelOffset, | 366 fKernelOffset, |
366 convert_tilemodes(fTileMode), | 367 convert_tilemodes(fTileMode), |
367 fConvolveAlpha); | 368 fConvolveAlpha); |
368 return true; | 369 return true; |
369 } | 370 } |
370 #endif | 371 #endif |
371 | 372 |
372 #ifndef SK_IGNORE_TO_STRING | 373 #ifndef SK_IGNORE_TO_STRING |
373 void SkMatrixConvolutionImageFilter::toString(SkString* str) const { | 374 void SkMatrixConvolutionImageFilter::toString(SkString* str) const { |
374 str->appendf("SkMatrixConvolutionImageFilter: ("); | 375 str->appendf("SkMatrixConvolutionImageFilter: ("); |
375 str->appendf("size: (%d,%d) kernel: (", fKernelSize.width(), fKernelSize.hei
ght()); | 376 str->appendf("size: (%d,%d) kernel: (", fKernelSize.width(), fKernelSize.hei
ght()); |
376 for (int y = 0; y < fKernelSize.height(); y++) { | 377 for (int y = 0; y < fKernelSize.height(); y++) { |
377 for (int x = 0; x < fKernelSize.width(); x++) { | 378 for (int x = 0; x < fKernelSize.width(); x++) { |
378 str->appendf("%f ", fKernel[y * fKernelSize.width() + x]); | 379 str->appendf("%f ", fKernel[y * fKernelSize.width() + x]); |
379 } | 380 } |
380 } | 381 } |
381 str->appendf(")"); | 382 str->appendf(")"); |
382 str->appendf("gain: %f bias: %f ", fGain, fBias); | 383 str->appendf("gain: %f bias: %f ", fGain, fBias); |
383 str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY); | 384 str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY); |
384 str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false"); | 385 str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false"); |
385 str->append(")"); | 386 str->append(")"); |
386 } | 387 } |
387 #endif | 388 #endif |
OLD | NEW |