OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 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 "SkBicubicImageFilter.h" | 8 #include "SkBicubicImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 coefficients[i] = random->nextSScalar1(); | 339 coefficients[i] = random->nextSScalar1(); |
340 } | 340 } |
341 return GrBicubicEffect::Create(textures[texIdx], coefficients); | 341 return GrBicubicEffect::Create(textures[texIdx], coefficients); |
342 } | 342 } |
343 | 343 |
344 bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkB
itmap* result) { | 344 bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkB
itmap* result) { |
345 SkBitmap srcBM; | 345 SkBitmap srcBM; |
346 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &srcBM))
{ | 346 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &srcBM))
{ |
347 return false; | 347 return false; |
348 } | 348 } |
349 GrTexture* srcTexture = (GrTexture*) srcBM.getTexture(); | 349 GrTexture* srcTexture = srcBM.getTexture(); |
350 GrContext* context = srcTexture->getContext(); | 350 GrContext* context = srcTexture->getContext(); |
351 | 351 |
352 SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth, | 352 SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth, |
353 srcBM.height() * fScale.fHeight); | 353 srcBM.height() * fScale.fHeight); |
354 | 354 |
355 GrTextureDesc desc; | 355 GrTextureDesc desc; |
356 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 356 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
357 desc.fWidth = SkScalarCeilToInt(dstRect.width()); | 357 desc.fWidth = SkScalarCeilToInt(dstRect.width()); |
358 desc.fHeight = SkScalarCeilToInt(dstRect.height()); | 358 desc.fHeight = SkScalarCeilToInt(dstRect.height()); |
359 desc.fConfig = kSkia8888_GrPixelConfig; | 359 desc.fConfig = kSkia8888_GrPixelConfig; |
360 | 360 |
361 GrAutoScratchTexture ast(context, desc); | 361 GrAutoScratchTexture ast(context, desc); |
362 SkAutoTUnref<GrTexture> dst(ast.detach()); | 362 SkAutoTUnref<GrTexture> dst(ast.detach()); |
363 if (!dst) { | 363 if (!dst) { |
364 return false; | 364 return false; |
365 } | 365 } |
366 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | 366 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); |
367 GrPaint paint; | 367 GrPaint paint; |
368 paint.colorStage(0)->setEffect(GrBicubicEffect::Create(srcTexture, fCoeffici
ents))->unref(); | 368 paint.colorStage(0)->setEffect(GrBicubicEffect::Create(srcTexture, fCoeffici
ents))->unref(); |
369 SkRect srcRect; | 369 SkRect srcRect; |
370 srcBM.getBounds(&srcRect); | 370 srcBM.getBounds(&srcRect); |
371 context->drawRectToRect(paint, dstRect, srcRect); | 371 context->drawRectToRect(paint, dstRect, srcRect); |
372 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); | 372 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); |
373 } | 373 } |
374 #endif | 374 #endif |
375 | 375 |
376 /////////////////////////////////////////////////////////////////////////////// | 376 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |