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/GrTextureDomainEffect.h" | 10 #include "effects/GrTextureDomainEffect.h" |
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 | 1381 |
1382 int w = bitmap.width(); | 1382 int w = bitmap.width(); |
1383 int h = bitmap.height(); | 1383 int h = bitmap.height(); |
1384 | 1384 |
1385 GrTexture* texture; | 1385 GrTexture* texture; |
1386 // draw sprite uses the default texture params | 1386 // draw sprite uses the default texture params |
1387 SkAutoCachedTexture act(this, bitmap, NULL, &texture); | 1387 SkAutoCachedTexture act(this, bitmap, NULL, &texture); |
1388 | 1388 |
1389 SkImageFilter* filter = paint.getImageFilter(); | 1389 SkImageFilter* filter = paint.getImageFilter(); |
1390 SkIPoint offset = SkIPoint::Make(0, 0); | 1390 SkIPoint offset = SkIPoint::Make(0, 0); |
| 1391 // This bitmap will own the filtered result as a texture. |
| 1392 SkBitmap filteredBitmap; |
| 1393 |
1391 if (NULL != filter) { | 1394 if (NULL != filter) { |
1392 SkBitmap filterBitmap; | 1395 if (filter_texture(this, fContext, texture, filter, w, h, &filteredBitma
p, &offset)) { |
1393 if (filter_texture(this, fContext, texture, filter, w, h, &filterBitmap,
&offset)) { | 1396 texture = (GrTexture*) filteredBitmap.getTexture(); |
1394 texture = (GrTexture*) filterBitmap.getTexture(); | 1397 w = filteredBitmap.width(); |
1395 w = filterBitmap.width(); | 1398 h = filteredBitmap.height(); |
1396 h = filterBitmap.height(); | |
1397 } | 1399 } |
1398 } | 1400 } |
1399 | 1401 |
1400 GrPaint grPaint; | 1402 GrPaint grPaint; |
1401 grPaint.addColorTextureEffect(texture, SkMatrix::I()); | 1403 grPaint.addColorTextureEffect(texture, SkMatrix::I()); |
1402 | 1404 |
1403 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { | 1405 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { |
1404 return; | 1406 return; |
1405 } | 1407 } |
1406 | 1408 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 GrTexture* devTex; | 1463 GrTexture* devTex; |
1462 if (NULL == (devTex = devRT->asTexture())) { | 1464 if (NULL == (devTex = devRT->asTexture())) { |
1463 return; | 1465 return; |
1464 } | 1466 } |
1465 | 1467 |
1466 const SkBitmap& bm = dev->accessBitmap(false); | 1468 const SkBitmap& bm = dev->accessBitmap(false); |
1467 int w = bm.width(); | 1469 int w = bm.width(); |
1468 int h = bm.height(); | 1470 int h = bm.height(); |
1469 | 1471 |
1470 SkImageFilter* filter = paint.getImageFilter(); | 1472 SkImageFilter* filter = paint.getImageFilter(); |
| 1473 // This bitmap will own the filtered result as a texture. |
| 1474 SkBitmap filteredBitmap; |
1471 | 1475 |
1472 if (NULL != filter) { | 1476 if (NULL != filter) { |
1473 SkBitmap filterBitmap; | |
1474 SkIPoint offset = SkIPoint::Make(0, 0); | 1477 SkIPoint offset = SkIPoint::Make(0, 0); |
1475 if (filter_texture(this, fContext, devTex, filter, w, h, &filterBitmap,
&offset)) { | 1478 if (filter_texture(this, fContext, devTex, filter, w, h, &filteredBitmap
, &offset)) { |
1476 devTex = filterBitmap.getTexture(); | 1479 devTex = filteredBitmap.getTexture(); |
1477 w = filterBitmap.width(); | 1480 w = filteredBitmap.width(); |
1478 h = filterBitmap.height(); | 1481 h = filteredBitmap.height(); |
1479 x += offset.fX; | 1482 x += offset.fX; |
1480 y += offset.fY; | 1483 y += offset.fY; |
1481 } | 1484 } |
1482 } | 1485 } |
1483 | 1486 |
1484 GrPaint grPaint; | 1487 GrPaint grPaint; |
1485 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); | 1488 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); |
1486 | 1489 |
1487 if (!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { | 1490 if (!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { |
1488 return; | 1491 return; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 GrTexture* texture, | 1763 GrTexture* texture, |
1761 bool needClear) | 1764 bool needClear) |
1762 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { | 1765 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { |
1763 | 1766 |
1764 GrAssert(texture && texture->asRenderTarget()); | 1767 GrAssert(texture && texture->asRenderTarget()); |
1765 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1768 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1766 // cache. We pass true for the third argument so that it will get unlocked. | 1769 // cache. We pass true for the third argument so that it will get unlocked. |
1767 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1770 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1768 fNeedClear = needClear; | 1771 fNeedClear = needClear; |
1769 } | 1772 } |
OLD | NEW |