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

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

Issue 2250403003: Add alpha type to texture producer (Closed) Base URL: https://skia.googlesource.com/skia.git@image-alpha-type
Patch Set: 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/GrTextureParamsAdjuster.cpp ('k') | src/image/SkImage_Gpu.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 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 } 1311 }
1312 1312
1313 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y, 1313 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y,
1314 const SkPaint& paint) { 1314 const SkPaint& paint) {
1315 ASSERT_SINGLE_OWNER 1315 ASSERT_SINGLE_OWNER
1316 SkMatrix viewMatrix = *draw.fMatrix; 1316 SkMatrix viewMatrix = *draw.fMatrix;
1317 viewMatrix.preTranslate(x, y); 1317 viewMatrix.preTranslate(x, y);
1318 uint32_t pinnedUniqueID; 1318 uint32_t pinnedUniqueID;
1319 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) { 1319 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
1320 CHECK_SHOULD_DRAW(draw); 1320 CHECK_SHOULD_DRAW(draw);
1321 GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID, 1321 GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds( ), pinnedUniqueID,
1322 as_IB(image)->onImageInfo().colorSpace()); 1322 as_IB(image)->onImageInfo().colorSpace());
1323 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint, 1323 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint,
1324 viewMatrix, fClip, paint); 1324 viewMatrix, fClip, paint);
1325 return; 1325 return;
1326 } else { 1326 } else {
1327 SkBitmap bm; 1327 SkBitmap bm;
1328 if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstra int, 1328 if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstra int,
1329 paint.getFilterQuality(), *draw.fMatrix, SkMat rix::I())) { 1329 paint.getFilterQuality(), *draw.fMatrix, SkMat rix::I())) {
1330 // only support tiling as bitmap at the moment, so force raster-vers ion 1330 // only support tiling as bitmap at the moment, so force raster-vers ion
1331 if (!as_IB(image)->getROPixels(&bm)) { 1331 if (!as_IB(image)->getROPixels(&bm)) {
(...skipping 11 matching lines...) Expand all
1343 } 1343 }
1344 } 1344 }
1345 1345
1346 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 1346 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
1347 const SkRect& dst, const SkPaint& paint, 1347 const SkRect& dst, const SkPaint& paint,
1348 SkCanvas::SrcRectConstraint constraint) { 1348 SkCanvas::SrcRectConstraint constraint) {
1349 ASSERT_SINGLE_OWNER 1349 ASSERT_SINGLE_OWNER
1350 uint32_t pinnedUniqueID; 1350 uint32_t pinnedUniqueID;
1351 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) { 1351 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
1352 CHECK_SHOULD_DRAW(draw); 1352 CHECK_SHOULD_DRAW(draw);
1353 GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID, 1353 GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds( ), pinnedUniqueID,
1354 as_IB(image)->onImageInfo().colorSpace()); 1354 as_IB(image)->onImageInfo().colorSpace());
1355 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri x, fClip, paint); 1355 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri x, fClip, paint);
1356 return; 1356 return;
1357 } 1357 }
1358 SkBitmap bm; 1358 SkBitmap bm;
1359 SkMatrix srcToDstRect; 1359 SkMatrix srcToDstRect;
1360 srcToDstRect.setRectToRect((src ? *src : SkRect::MakeIWH(image->width(), ima ge->height())), 1360 srcToDstRect.setRectToRect((src ? *src : SkRect::MakeIWH(image->width(), ima ge->height())),
1361 dst, SkMatrix::kFill_ScaleToFit); 1361 dst, SkMatrix::kFill_ScaleToFit);
1362 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), *draw.fMatrix, 1362 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), *draw.fMatrix,
1363 srcToDstRect)) { 1363 srcToDstRect)) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() , 1414 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() ,
1415 producer->height(), center, dst); 1415 producer->height(), center, dst);
1416 } 1416 }
1417 1417
1418 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, 1418 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image,
1419 const SkIRect& center, const SkRect& dst, const SkPaint& paint) { 1419 const SkIRect& center, const SkRect& dst, const SkPaint& paint) {
1420 ASSERT_SINGLE_OWNER 1420 ASSERT_SINGLE_OWNER
1421 uint32_t pinnedUniqueID; 1421 uint32_t pinnedUniqueID;
1422 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) { 1422 if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
1423 CHECK_SHOULD_DRAW(draw); 1423 CHECK_SHOULD_DRAW(draw);
1424 GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID, 1424 GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds( ), pinnedUniqueID,
1425 as_IB(image)->onImageInfo().colorSpace()); 1425 as_IB(image)->onImageInfo().colorSpace());
1426 this->drawProducerNine(draw, &adjuster, center, dst, paint); 1426 this->drawProducerNine(draw, &adjuster, center, dst, paint);
1427 } else { 1427 } else {
1428 SkBitmap bm; 1428 SkBitmap bm;
1429 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { 1429 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
1430 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint); 1430 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint);
1431 this->drawProducerNine(draw, &maker, center, dst, paint); 1431 this->drawProducerNine(draw, &maker, center, dst, paint);
1432 } else if (as_IB(image)->getROPixels(&bm)) { 1432 } else if (as_IB(image)->getROPixels(&bm)) {
1433 this->drawBitmapNine(draw, bm, center, dst, paint); 1433 this->drawBitmapNine(draw, bm, center, dst, paint);
1434 } 1434 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 } 1721 }
1722 1722
1723 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1723 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1724 ASSERT_SINGLE_OWNER 1724 ASSERT_SINGLE_OWNER
1725 // We always return a transient cache, so it is freed after each 1725 // We always return a transient cache, so it is freed after each
1726 // filter traversal. 1726 // filter traversal.
1727 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1727 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1728 } 1728 }
1729 1729
1730 #endif 1730 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698