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

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

Issue 2241353002: pin as texture api (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix comments Created 4 years, 4 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
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.cpp ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 } 1349 }
1350 1350
1351 this->drawSpecial(draw, srcImg.get(), left, top, paint); 1351 this->drawSpecial(draw, srcImg.get(), left, top, paint);
1352 } 1352 }
1353 1353
1354 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y, 1354 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y,
1355 const SkPaint& paint) { 1355 const SkPaint& paint) {
1356 ASSERT_SINGLE_OWNER 1356 ASSERT_SINGLE_OWNER
1357 SkMatrix viewMatrix = *draw.fMatrix; 1357 SkMatrix viewMatrix = *draw.fMatrix;
1358 viewMatrix.preTranslate(x, y); 1358 viewMatrix.preTranslate(x, y);
1359 if (as_IB(image)->peekTexture()) { 1359 uint32_t pinnedUniqueID;
1360 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
1360 CHECK_SHOULD_DRAW(draw); 1361 CHECK_SHOULD_DRAW(draw);
1361 GrImageTextureAdjuster adjuster(as_IB(image)); 1362 GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID,
1363 as_IB(image)->onImageInfo().colorSpace());
1362 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint, 1364 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint,
1363 viewMatrix, fClip, paint); 1365 viewMatrix, fClip, paint);
1364 return; 1366 return;
1365 } else { 1367 } else {
1366 SkBitmap bm; 1368 SkBitmap bm;
1367 if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstra int, 1369 if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstra int,
1368 paint.getFilterQuality(), *draw.fMatrix)) { 1370 paint.getFilterQuality(), *draw.fMatrix)) {
1369 // only support tiling as bitmap at the moment, so force raster-vers ion 1371 // only support tiling as bitmap at the moment, so force raster-vers ion
1370 if (!as_IB(image)->getROPixels(&bm)) { 1372 if (!as_IB(image)->getROPixels(&bm)) {
1371 return; 1373 return;
1372 } 1374 }
1373 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 1375 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
1374 } else if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { 1376 } else if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
1375 CHECK_SHOULD_DRAW(draw); 1377 CHECK_SHOULD_DRAW(draw);
1376 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint); 1378 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint);
1377 this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_ SrcRectConstraint, 1379 this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_ SrcRectConstraint,
1378 viewMatrix, fClip, paint); 1380 viewMatrix, fClip, paint);
1379 } else if (as_IB(image)->getROPixels(&bm)) { 1381 } else if (as_IB(image)->getROPixels(&bm)) {
1380 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 1382 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
1381 } 1383 }
1382 } 1384 }
1383 } 1385 }
1384 1386
1385 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 1387 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
1386 const SkRect& dst, const SkPaint& paint, 1388 const SkRect& dst, const SkPaint& paint,
1387 SkCanvas::SrcRectConstraint constraint) { 1389 SkCanvas::SrcRectConstraint constraint) {
1388 ASSERT_SINGLE_OWNER 1390 ASSERT_SINGLE_OWNER
1389 if (as_IB(image)->peekTexture()) { 1391 uint32_t pinnedUniqueID;
1392 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
1390 CHECK_SHOULD_DRAW(draw); 1393 CHECK_SHOULD_DRAW(draw);
1391 GrImageTextureAdjuster adjuster(as_IB(image)); 1394 GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID,
1395 as_IB(image)->onImageInfo().colorSpace());
1392 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri x, fClip, paint); 1396 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri x, fClip, paint);
1393 return; 1397 return;
1394 } 1398 }
1395 SkBitmap bm; 1399 SkBitmap bm;
1396 SkMatrix totalMatrix = *draw.fMatrix; 1400 SkMatrix totalMatrix = *draw.fMatrix;
1397 totalMatrix.preScale(dst.width() / (src ? src->width() : image->width()), 1401 totalMatrix.preScale(dst.width() / (src ? src->width() : image->width()),
1398 dst.height() / (src ? src->height() : image->height())) ; 1402 dst.height() / (src ? src->height() : image->height())) ;
1399 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), totalMatrix)) { 1403 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), totalMatrix)) {
1400 // only support tiling as bitmap at the moment, so force raster-version 1404 // only support tiling as bitmap at the moment, so force raster-version
1401 if (!as_IB(image)->getROPixels(&bm)) { 1405 if (!as_IB(image)->getROPixels(&bm)) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 return; 1451 return;
1448 } 1452 }
1449 1453
1450 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() , 1454 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() ,
1451 producer->height(), center, dst); 1455 producer->height(), center, dst);
1452 } 1456 }
1453 1457
1454 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, 1458 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image,
1455 const SkIRect& center, const SkRect& dst, const SkPaint& paint) { 1459 const SkIRect& center, const SkRect& dst, const SkPaint& paint) {
1456 ASSERT_SINGLE_OWNER 1460 ASSERT_SINGLE_OWNER
1457 if (as_IB(image)->peekTexture()) { 1461 uint32_t pinnedUniqueID;
1458 GrImageTextureAdjuster adjuster(as_IB(image)); 1462 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
1463 CHECK_SHOULD_DRAW(draw);
1464 GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID,
1465 as_IB(image)->onImageInfo().colorSpace());
1459 this->drawProducerNine(draw, &adjuster, center, dst, paint); 1466 this->drawProducerNine(draw, &adjuster, center, dst, paint);
1460 } else { 1467 } else {
1461 SkBitmap bm; 1468 SkBitmap bm;
1462 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { 1469 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
1463 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint); 1470 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint);
1464 this->drawProducerNine(draw, &maker, center, dst, paint); 1471 this->drawProducerNine(draw, &maker, center, dst, paint);
1465 } else if (as_IB(image)->getROPixels(&bm)) { 1472 } else if (as_IB(image)->getROPixels(&bm)) {
1466 this->drawBitmapNine(draw, bm, center, dst, paint); 1473 this->drawBitmapNine(draw, bm, center, dst, paint);
1467 } 1474 }
1468 } 1475 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 } 1761 }
1755 1762
1756 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1763 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1757 ASSERT_SINGLE_OWNER 1764 ASSERT_SINGLE_OWNER
1758 // We always return a transient cache, so it is freed after each 1765 // We always return a transient cache, so it is freed after each
1759 // filter traversal. 1766 // filter traversal.
1760 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1767 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1761 } 1768 }
1762 1769
1763 #endif 1770 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.cpp ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698