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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 paint.addColorFragmentProcessor(fp.get()); | 280 paint.addColorFragmentProcessor(fp.get()); |
281 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 281 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
282 | 282 |
283 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, | 283 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, |
284 bounds.width(), bou
nds.height(), | 284 bounds.width(), bou
nds.height(), |
285 kRGBA_8888_GrPixelC
onfig)); | 285 kRGBA_8888_GrPixelC
onfig)); |
286 if (!drawContext) { | 286 if (!drawContext) { |
287 return nullptr; | 287 return nullptr; |
288 } | 288 } |
289 | 289 |
| 290 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); |
290 SkRect srcRect = SkRect::Make(bounds); | 291 SkRect srcRect = SkRect::Make(bounds); |
291 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 292 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
292 GrClip clip(dstRect); | 293 GrFixedClip clip(dstIRect); |
293 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); | 294 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); |
294 | 295 |
295 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), | 296 return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialIm
age, |
296 kNeedNewImageUniqueID_SpecialImage, | |
297 drawContext->asTexture()); | 297 drawContext->asTexture()); |
298 } | 298 } |
299 #endif | 299 #endif |
300 | 300 |
301 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { | 301 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { |
302 SkASSERT(nullptr != filterPtr); | 302 SkASSERT(nullptr != filterPtr); |
303 if (!this->isColorFilterNode(filterPtr)) { | 303 if (!this->isColorFilterNode(filterPtr)) { |
304 return false; | 304 return false; |
305 } | 305 } |
306 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ | 306 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); | 439 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); |
440 | 440 |
441 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); | 441 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); |
442 | 442 |
443 return result; | 443 return result; |
444 } | 444 } |
445 | 445 |
446 void SkImageFilter::PurgeCache() { | 446 void SkImageFilter::PurgeCache() { |
447 SkImageFilterCache::Get()->purge(); | 447 SkImageFilterCache::Get()->purge(); |
448 } | 448 } |
OLD | NEW |