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 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: rebase Created 6 years, 3 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/GrSWMaskHelper.cpp ('k') | src/gpu/SkGr.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 "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 GrPaint* grp, GrTexture* mask) { 581 GrPaint* grp, GrTexture* mask) {
582 GrContext::AutoMatrix am; 582 GrContext::AutoMatrix am;
583 if (!am.setIdentity(context, grp)) { 583 if (!am.setIdentity(context, grp)) {
584 return false; 584 return false;
585 } 585 }
586 586
587 SkMatrix matrix; 587 SkMatrix matrix;
588 matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop); 588 matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
589 matrix.postIDiv(mask->width(), mask->height()); 589 matrix.postIDiv(mask->width(), mask->height());
590 590
591 grp->addCoverageEffect(GrSimpleTextureEffect::Create(mask, matrix))->unref() ; 591 grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix))->unre f();
592 context->drawRect(*grp, maskRect); 592 context->drawRect(*grp, maskRect);
593 return true; 593 return true;
594 } 594 }
595 595
596 bool draw_with_mask_filter(GrContext* context, const SkPath& devPath, 596 bool draw_with_mask_filter(GrContext* context, const SkPath& devPath,
597 SkMaskFilter* filter, const SkRegion& clip, 597 SkMaskFilter* filter, const SkRegion& clip,
598 GrPaint* grp, SkPaint::Style style) { 598 GrPaint* grp, SkPaint::Style style) {
599 SkMask srcM, dstM; 599 SkMask srcM, dstM;
600 600
601 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &context->getMat rix(), &srcM, 601 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &context->getMat rix(), &srcM,
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; 1301 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() };
1302 SkRect paintRect; 1302 SkRect paintRect;
1303 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); 1303 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width()));
1304 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); 1304 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height()));
1305 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), 1305 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv),
1306 SkScalarMul(srcRect.fTop, hInv), 1306 SkScalarMul(srcRect.fTop, hInv),
1307 SkScalarMul(srcRect.fRight, wInv), 1307 SkScalarMul(srcRect.fRight, wInv),
1308 SkScalarMul(srcRect.fBottom, hInv)); 1308 SkScalarMul(srcRect.fBottom, hInv));
1309 1309
1310 SkRect textureDomain = SkRect::MakeEmpty(); 1310 SkRect textureDomain = SkRect::MakeEmpty();
1311 SkAutoTUnref<GrEffect> effect; 1311 SkAutoTUnref<GrFragmentProcessor> fp;
1312 if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) { 1312 if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) {
1313 // Use a constrained texture domain to avoid color bleeding 1313 // Use a constrained texture domain to avoid color bleeding
1314 SkScalar left, top, right, bottom; 1314 SkScalar left, top, right, bottom;
1315 if (srcRect.width() > SK_Scalar1) { 1315 if (srcRect.width() > SK_Scalar1) {
1316 SkScalar border = SK_ScalarHalf / texture->width(); 1316 SkScalar border = SK_ScalarHalf / texture->width();
1317 left = paintRect.left() + border; 1317 left = paintRect.left() + border;
1318 right = paintRect.right() - border; 1318 right = paintRect.right() - border;
1319 } else { 1319 } else {
1320 left = right = SkScalarHalf(paintRect.left() + paintRect.right()); 1320 left = right = SkScalarHalf(paintRect.left() + paintRect.right());
1321 } 1321 }
1322 if (srcRect.height() > SK_Scalar1) { 1322 if (srcRect.height() > SK_Scalar1) {
1323 SkScalar border = SK_ScalarHalf / texture->height(); 1323 SkScalar border = SK_ScalarHalf / texture->height();
1324 top = paintRect.top() + border; 1324 top = paintRect.top() + border;
1325 bottom = paintRect.bottom() - border; 1325 bottom = paintRect.bottom() - border;
1326 } else { 1326 } else {
1327 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); 1327 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
1328 } 1328 }
1329 textureDomain.setLTRB(left, top, right, bottom); 1329 textureDomain.setLTRB(left, top, right, bottom);
1330 if (bicubic) { 1330 if (bicubic) {
1331 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), texture Domain)); 1331 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDoma in));
1332 } else { 1332 } else {
1333 effect.reset(GrTextureDomainEffect::Create(texture, 1333 fp.reset(GrTextureDomainEffect::Create(texture,
1334 SkMatrix::I(), 1334 SkMatrix::I(),
1335 textureDomain, 1335 textureDomain,
1336 GrTextureDomain::kClamp_M ode, 1336 GrTextureDomain::kClamp_M ode,
1337 params.filterMode())); 1337 params.filterMode()));
1338 } 1338 }
1339 } else if (bicubic) { 1339 } else if (bicubic) {
1340 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); 1340 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
1341 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() }; 1341 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() };
1342 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes)) ; 1342 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes));
1343 } else { 1343 } else {
1344 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param s)); 1344 fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params));
1345 } 1345 }
1346 1346
1347 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring 1347 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
1348 // the rest from the SkPaint. 1348 // the rest from the SkPaint.
1349 GrPaint grPaint; 1349 GrPaint grPaint;
1350 grPaint.addColorEffect(effect); 1350 grPaint.addColorProcessor(fp);
1351 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); 1351 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
1352 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor() ) : 1352 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor() ) :
1353 SkColor2GrColor(paint.getColor()); 1353 SkColor2GrColor(paint.getColor());
1354 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint) ; 1354 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint) ;
1355 1355
1356 fContext->drawRectToRect(grPaint, dstRect, paintRect); 1356 fContext->drawRectToRect(grPaint, dstRect, paintRect);
1357 } 1357 }
1358 1358
1359 static bool filter_texture(SkBaseDevice* device, GrContext* context, 1359 static bool filter_texture(SkBaseDevice* device, GrContext* context,
1360 GrTexture* texture, const SkImageFilter* filter, 1360 GrTexture* texture, const SkImageFilter* filter,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 w = filteredBitmap.width(); 1409 w = filteredBitmap.width();
1410 h = filteredBitmap.height(); 1410 h = filteredBitmap.height();
1411 left += offset.x(); 1411 left += offset.x();
1412 top += offset.y(); 1412 top += offset.y();
1413 } else { 1413 } else {
1414 return; 1414 return;
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 GrPaint grPaint; 1418 GrPaint grPaint;
1419 grPaint.addColorTextureEffect(texture, SkMatrix::I()); 1419 grPaint.addColorTextureProcessor(texture, SkMatrix::I());
1420 1420
1421 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai nt.getColor()), 1421 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai nt.getColor()),
1422 false, &grPaint); 1422 false, &grPaint);
1423 1423
1424 fContext->drawRectToRect(grPaint, 1424 fContext->drawRectToRect(grPaint,
1425 SkRect::MakeXYWH(SkIntToScalar(left), 1425 SkRect::MakeXYWH(SkIntToScalar(left),
1426 SkIntToScalar(top), 1426 SkIntToScalar(top),
1427 SkIntToScalar(w), 1427 SkIntToScalar(w),
1428 SkIntToScalar(h)), 1428 SkIntToScalar(h)),
1429 SkRect::MakeXYWH(0, 1429 SkRect::MakeXYWH(0,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 w = filteredBitmap.width(); 1520 w = filteredBitmap.width();
1521 h = filteredBitmap.height(); 1521 h = filteredBitmap.height();
1522 x += offset.fX; 1522 x += offset.fX;
1523 y += offset.fY; 1523 y += offset.fY;
1524 } else { 1524 } else {
1525 return; 1525 return;
1526 } 1526 }
1527 } 1527 }
1528 1528
1529 GrPaint grPaint; 1529 GrPaint grPaint;
1530 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); 1530 grPaint.addColorTextureProcessor(devTex, SkMatrix::I());
1531 1531
1532 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai nt.getColor()), 1532 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai nt.getColor()),
1533 false, &grPaint); 1533 false, &grPaint);
1534 1534
1535 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), 1535 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x),
1536 SkIntToScalar(y), 1536 SkIntToScalar(y),
1537 SkIntToScalar(w), 1537 SkIntToScalar(w),
1538 SkIntToScalar(h)); 1538 SkIntToScalar(h));
1539 1539
1540 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate 1540 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture); 1881 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture);
1882 1882
1883 return true; 1883 return true;
1884 } 1884 }
1885 1885
1886 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1886 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1887 // We always return a transient cache, so it is freed after each 1887 // We always return a transient cache, so it is freed after each
1888 // filter traversal. 1888 // filter traversal.
1889 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1889 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1890 } 1890 }
OLDNEW
« no previous file with comments | « src/gpu/GrSWMaskHelper.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698