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

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

Issue 1507973005: Make "alpha only" be a property of GrTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@producernine
Patch Set: fix unused var Created 5 years 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/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice_drawTexture.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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 823
824 return this->shouldTileImageID(image->unique(), image->bounds(), viewMatrix, params, srcRectPtr, 824 return this->shouldTileImageID(image->unique(), image->bounds(), viewMatrix, params, srcRectPtr,
825 maxTileSize, &outTileSize, &outClippedSrcRect ); 825 maxTileSize, &outTileSize, &outClippedSrcRect );
826 } 826 }
827 827
828 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, 828 void SkGpuDevice::drawBitmap(const SkDraw& origDraw,
829 const SkBitmap& bitmap, 829 const SkBitmap& bitmap,
830 const SkMatrix& m, 830 const SkMatrix& m,
831 const SkPaint& paint) { 831 const SkPaint& paint) {
832 CHECK_SHOULD_DRAW(origDraw); 832 CHECK_SHOULD_DRAW(origDraw);
833 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType();
834 SkMatrix viewMatrix; 833 SkMatrix viewMatrix;
835 viewMatrix.setConcat(*origDraw.fMatrix, m); 834 viewMatrix.setConcat(*origDraw.fMatrix, m);
836 if (bitmap.getTexture()) { 835 if (bitmap.getTexture()) {
837 GrBitmapTextureAdjuster adjuster(&bitmap); 836 GrBitmapTextureAdjuster adjuster(&bitmap);
838 // We can use kFast here because we know texture-backed bitmaps don't su pport extractSubset. 837 // We can use kFast here because we know texture-backed bitmaps don't su pport extractSubset.
839 this->drawTextureProducer(&adjuster, alphaOnly, nullptr, nullptr, 838 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint,
840 SkCanvas::kFast_SrcRectConstraint, viewMatrix, fClip, paint); 839 viewMatrix, fClip, paint);
841 return; 840 return;
842 } 841 }
843 int maxTileSize = fContext->caps()->maxTileSize(); 842 int maxTileSize = fContext->caps()->maxTileSize();
844 843
845 // The tile code path doesn't currently support AA, so if the paint asked fo r aa and we could 844 // The tile code path doesn't currently support AA, so if the paint asked fo r aa and we could
846 // draw untiled, then we bypass checking for tiling purely for optimization reasons. 845 // draw untiled, then we bypass checking for tiling purely for optimization reasons.
847 bool drawAA = !fRenderTarget->isUnifiedMultisampled() && 846 bool drawAA = !fRenderTarget->isUnifiedMultisampled() &&
848 paint.isAntiAlias() && 847 paint.isAntiAlias() &&
849 bitmap.width() <= maxTileSize && 848 bitmap.width() <= maxTileSize &&
850 bitmap.height() <= maxTileSize; 849 bitmap.height() <= maxTileSize;
(...skipping 24 matching lines...) Expand all
875 874
876 int maxTileSizeForFilter = fContext->caps()->maxTileSize() - 2 * tileFil terPad; 875 int maxTileSizeForFilter = fContext->caps()->maxTileSize() - 2 * tileFil terPad;
877 if (this->shouldTileBitmap(bitmap, viewMatrix, params, &srcRect, 876 if (this->shouldTileBitmap(bitmap, viewMatrix, params, &srcRect,
878 maxTileSizeForFilter, &tileSize, &clippedSrcR ect)) { 877 maxTileSizeForFilter, &tileSize, &clippedSrcR ect)) {
879 this->drawTiledBitmap(bitmap, viewMatrix, srcRect, clippedSrcRect, p arams, paint, 878 this->drawTiledBitmap(bitmap, viewMatrix, srcRect, clippedSrcRect, p arams, paint,
880 SkCanvas::kStrict_SrcRectConstraint, tileSize, doBicubic); 879 SkCanvas::kStrict_SrcRectConstraint, tileSize, doBicubic);
881 return; 880 return;
882 } 881 }
883 } 882 }
884 GrBitmapTextureMaker maker(fContext, bitmap); 883 GrBitmapTextureMaker maker(fContext, bitmap);
885 this->drawTextureProducer(&maker, alphaOnly, nullptr, nullptr, 884 this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kStrict_SrcRec tConstraint,
886 SkCanvas::kStrict_SrcRectConstraint, viewMatrix, f Clip, paint); 885 viewMatrix, fClip, paint);
887 } 886 }
888 887
889 // This method outsets 'iRect' by 'outset' all around and then clamps its extent s to 888 // This method outsets 'iRect' by 'outset' all around and then clamps its extent s to
890 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner 889 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner
891 // of 'iRect' for all possible outsets/clamps. 890 // of 'iRect' for all possible outsets/clamps.
892 static inline void clamped_outset_with_offset(SkIRect* iRect, 891 static inline void clamped_outset_with_offset(SkIRect* iRect,
893 int outset, 892 int outset,
894 SkPoint* offset, 893 SkPoint* offset,
895 const SkIRect& clamp) { 894 const SkIRect& clamp) {
896 iRect->outset(outset, outset); 895 iRect->outset(outset, outset);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 SkIntToScalar(h)), 1207 SkIntToScalar(h)),
1209 SkRect::MakeXYWH(0, 1208 SkRect::MakeXYWH(0,
1210 0, 1209 0,
1211 SK_Scalar1 * w / texture->widt h(), 1210 SK_Scalar1 * w / texture->widt h(),
1212 SK_Scalar1 * h / texture->heig ht())); 1211 SK_Scalar1 * h / texture->heig ht()));
1213 } 1212 }
1214 1213
1215 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 1214 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
1216 const SkRect* src, const SkRect& origDst, 1215 const SkRect* src, const SkRect& origDst,
1217 const SkPaint& paint, SkCanvas::SrcRectConstrai nt constraint) { 1216 const SkPaint& paint, SkCanvas::SrcRectConstrai nt constraint) {
1218 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType();
1219 if (bitmap.getTexture()) { 1217 if (bitmap.getTexture()) {
1220 CHECK_SHOULD_DRAW(draw); 1218 CHECK_SHOULD_DRAW(draw);
1221 GrBitmapTextureAdjuster adjuster(&bitmap); 1219 GrBitmapTextureAdjuster adjuster(&bitmap);
1222 this->drawTextureProducer(&adjuster, alphaOnly, src, &origDst, constrain t, *draw.fMatrix, 1220 this->drawTextureProducer(&adjuster, src, &origDst, constraint, *draw.fM atrix, fClip,
1223 fClip, paint); 1221 paint);
1224 return; 1222 return;
1225 } 1223 }
1226 // The src rect is inferred to be the bmp bounds if not provided. Otherwise, the src rect must 1224 // The src rect is inferred to be the bmp bounds if not provided. Otherwise, the src rect must
1227 // be clipped to the bmp bounds. To determine tiling parameters we need the filter mode which 1225 // be clipped to the bmp bounds. To determine tiling parameters we need the filter mode which
1228 // in turn requires knowing the src-to-dst mapping. If the src was clipped t o the bmp bounds 1226 // in turn requires knowing the src-to-dst mapping. If the src was clipped t o the bmp bounds
1229 // then we use the src-to-dst mapping to compute a new clipped dst rect. 1227 // then we use the src-to-dst mapping to compute a new clipped dst rect.
1230 const SkRect* dst = &origDst; 1228 const SkRect* dst = &origDst;
1231 const SkRect bmpBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height()); 1229 const SkRect bmpBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height());
1232 // Compute matrix from the two rectangles 1230 // Compute matrix from the two rectangles
1233 if (!src) { 1231 if (!src) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 viewMatrix.preTranslate(dst->fLeft, dst->fTop); 1288 viewMatrix.preTranslate(dst->fLeft, dst->fTop);
1291 viewMatrix.preScale(dst->width()/src->width(), dst->height()/src->height ()); 1289 viewMatrix.preScale(dst->width()/src->width(), dst->height()/src->height ());
1292 if (this->shouldTileBitmap(bitmap, viewMatrix, params, src, 1290 if (this->shouldTileBitmap(bitmap, viewMatrix, params, src,
1293 maxTileSizeForFilter, &tileSize, &clippedSrcR ect)) { 1291 maxTileSizeForFilter, &tileSize, &clippedSrcR ect)) {
1294 this->drawTiledBitmap(bitmap, viewMatrix, *src, clippedSrcRect, para ms, paint, 1292 this->drawTiledBitmap(bitmap, viewMatrix, *src, clippedSrcRect, para ms, paint,
1295 constraint, tileSize, doBicubic); 1293 constraint, tileSize, doBicubic);
1296 return; 1294 return;
1297 } 1295 }
1298 } 1296 }
1299 GrBitmapTextureMaker maker(fContext, bitmap); 1297 GrBitmapTextureMaker maker(fContext, bitmap);
1300 this->drawTextureProducer(&maker, alphaOnly, src, dst, constraint, *draw.fMa trix, fClip, paint); 1298 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip , paint);
1301 } 1299 }
1302 1300
1303 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 1301 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
1304 int x, int y, const SkPaint& paint) { 1302 int x, int y, const SkPaint& paint) {
1305 // clear of the source device must occur before CHECK_SHOULD_DRAW 1303 // clear of the source device must occur before CHECK_SHOULD_DRAW
1306 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext); 1304 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext);
1307 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); 1305 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
1308 1306
1309 // TODO: If the source device covers the whole of this device, we could 1307 // TODO: If the source device covers the whole of this device, we could
1310 // omit fNeedsClear -related flushing. 1308 // omit fNeedsClear -related flushing.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 } 1403 }
1406 1404
1407 return this->filterTexture(fContext, texture, src.width(), src.height(), 1405 return this->filterTexture(fContext, texture, src.width(), src.height(),
1408 filter, ctx, result, offset); 1406 filter, ctx, result, offset);
1409 } 1407 }
1410 1408
1411 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y, 1409 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y,
1412 const SkPaint& paint) { 1410 const SkPaint& paint) {
1413 SkMatrix viewMatrix = *draw.fMatrix; 1411 SkMatrix viewMatrix = *draw.fMatrix;
1414 viewMatrix.preTranslate(x, y); 1412 viewMatrix.preTranslate(x, y);
1415 if (GrTexture* tex = as_IB(image)->peekTexture()) { 1413 if (as_IB(image)->peekTexture()) {
1416 CHECK_SHOULD_DRAW(draw); 1414 CHECK_SHOULD_DRAW(draw);
1417 bool alphaOnly = GrPixelConfigIsAlphaOnly(tex->config());
1418 GrImageTextureAdjuster adjuster(as_IB(image)); 1415 GrImageTextureAdjuster adjuster(as_IB(image));
1419 this->drawTextureProducer(&adjuster, alphaOnly, nullptr, nullptr, 1416 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint,
1420 SkCanvas::kFast_SrcRectConstraint, viewMatrix, fClip, paint); 1417 viewMatrix, fClip, paint);
1421 return; 1418 return;
1422 } else { 1419 } else {
1423 SkBitmap bm; 1420 SkBitmap bm;
1424 if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstra int, 1421 if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstra int,
1425 paint.getFilterQuality(), *draw.fMatrix)) { 1422 paint.getFilterQuality(), *draw.fMatrix)) {
1426 // only support tiling as bitmap at the moment, so force raster-vers ion 1423 // only support tiling as bitmap at the moment, so force raster-vers ion
1427 if (!as_IB(image)->getROPixels(&bm)) { 1424 if (!as_IB(image)->getROPixels(&bm)) {
1428 return; 1425 return;
1429 } 1426 }
1430 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 1427 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
1431 } else if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { 1428 } else if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
1432 CHECK_SHOULD_DRAW(draw); 1429 CHECK_SHOULD_DRAW(draw);
1433 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint); 1430 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint);
1434 bool alphaOnly = kAlpha_8_SkColorType == cacher->info().colorType(); 1431 this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_ SrcRectConstraint,
1435 this->drawTextureProducer(&maker, alphaOnly, nullptr, nullptr, 1432 viewMatrix, fClip, paint);
1436 SkCanvas::kFast_SrcRectConstraint, viewMat rix, fClip, paint);
1437 } else if (as_IB(image)->getROPixels(&bm)) { 1433 } else if (as_IB(image)->getROPixels(&bm)) {
1438 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 1434 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
1439 } 1435 }
1440 } 1436 }
1441 } 1437 }
1442 1438
1443 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 1439 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
1444 const SkRect& dst, const SkPaint& paint, 1440 const SkRect& dst, const SkPaint& paint,
1445 SkCanvas::SrcRectConstraint constraint) { 1441 SkCanvas::SrcRectConstraint constraint) {
1446 if (GrTexture* tex = as_IB(image)->peekTexture()) { 1442 if (as_IB(image)->peekTexture()) {
1447 CHECK_SHOULD_DRAW(draw); 1443 CHECK_SHOULD_DRAW(draw);
1448 GrImageTextureAdjuster adjuster(as_IB(image)); 1444 GrImageTextureAdjuster adjuster(as_IB(image));
1449 bool alphaOnly = GrPixelConfigIsAlphaOnly(tex->config()); 1445 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri x, fClip, paint);
1450 this->drawTextureProducer(&adjuster, alphaOnly, src, &dst, constraint, * draw.fMatrix,
1451 fClip, paint);
1452 return; 1446 return;
1453 } 1447 }
1454 SkBitmap bm; 1448 SkBitmap bm;
1455 SkMatrix totalMatrix = *draw.fMatrix; 1449 SkMatrix totalMatrix = *draw.fMatrix;
1456 totalMatrix.preScale(dst.width() / (src ? src->width() : image->width()), 1450 totalMatrix.preScale(dst.width() / (src ? src->width() : image->width()),
1457 dst.height() / (src ? src->height() : image->height())) ; 1451 dst.height() / (src ? src->height() : image->height())) ;
1458 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), totalMatrix)) { 1452 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), totalMatrix)) {
1459 // only support tiling as bitmap at the moment, so force raster-version 1453 // only support tiling as bitmap at the moment, so force raster-version
1460 if (!as_IB(image)->getROPixels(&bm)) { 1454 if (!as_IB(image)->getROPixels(&bm)) {
1461 return; 1455 return;
1462 } 1456 }
1463 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); 1457 this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
1464 } else if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { 1458 } else if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
1465 CHECK_SHOULD_DRAW(draw); 1459 CHECK_SHOULD_DRAW(draw);
1466 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_Cachi ngHint); 1460 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_Cachi ngHint);
1467 bool alphaOnly = kAlpha_8_SkColorType == cacher->info().colorType(); 1461 this->drawTextureProducer(&maker, src, &dst, constraint, *draw.fMatrix, fClip, paint);
1468 this->drawTextureProducer(&maker, alphaOnly, src, &dst, constraint, *dra w.fMatrix,
1469 fClip, paint);
1470 } else if (as_IB(image)->getROPixels(&bm)) { 1462 } else if (as_IB(image)->getROPixels(&bm)) {
1471 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); 1463 this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
1472 } 1464 }
1473 } 1465 }
1474 1466
1475 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc er, bool alphaOnly, 1467 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc er,
1476 const SkIRect& center, const SkRect& dst, con st SkPaint& paint) { 1468 const SkIRect& center, const SkRect& dst, con st SkPaint& paint) {
1477 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawProducerNine", fContext); 1469 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawProducerNine", fContext);
1478 1470
1479 CHECK_FOR_ANNOTATION(paint); 1471 CHECK_FOR_ANNOTATION(paint);
1480 CHECK_SHOULD_DRAW(draw); 1472 CHECK_SHOULD_DRAW(draw);
1481 1473
1482 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() || 1474 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() ||
1483 fRenderTarget->isUnifiedMultisampled(); 1475 fRenderTarget->isUnifiedMultisampled();
1484 bool doBicubic; 1476 bool doBicubic;
1485 GrTextureParams::FilterMode textureFilterMode = 1477 GrTextureParams::FilterMode textureFilterMode =
1486 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(), 1478 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(),
1487 &doBicubic); 1479 &doBicubic);
1488 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) { 1480 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) {
1489 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ; 1481 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ;
1490 1482
1491 SkRect srcR, dstR; 1483 SkRect srcR, dstR;
1492 while (iter.next(&srcR, &dstR)) { 1484 while (iter.next(&srcR, &dstR)) {
1493 this->drawTextureProducer(producer, alphaOnly, &srcR, &dstR, 1485 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_ SrcRectConstraint,
1494 SkCanvas::kStrict_SrcRectConstraint, *dra w.fMatrix, fClip, 1486 *draw.fMatrix, fClip, paint);
1495 paint);
1496 } 1487 }
1497 return; 1488 return;
1498 } 1489 }
1499 1490
1500 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode; 1491 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode;
1501 SkAutoTUnref<const GrFragmentProcessor> fp( 1492 SkAutoTUnref<const GrFragmentProcessor> fp(
1502 producer->createFragmentProcessor(SkMatrix::I(), 1493 producer->createFragmentProcessor(SkMatrix::I(),
1503 SkRect::MakeIWH(producer->width(), pro ducer->height()), 1494 SkRect::MakeIWH(producer->width(), pro ducer->height()),
1504 GrTextureProducer::kNo_FilterConstrain t, true, 1495 GrTextureProducer::kNo_FilterConstrain t, true,
1505 &kMode)); 1496 &kMode));
1506 GrPaint grPaint; 1497 GrPaint grPaint;
1507 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp, 1498 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp,
1508 alphaOnly, &grPaint)) { 1499 producer->isAlphaOnly(), &grPaint)) {
1509 return; 1500 return;
1510 } 1501 }
1511 1502
1512 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() , 1503 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() ,
1513 producer->height(), center, dst); 1504 producer->height(), center, dst);
1514 } 1505 }
1515 1506
1516 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, 1507 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image,
1517 const SkIRect& center, const SkRect& dst, const SkPaint& paint) { 1508 const SkIRect& center, const SkRect& dst, const SkPaint& paint) {
1518 if (GrTexture* tex = as_IB(image)->peekTexture()) { 1509 if (as_IB(image)->peekTexture()) {
1519 bool alphaOnly = GrPixelConfigIsAlphaOnly(tex->config());
1520 GrImageTextureAdjuster adjuster(as_IB(image)); 1510 GrImageTextureAdjuster adjuster(as_IB(image));
1521 this->drawProducerNine(draw, &adjuster, alphaOnly, center, dst, paint); 1511 this->drawProducerNine(draw, &adjuster, center, dst, paint);
1522 } else { 1512 } else {
1523 SkBitmap bm; 1513 SkBitmap bm;
1524 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { 1514 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
1525 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint); 1515 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C achingHint);
1526 bool alphaOnly = kAlpha_8_SkColorType == cacher->info().colorType(); 1516 this->drawProducerNine(draw, &maker, center, dst, paint);
1527 this->drawProducerNine(draw, &maker, alphaOnly, center, dst, paint);
1528 } else if (as_IB(image)->getROPixels(&bm)) { 1517 } else if (as_IB(image)->getROPixels(&bm)) {
1529 this->drawBitmapNine(draw, bm, center, dst, paint); 1518 this->drawBitmapNine(draw, bm, center, dst, paint);
1530 } 1519 }
1531 } 1520 }
1532 } 1521 }
1533 1522
1534 void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con st SkIRect& center, 1523 void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con st SkIRect& center,
1535 const SkRect& dst, const SkPaint& paint) { 1524 const SkRect& dst, const SkPaint& paint) {
1536 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType();
1537 if (bitmap.getTexture()) { 1525 if (bitmap.getTexture()) {
1538 GrBitmapTextureAdjuster adjuster(&bitmap); 1526 GrBitmapTextureAdjuster adjuster(&bitmap);
1539 this->drawProducerNine(draw, &adjuster, alphaOnly, center, dst, paint); 1527 this->drawProducerNine(draw, &adjuster, center, dst, paint);
1540 } else { 1528 } else {
1541 GrBitmapTextureMaker maker(fContext, bitmap); 1529 GrBitmapTextureMaker maker(fContext, bitmap);
1542 this->drawProducerNine(draw, &maker, alphaOnly, center, dst, paint); 1530 this->drawProducerNine(draw, &maker, center, dst, paint);
1543 } 1531 }
1544 } 1532 }
1545 1533
1546 /////////////////////////////////////////////////////////////////////////////// 1534 ///////////////////////////////////////////////////////////////////////////////
1547 1535
1548 // must be in SkCanvas::VertexMode order 1536 // must be in SkCanvas::VertexMode order
1549 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1537 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1550 kTriangles_GrPrimitiveType, 1538 kTriangles_GrPrimitiveType,
1551 kTriangleStrip_GrPrimitiveType, 1539 kTriangleStrip_GrPrimitiveType,
1552 kTriangleFan_GrPrimitiveType, 1540 kTriangleFan_GrPrimitiveType,
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1874 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1887 } 1875 }
1888 1876
1889 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1877 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1890 // We always return a transient cache, so it is freed after each 1878 // We always return a transient cache, so it is freed after each
1891 // filter traversal. 1879 // filter traversal.
1892 return SkGpuDevice::NewImageFilterCache(); 1880 return SkGpuDevice::NewImageFilterCache();
1893 } 1881 }
1894 1882
1895 #endif 1883 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice_drawTexture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698