OLD | NEW |
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 Loading... |
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 GrRawTextureAdjuster adjuster(tex.get(), image->dimensions(), pinnedUniq
ueID, |
| 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 GrRawTextureAdjuster adjuster(tex.get(), image->dimensions(), pinnedUniq
ueID, |
| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 } | 1758 } |
1755 | 1759 |
1756 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1760 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1757 ASSERT_SINGLE_OWNER | 1761 ASSERT_SINGLE_OWNER |
1758 // We always return a transient cache, so it is freed after each | 1762 // We always return a transient cache, so it is freed after each |
1759 // filter traversal. | 1763 // filter traversal. |
1760 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1764 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1761 } | 1765 } |
1762 | 1766 |
1763 #endif | 1767 #endif |
OLD | NEW |