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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 bounds.offset(-fKernelOffset); | 312 bounds.offset(-fKernelOffset); |
313 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { | 313 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { |
314 return false; | 314 return false; |
315 } | 315 } |
316 *dst = bounds; | 316 *dst = bounds; |
317 return true; | 317 return true; |
318 } | 318 } |
319 | 319 |
320 #if SK_SUPPORT_GPU | 320 #if SK_SUPPORT_GPU |
321 | 321 |
322 static GrMatrixConvolutionEffect::TileMode convert_tilemodes( | 322 static GrTextureDomain::Mode convert_tilemodes( |
323 SkMatrixConvolutionImageFilter::TileMode tileMode) { | 323 SkMatrixConvolutionImageFilter::TileMode tileMode) { |
324 GR_STATIC_ASSERT(static_cast<int>(SkMatrixConvolutionImageFilter::kClamp_Til
eMode) == | 324 switch (tileMode) { |
325 static_cast<int>(GrMatrixConvolutionEffect::kClamp_TileMode
)); | 325 case SkMatrixConvolutionImageFilter::kClamp_TileMode: |
326 GR_STATIC_ASSERT(static_cast<int>(SkMatrixConvolutionImageFilter::kRepeat_Ti
leMode) == | 326 return GrTextureDomain::kClamp_Mode; |
327 static_cast<int>(GrMatrixConvolutionEffect::kRepeat_TileMod
e)); | 327 case SkMatrixConvolutionImageFilter::kRepeat_TileMode: |
328 GR_STATIC_ASSERT(static_cast<int>(SkMatrixConvolutionImageFilter::kClampToBl
ack_TileMode) == | 328 return GrTextureDomain::kRepeat_Mode; |
329 static_cast<int>(GrMatrixConvolutionEffect::kClampToBlack_T
ileMode)); | 329 case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode: |
330 GR_STATIC_ASSERT(static_cast<int>(SkMatrixConvolutionImageFilter::kMax_TileM
ode) == | 330 return GrTextureDomain::kDecal_Mode; |
331 static_cast<int>(GrMatrixConvolutionEffect::kMax_TileMode))
; | 331 default: |
332 return static_cast<GrMatrixConvolutionEffect::TileMode>(tileMode); | 332 SkASSERT(false); |
| 333 } |
| 334 return GrTextureDomain::kIgnore_Mode; |
333 } | 335 } |
334 | 336 |
335 bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** effect, | 337 bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** effect, |
336 GrTexture* texture, | 338 GrTexture* texture, |
337 const SkMatrix&, | 339 const SkMatrix&, |
338 const SkIRect& bounds | 340 const SkIRect& bounds) const { |
339 ) const { | |
340 if (!effect) { | 341 if (!effect) { |
341 return fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE; | 342 return fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE; |
342 } | 343 } |
343 SkASSERT(fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE); | 344 SkASSERT(fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE); |
344 *effect = GrMatrixConvolutionEffect::Create(texture, | 345 *effect = GrMatrixConvolutionEffect::Create(texture, |
345 bounds, | 346 bounds, |
346 fKernelSize, | 347 fKernelSize, |
347 fKernel, | 348 fKernel, |
348 fGain, | 349 fGain, |
349 fBias, | 350 fBias, |
350 fKernelOffset, | 351 fKernelOffset, |
351 convert_tilemodes(fTileMode), | 352 convert_tilemodes(fTileMode), |
352 fConvolveAlpha); | 353 fConvolveAlpha); |
353 return true; | 354 return true; |
354 } | 355 } |
355 #endif | 356 #endif |
OLD | NEW |