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

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

Issue 318923005: SkShader::asNewEffect Refactoring (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added macros to check for gpu support Created 6 years, 6 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/effects/gradients/SkTwoPointRadialGradient.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 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes)) ; 1349 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes)) ;
1350 } else { 1350 } else {
1351 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param s)); 1351 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param s));
1352 } 1352 }
1353 1353
1354 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring 1354 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
1355 // the rest from the SkPaint. 1355 // the rest from the SkPaint.
1356 GrPaint grPaint; 1356 GrPaint grPaint;
1357 grPaint.addColorEffect(effect); 1357 grPaint.addColorEffect(effect);
1358 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); 1358 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config());
1359 SkPaint2GrPaintNoShader(this->context(), paint, alphaOnly, false, &grPaint); 1359 GrColor grColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
1360 SkColor2GrColor(paint.getColor());
1361 SkPaint2GrPaintNoShader(this->context(), paint, grColor, false, &grPaint);
1360 1362
1361 fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL); 1363 fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL);
1362 } 1364 }
1363 1365
1364 static bool filter_texture(SkBaseDevice* device, GrContext* context, 1366 static bool filter_texture(SkBaseDevice* device, GrContext* context,
1365 GrTexture* texture, const SkImageFilter* filter, 1367 GrTexture* texture, const SkImageFilter* filter,
1366 int w, int h, const SkImageFilter::Context& ctx, 1368 int w, int h, const SkImageFilter::Context& ctx,
1367 SkBitmap* result, SkIPoint* offset) { 1369 SkBitmap* result, SkIPoint* offset) {
1368 SkASSERT(filter); 1370 SkASSERT(filter);
1369 SkDeviceImageFilterProxy proxy(device); 1371 SkDeviceImageFilterProxy proxy(device);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 left += offset.x(); 1417 left += offset.x();
1416 top += offset.y(); 1418 top += offset.y();
1417 } else { 1419 } else {
1418 return; 1420 return;
1419 } 1421 }
1420 } 1422 }
1421 1423
1422 GrPaint grPaint; 1424 GrPaint grPaint;
1423 grPaint.addColorTextureEffect(texture, SkMatrix::I()); 1425 grPaint.addColorTextureEffect(texture, SkMatrix::I());
1424 1426
1425 SkPaint2GrPaintNoShader(this->context(), paint, true, false, &grPaint); 1427 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai nt.getColor()),
1428 false, &grPaint);
1426 1429
1427 fContext->drawRectToRect(grPaint, 1430 fContext->drawRectToRect(grPaint,
1428 SkRect::MakeXYWH(SkIntToScalar(left), 1431 SkRect::MakeXYWH(SkIntToScalar(left),
1429 SkIntToScalar(top), 1432 SkIntToScalar(top),
1430 SkIntToScalar(w), 1433 SkIntToScalar(w),
1431 SkIntToScalar(h)), 1434 SkIntToScalar(h)),
1432 SkRect::MakeXYWH(0, 1435 SkRect::MakeXYWH(0,
1433 0, 1436 0,
1434 SK_Scalar1 * w / texture->width(), 1437 SK_Scalar1 * w / texture->width(),
1435 SK_Scalar1 * h / texture->height() )); 1438 SK_Scalar1 * h / texture->height() ));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 x += offset.fX; 1526 x += offset.fX;
1524 y += offset.fY; 1527 y += offset.fY;
1525 } else { 1528 } else {
1526 return; 1529 return;
1527 } 1530 }
1528 } 1531 }
1529 1532
1530 GrPaint grPaint; 1533 GrPaint grPaint;
1531 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); 1534 grPaint.addColorTextureEffect(devTex, SkMatrix::I());
1532 1535
1533 SkPaint2GrPaintNoShader(this->context(), paint, true, false, &grPaint); 1536 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai nt.getColor()),
1537 false, &grPaint);
1534 1538
1535 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), 1539 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x),
1536 SkIntToScalar(y), 1540 SkIntToScalar(y),
1537 SkIntToScalar(w), 1541 SkIntToScalar(w),
1538 SkIntToScalar(h)); 1542 SkIntToScalar(h));
1539 1543
1540 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate 1544 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate
1541 // scratch texture). 1545 // scratch texture).
1542 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), 1546 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
1543 SK_Scalar1 * h / devTex->height()); 1547 SK_Scalar1 * h / devTex->height());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 pts[i + 5] = vertices[state.f0]; 1613 pts[i + 5] = vertices[state.f0];
1610 i += 6; 1614 i += 6;
1611 } 1615 }
1612 draw.drawPoints(SkCanvas::kLines_PointMode, i, pts, copy, true); 1616 draw.drawPoints(SkCanvas::kLines_PointMode, i, pts, copy, true);
1613 return; 1617 return;
1614 } 1618 }
1615 1619
1616 GrPaint grPaint; 1620 GrPaint grPaint;
1617 // we ignore the shader if texs is null. 1621 // we ignore the shader if texs is null.
1618 if (NULL == texs) { 1622 if (NULL == texs) {
1619 SkPaint2GrPaintNoShader(this->context(), paint, false, NULL == colors, & grPaint); 1623 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColor(paint.ge tColor()),
1624 NULL == colors, &grPaint);
1620 } else { 1625 } else {
1621 SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint); 1626 SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint);
1622 } 1627 }
1623 1628
1624 #if 0 1629 #if 0
1625 if (NULL != xmode && NULL != texs && NULL != colors) { 1630 if (NULL != xmode && NULL != texs && NULL != colors) {
1626 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { 1631 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) {
1627 SkDebugf("Unsupported vertex-color/texture xfer mode.\n"); 1632 SkDebugf("Unsupported vertex-color/texture xfer mode.\n");
1628 return; 1633 return;
1629 } 1634 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict ure, i); 1981 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict ure, i);
1977 1982
1978 if (NULL != layer->getTexture()) { 1983 if (NULL != layer->getTexture()) {
1979 fContext->unlockScratchTexture(layer->getTexture()); 1984 fContext->unlockScratchTexture(layer->getTexture());
1980 layer->setTexture(NULL); 1985 layer->setTexture(NULL);
1981 } 1986 }
1982 } 1987 }
1983 1988
1984 return true; 1989 return true;
1985 } 1990 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698