| 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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 desc.fFlags = kRenderTarget_GrSurfaceFlag, | 249 desc.fFlags = kRenderTarget_GrSurfaceFlag, |
| 250 desc.fWidth = bounds.width(); | 250 desc.fWidth = bounds.width(); |
| 251 desc.fHeight = bounds.height(); | 251 desc.fHeight = bounds.height(); |
| 252 desc.fConfig = kRGBA_8888_GrPixelConfig; | 252 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 253 | 253 |
| 254 SkAutoTUnref<GrTexture> dst( | 254 SkAutoTUnref<GrTexture> dst( |
| 255 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); | 255 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); |
| 256 if (!dst) { | 256 if (!dst) { |
| 257 return false; | 257 return false; |
| 258 } | 258 } |
| 259 GrContext::AutoMatrix am; | |
| 260 am.setIdentity(context); | |
| 261 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | 259 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); |
| 262 GrContext::AutoClip acs(context, dstRect); | 260 GrContext::AutoClip acs(context, dstRect); |
| 263 GrFragmentProcessor* fp; | 261 GrFragmentProcessor* fp; |
| 264 offset->fX = bounds.left(); | 262 offset->fX = bounds.left(); |
| 265 offset->fY = bounds.top(); | 263 offset->fY = bounds.top(); |
| 266 bounds.offset(-srcOffset); | 264 bounds.offset(-srcOffset); |
| 267 SkMatrix matrix(ctx.ctm()); | 265 SkMatrix matrix(ctx.ctm()); |
| 268 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 266 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
| 269 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { | 267 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { |
| 270 SkASSERT(fp); | 268 SkASSERT(fp); |
| 271 GrPaint paint; | 269 GrPaint paint; |
| 272 paint.addColorProcessor(fp)->unref(); | 270 paint.addColorProcessor(fp)->unref(); |
| 273 context->drawRectToRect(paint, dstRect, srcRect); | 271 context->drawRectToRect(paint, SkMatrix::I(), dstRect, srcRect); |
| 274 | 272 |
| 275 WrapTexture(dst, bounds.width(), bounds.height(), result); | 273 WrapTexture(dst, bounds.width(), bounds.height(), result); |
| 276 return true; | 274 return true; |
| 277 } | 275 } |
| 278 #endif | 276 #endif |
| 279 return false; | 277 return false; |
| 280 } | 278 } |
| 281 | 279 |
| 282 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, | 280 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, |
| 283 const SkIPoint& srcOffset, SkIRect* bounds) co
nst { | 281 const SkIPoint& srcOffset, SkIRect* bounds) co
nst { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 486 |
| 489 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { | 487 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { |
| 490 return SkNEW_ARGS(CacheImpl, (maxBytes)); | 488 return SkNEW_ARGS(CacheImpl, (maxBytes)); |
| 491 } | 489 } |
| 492 | 490 |
| 493 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); | 491 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); |
| 494 | 492 |
| 495 SkImageFilter::Cache* SkImageFilter::Cache::Get() { | 493 SkImageFilter::Cache* SkImageFilter::Cache::Get() { |
| 496 return cache.get(); | 494 return cache.get(); |
| 497 } | 495 } |
| OLD | NEW |