| 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" |
| 11 #include "SkChecksum.h" | 11 #include "SkChecksum.h" |
| 12 #include "SkDevice.h" | 12 #include "SkDevice.h" |
| 13 #include "SkLazyPtr.h" | 13 #include "SkLazyPtr.h" |
| 14 #include "SkMatrixImageFilter.h" | 14 #include "SkMatrixImageFilter.h" |
| 15 #include "SkReadBuffer.h" | 15 #include "SkReadBuffer.h" |
| 16 #include "SkWriteBuffer.h" | 16 #include "SkWriteBuffer.h" |
| 17 #include "SkRect.h" | 17 #include "SkRect.h" |
| 18 #include "SkTDynamicHash.h" | 18 #include "SkTDynamicHash.h" |
| 19 #include "SkTInternalLList.h" | 19 #include "SkTInternalLList.h" |
| 20 #include "SkValidationUtils.h" | 20 #include "SkValidationUtils.h" |
| 21 #if SK_SUPPORT_GPU | 21 #if SK_SUPPORT_GPU |
| 22 #include "GrContext.h" | 22 #include "GrContext.h" |
| 23 #include "GrDrawContext.h" |
| 23 #include "SkGrPixelRef.h" | 24 #include "SkGrPixelRef.h" |
| 24 #include "SkGr.h" | 25 #include "SkGr.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 #ifdef SK_BUILD_FOR_IOS | 28 #ifdef SK_BUILD_FOR_IOS |
| 28 enum { kDefaultCacheSize = 2 * 1024 * 1024 }; | 29 enum { kDefaultCacheSize = 2 * 1024 * 1024 }; |
| 29 #else | 30 #else |
| 30 enum { kDefaultCacheSize = 128 * 1024 * 1024 }; | 31 enum { kDefaultCacheSize = 128 * 1024 * 1024 }; |
| 31 #endif | 32 #endif |
| 32 | 33 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 GrFragmentProcessor* fp; | 270 GrFragmentProcessor* fp; |
| 270 offset->fX = bounds.left(); | 271 offset->fX = bounds.left(); |
| 271 offset->fY = bounds.top(); | 272 offset->fY = bounds.top(); |
| 272 bounds.offset(-srcOffset); | 273 bounds.offset(-srcOffset); |
| 273 SkMatrix matrix(ctx.ctm()); | 274 SkMatrix matrix(ctx.ctm()); |
| 274 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 275 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
| 275 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { | 276 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { |
| 276 SkASSERT(fp); | 277 SkASSERT(fp); |
| 277 GrPaint paint; | 278 GrPaint paint; |
| 278 paint.addColorProcessor(fp)->unref(); | 279 paint.addColorProcessor(fp)->unref(); |
| 279 context->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatri
x::I(), dstRect, | |
| 280 srcRect); | |
| 281 | 280 |
| 282 WrapTexture(dst, bounds.width(), bounds.height(), result); | 281 GrDrawContext* drawContext = context->drawContext(); |
| 283 return true; | 282 if (drawContext) { |
| 283 drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint,
SkMatrix::I(), |
| 284 dstRect, srcRect); |
| 285 |
| 286 WrapTexture(dst, bounds.width(), bounds.height(), result); |
| 287 return true; |
| 288 } |
| 284 } | 289 } |
| 285 #endif | 290 #endif |
| 286 return false; | 291 return false; |
| 287 } | 292 } |
| 288 | 293 |
| 289 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, | 294 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, |
| 290 const SkIPoint& srcOffset, SkIRect* bounds) co
nst { | 295 const SkIPoint& srcOffset, SkIRect* bounds) co
nst { |
| 291 SkIRect srcBounds; | 296 SkIRect srcBounds; |
| 292 src.getBounds(&srcBounds); | 297 src.getBounds(&srcBounds); |
| 293 srcBounds.offset(srcOffset); | 298 srcBounds.offset(srcOffset); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 516 |
| 512 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); | 517 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); |
| 513 | 518 |
| 514 SkImageFilter::Cache* SkImageFilter::Cache::Get() { | 519 SkImageFilter::Cache* SkImageFilter::Cache::Get() { |
| 515 return cache.get(); | 520 return cache.get(); |
| 516 } | 521 } |
| 517 | 522 |
| 518 void SkImageFilter::PurgeCache() { | 523 void SkImageFilter::PurgeCache() { |
| 519 cache.get()->purge(); | 524 cache.get()->purge(); |
| 520 } | 525 } |
| OLD | NEW |