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 "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1341 GrPaint grPaint; | 1341 GrPaint grPaint; |
1342 grPaint.addColorProcessor(fp); | 1342 grPaint.addColorProcessor(fp); |
1343 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); | 1343 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); |
1344 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor() ) : | 1344 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor() ) : |
1345 SkColor2GrColor(paint.getColor()); | 1345 SkColor2GrColor(paint.getColor()); |
1346 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint) ; | 1346 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint) ; |
1347 | 1347 |
1348 fContext->drawRectToRect(grPaint, dstRect, paintRect); | 1348 fContext->drawRectToRect(grPaint, dstRect, paintRect); |
1349 } | 1349 } |
1350 | 1350 |
1351 static bool filter_texture(SkBaseDevice* device, GrContext* context, | 1351 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
1352 GrTexture* texture, const SkImageFilter* filter, | 1352 const SkImageFilter* filter, |
1353 const SkImageFilter::Context& ctx, | 1353 const SkImageFilter::Context& ctx, |
1354 SkBitmap* result, SkIPoint* offset) { | 1354 SkBitmap* result, SkIPoint* offset) { |
1355 SkASSERT(filter); | 1355 SkASSERT(filter); |
reed1
2014/11/20 17:21:44
lets add a comment/bug to somehow get the "real" p
f(malita)
2014/11/20 18:35:21
Done.
| |
1356 SkDeviceImageFilterProxy proxy(device); | 1356 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties(). pixelGeometry())); |
1357 | 1357 |
1358 if (filter->canFilterImageGPU()) { | 1358 if (filter->canFilterImageGPU()) { |
1359 // Save the render target and set it to NULL, so we don't accidentally d raw to it in the | 1359 // Save the render target and set it to NULL, so we don't accidentally d raw to it in the |
1360 // filter. Also set the clip wide open and the matrix to identity. | 1360 // filter. Also set the clip wide open and the matrix to identity. |
1361 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); | 1361 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); |
1362 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result , offset); | 1362 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result , offset); |
1363 } else { | 1363 } else { |
1364 return false; | 1364 return false; |
1365 } | 1365 } |
1366 } | 1366 } |
(...skipping 21 matching lines...) Expand all Loading... | |
1388 | 1388 |
1389 if (filter) { | 1389 if (filter) { |
1390 SkIPoint offset = SkIPoint::Make(0, 0); | 1390 SkIPoint offset = SkIPoint::Make(0, 0); |
1391 SkMatrix matrix(*draw.fMatrix); | 1391 SkMatrix matrix(*draw.fMatrix); |
1392 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 1392 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
1393 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); | 1393 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); |
1394 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1394 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1395 // This cache is transient, and is freed (along with all its contained | 1395 // This cache is transient, and is freed (along with all its contained |
1396 // textures) when it goes out of scope. | 1396 // textures) when it goes out of scope. |
1397 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1397 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1398 if (filter_texture(this, fContext, texture, filter, ctx, &filteredBitmap , | 1398 if (this->filterTexture(fContext, texture, filter, ctx, &filteredBitmap, |
1399 &offset)) { | 1399 &offset)) { |
1400 texture = (GrTexture*) filteredBitmap.getTexture(); | 1400 texture = (GrTexture*) filteredBitmap.getTexture(); |
1401 w = filteredBitmap.width(); | 1401 w = filteredBitmap.width(); |
1402 h = filteredBitmap.height(); | 1402 h = filteredBitmap.height(); |
1403 left += offset.x(); | 1403 left += offset.x(); |
1404 top += offset.y(); | 1404 top += offset.y(); |
1405 } else { | 1405 } else { |
1406 return; | 1406 return; |
1407 } | 1407 } |
1408 } | 1408 } |
1409 | 1409 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1499 | 1499 |
1500 if (filter) { | 1500 if (filter) { |
1501 SkIPoint offset = SkIPoint::Make(0, 0); | 1501 SkIPoint offset = SkIPoint::Make(0, 0); |
1502 SkMatrix matrix(*draw.fMatrix); | 1502 SkMatrix matrix(*draw.fMatrix); |
1503 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1503 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
1504 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); | 1504 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); |
1505 // This cache is transient, and is freed (along with all its contained | 1505 // This cache is transient, and is freed (along with all its contained |
1506 // textures) when it goes out of scope. | 1506 // textures) when it goes out of scope. |
1507 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1507 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1508 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1508 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1509 if (filter_texture(this, fContext, devTex, filter, ctx, &filteredBitmap, | 1509 if (this->filterTexture(fContext, devTex, filter, ctx, &filteredBitmap, |
1510 &offset)) { | 1510 &offset)) { |
1511 devTex = filteredBitmap.getTexture(); | 1511 devTex = filteredBitmap.getTexture(); |
1512 w = filteredBitmap.width(); | 1512 w = filteredBitmap.width(); |
1513 h = filteredBitmap.height(); | 1513 h = filteredBitmap.height(); |
1514 x += offset.fX; | 1514 x += offset.fX; |
1515 y += offset.fY; | 1515 y += offset.fY; |
1516 } else { | 1516 } else { |
1517 return; | 1517 return; |
1518 } | 1518 } |
1519 } | 1519 } |
1520 | 1520 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 SkAutoLockPixels alp(src, !src.getTexture()); | 1552 SkAutoLockPixels alp(src, !src.getTexture()); |
1553 if (!src.getTexture() && !src.readyToDraw()) { | 1553 if (!src.getTexture() && !src.readyToDraw()) { |
1554 return false; | 1554 return false; |
1555 } | 1555 } |
1556 | 1556 |
1557 GrTexture* texture; | 1557 GrTexture* texture; |
1558 // We assume here that the filter will not attempt to tile the src. Otherwis e, this cache lookup | 1558 // We assume here that the filter will not attempt to tile the src. Otherwis e, this cache lookup |
1559 // must be pushed upstack. | 1559 // must be pushed upstack. |
1560 AutoBitmapTexture abt(fContext, src, NULL, &texture); | 1560 AutoBitmapTexture abt(fContext, src, NULL, &texture); |
1561 | 1561 |
1562 return filter_texture(this, fContext, texture, filter, ctx, result, offset); | 1562 return this->filterTexture(fContext, texture, filter, ctx, result, offset); |
1563 } | 1563 } |
1564 | 1564 |
1565 /////////////////////////////////////////////////////////////////////////////// | 1565 /////////////////////////////////////////////////////////////////////////////// |
1566 | 1566 |
1567 // must be in SkCanvas::VertexMode order | 1567 // must be in SkCanvas::VertexMode order |
1568 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { | 1568 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { |
1569 kTriangles_GrPrimitiveType, | 1569 kTriangles_GrPrimitiveType, |
1570 kTriangleStrip_GrPrimitiveType, | 1570 kTriangleStrip_GrPrimitiveType, |
1571 kTriangleFan_GrPrimitiveType, | 1571 kTriangleFan_GrPrimitiveType, |
1572 }; | 1572 }; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1838 return true; | 1838 return true; |
1839 } | 1839 } |
1840 | 1840 |
1841 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1841 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1842 // We always return a transient cache, so it is freed after each | 1842 // We always return a transient cache, so it is freed after each |
1843 // filter traversal. | 1843 // filter traversal. |
1844 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1844 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1845 } | 1845 } |
1846 | 1846 |
1847 #endif | 1847 #endif |
OLD | NEW |