Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1421493003: tunnel down texture-size-constraint to imagefilters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, 675 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
676 const SkPaint& paint, const SkMatrix* prePathMatrix, 676 const SkPaint& paint, const SkMatrix* prePathMatrix,
677 bool pathIsMutable) { 677 bool pathIsMutable) {
678 CHECK_FOR_ANNOTATION(paint); 678 CHECK_FOR_ANNOTATION(paint);
679 CHECK_SHOULD_DRAW(draw); 679 CHECK_SHOULD_DRAW(draw);
680 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); 680 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext);
681 681
682 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, 682 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget,
683 fClip, origSrcPath, paint, 683 fClip, origSrcPath, paint,
684 *draw.fMatrix, prePathMatrix, 684 *draw.fMatrix, prePathMatrix,
685 draw.fClip->getBounds(), pathIsMutable); 685 draw.fClip->getBounds(), pathIsMutable,
686 GrTextureProvider::kApprox_SizeConstrain t);
686 } 687 }
687 688
688 static const int kBmpSmallTileSize = 1 << 10; 689 static const int kBmpSmallTileSize = 1 << 10;
689 690
690 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { 691 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) {
691 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; 692 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1;
692 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; 693 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1;
693 return tilesX * tilesY; 694 return tilesX * tilesY;
694 } 695 }
695 696
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 SkBitmap filteredBitmap; 1427 SkBitmap filteredBitmap;
1427 1428
1428 if (filter) { 1429 if (filter) {
1429 SkIPoint offset = SkIPoint::Make(0, 0); 1430 SkIPoint offset = SkIPoint::Make(0, 0);
1430 SkMatrix matrix(*draw.fMatrix); 1431 SkMatrix matrix(*draw.fMatrix);
1431 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); 1432 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
1432 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); 1433 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
1433 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); 1434 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
1434 // This cache is transient, and is freed (along with all its contained 1435 // This cache is transient, and is freed (along with all its contained
1435 // textures) when it goes out of scope. 1436 // textures) when it goes out of scope.
1436 SkImageFilter::Context ctx(matrix, clipBounds, cache); 1437 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint);
1437 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB itmap, 1438 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB itmap,
1438 &offset)) { 1439 &offset)) {
1439 texture = (GrTexture*) filteredBitmap.getTexture(); 1440 texture = (GrTexture*) filteredBitmap.getTexture();
1440 w = filteredBitmap.width(); 1441 w = filteredBitmap.width();
1441 h = filteredBitmap.height(); 1442 h = filteredBitmap.height();
1442 left += offset.x(); 1443 left += offset.x();
1443 top += offset.y(); 1444 top += offset.y();
1444 } else { 1445 } else {
1445 return; 1446 return;
1446 } 1447 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 SkBitmap filteredBitmap; 1547 SkBitmap filteredBitmap;
1547 1548
1548 if (filter) { 1549 if (filter) {
1549 SkIPoint offset = SkIPoint::Make(0, 0); 1550 SkIPoint offset = SkIPoint::Make(0, 0);
1550 SkMatrix matrix(*draw.fMatrix); 1551 SkMatrix matrix(*draw.fMatrix);
1551 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1552 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1552 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); 1553 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height());
1553 // This cache is transient, and is freed (along with all its contained 1554 // This cache is transient, and is freed (along with all its contained
1554 // textures) when it goes out of scope. 1555 // textures) when it goes out of scope.
1555 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); 1556 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
1556 SkImageFilter::Context ctx(matrix, clipBounds, cache); 1557 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint);
1557 if (this->filterTexture(fContext, devTex, device->width(), device->heigh t(), 1558 if (this->filterTexture(fContext, devTex, device->width(), device->heigh t(),
1558 filter, ctx, &filteredBitmap, &offset)) { 1559 filter, ctx, &filteredBitmap, &offset)) {
1559 devTex = filteredBitmap.getTexture(); 1560 devTex = filteredBitmap.getTexture();
1560 w = filteredBitmap.width(); 1561 w = filteredBitmap.width();
1561 h = filteredBitmap.height(); 1562 h = filteredBitmap.height();
1562 x += offset.fX; 1563 x += offset.fX;
1563 y += offset.fY; 1564 y += offset.fY;
1564 } else { 1565 } else {
1565 return; 1566 return;
1566 } 1567 }
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 2020 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
2020 } 2021 }
2021 2022
2022 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 2023 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
2023 // We always return a transient cache, so it is freed after each 2024 // We always return a transient cache, so it is freed after each
2024 // filter traversal. 2025 // filter traversal.
2025 return SkGpuDevice::NewImageFilterCache(); 2026 return SkGpuDevice::NewImageFilterCache();
2026 } 2027 }
2027 2028
2028 #endif 2029 #endif
OLDNEW
« src/gpu/GrBlurUtils.cpp ('K') | « src/gpu/GrTextContext.cpp ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698