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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 442 |
443 #ifdef SK_DEBUG | 443 #ifdef SK_DEBUG |
444 check_bounds(fClipData, *draw.fClip, fRenderTarget->width(), fRenderTarget->
height()); | 444 check_bounds(fClipData, *draw.fClip, fRenderTarget->width(), fRenderTarget->
height()); |
445 #endif | 445 #endif |
446 | 446 |
447 fContext->setClip(&fClipData); | 447 fContext->setClip(&fClipData); |
448 | 448 |
449 DO_DEFERRED_CLEAR(); | 449 DO_DEFERRED_CLEAR(); |
450 } | 450 } |
451 | 451 |
452 SkGpuRenderTarget* SkGpuDevice::accessRenderTarget() { | 452 GrRenderTarget* SkGpuDevice::accessRenderTarget() { |
453 DO_DEFERRED_CLEAR(); | 453 DO_DEFERRED_CLEAR(); |
454 return (SkGpuRenderTarget*)fRenderTarget; | 454 return fRenderTarget; |
455 } | 455 } |
456 | 456 |
457 bool SkGpuDevice::bindDeviceAsTexture(GrPaint* paint) { | 457 bool SkGpuDevice::bindDeviceAsTexture(GrPaint* paint) { |
458 GrTexture* texture = fRenderTarget->asTexture(); | 458 GrTexture* texture = fRenderTarget->asTexture(); |
459 if (NULL != texture) { | 459 if (NULL != texture) { |
460 paint->colorStage(kBitmapEffectIdx)->setEffect( | 460 paint->colorStage(kBitmapEffectIdx)->setEffect( |
461 GrSimpleTextureEffect::Create(texture, SkMatrix::I()))->unref(); | 461 GrSimpleTextureEffect::Create(texture, SkMatrix::I()))->unref(); |
462 return true; | 462 return true; |
463 } | 463 } |
464 return false; | 464 return false; |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 // draw sprite uses the default texture params | 1487 // draw sprite uses the default texture params |
1488 SkAutoCachedTexture act(this, bitmap, NULL, &texture); | 1488 SkAutoCachedTexture act(this, bitmap, NULL, &texture); |
1489 grPaint.colorStage(kBitmapEffectIdx)->setEffect( | 1489 grPaint.colorStage(kBitmapEffectIdx)->setEffect( |
1490 GrSimpleTextureEffect::Create(texture, SkMatrix::I()))->unref(); | 1490 GrSimpleTextureEffect::Create(texture, SkMatrix::I()))->unref(); |
1491 | 1491 |
1492 SkImageFilter* filter = paint.getImageFilter(); | 1492 SkImageFilter* filter = paint.getImageFilter(); |
1493 if (NULL != filter) { | 1493 if (NULL != filter) { |
1494 SkBitmap filterBitmap; | 1494 SkBitmap filterBitmap; |
1495 if (filter_texture(this, fContext, texture, filter, w, h, &filterBitmap)
) { | 1495 if (filter_texture(this, fContext, texture, filter, w, h, &filterBitmap)
) { |
1496 grPaint.colorStage(kBitmapEffectIdx)->setEffect( | 1496 grPaint.colorStage(kBitmapEffectIdx)->setEffect( |
1497 GrSimpleTextureEffect::Create((GrTexture*) filterBitmap.getTextu
re(), SkMatrix::I()))->unref(); | 1497 GrSimpleTextureEffect::Create(filterBitmap.getTexture(), SkMatri
x::I()))->unref(); |
1498 texture = (GrTexture*) filterBitmap.getTexture(); | 1498 texture = filterBitmap.getTexture(); |
1499 w = filterBitmap.width(); | 1499 w = filterBitmap.width(); |
1500 h = filterBitmap.height(); | 1500 h = filterBitmap.height(); |
1501 } | 1501 } |
1502 } | 1502 } |
1503 | 1503 |
1504 fContext->drawRectToRect(grPaint, | 1504 fContext->drawRectToRect(grPaint, |
1505 GrRect::MakeXYWH(SkIntToScalar(left), | 1505 GrRect::MakeXYWH(SkIntToScalar(left), |
1506 SkIntToScalar(top), | 1506 SkIntToScalar(top), |
1507 SkIntToScalar(w), | 1507 SkIntToScalar(w), |
1508 SkIntToScalar(h)), | 1508 SkIntToScalar(h)), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 | 1564 |
1565 const SkBitmap& bm = dev->accessBitmap(false); | 1565 const SkBitmap& bm = dev->accessBitmap(false); |
1566 int w = bm.width(); | 1566 int w = bm.width(); |
1567 int h = bm.height(); | 1567 int h = bm.height(); |
1568 | 1568 |
1569 SkImageFilter* filter = paint.getImageFilter(); | 1569 SkImageFilter* filter = paint.getImageFilter(); |
1570 if (NULL != filter) { | 1570 if (NULL != filter) { |
1571 SkBitmap filterBitmap; | 1571 SkBitmap filterBitmap; |
1572 if (filter_texture(this, fContext, devTex, filter, w, h, &filterBitmap))
{ | 1572 if (filter_texture(this, fContext, devTex, filter, w, h, &filterBitmap))
{ |
1573 grPaint.colorStage(kBitmapEffectIdx)->setEffect( | 1573 grPaint.colorStage(kBitmapEffectIdx)->setEffect( |
1574 GrSimpleTextureEffect::Create((GrTexture*) filterBitmap.getTextu
re(), SkMatrix::I()))->unref(); | 1574 GrSimpleTextureEffect::Create(filterBitmap.getTexture(), SkMatri
x::I()))->unref(); |
1575 devTex = (GrTexture*) filterBitmap.getTexture(); | 1575 devTex = filterBitmap.getTexture(); |
1576 w = filterBitmap.width(); | 1576 w = filterBitmap.width(); |
1577 h = filterBitmap.height(); | 1577 h = filterBitmap.height(); |
1578 } | 1578 } |
1579 } | 1579 } |
1580 | 1580 |
1581 GrRect dstRect = GrRect::MakeXYWH(SkIntToScalar(x), | 1581 GrRect dstRect = GrRect::MakeXYWH(SkIntToScalar(x), |
1582 SkIntToScalar(y), | 1582 SkIntToScalar(y), |
1583 SkIntToScalar(w), | 1583 SkIntToScalar(w), |
1584 SkIntToScalar(h)); | 1584 SkIntToScalar(h)); |
1585 | 1585 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 GrTexture* texture, | 1852 GrTexture* texture, |
1853 bool needClear) | 1853 bool needClear) |
1854 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { | 1854 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { |
1855 | 1855 |
1856 GrAssert(texture && texture->asRenderTarget()); | 1856 GrAssert(texture && texture->asRenderTarget()); |
1857 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1857 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1858 // cache. We pass true for the third argument so that it will get unlocked. | 1858 // cache. We pass true for the third argument so that it will get unlocked. |
1859 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1859 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1860 fNeedClear = needClear; | 1860 fNeedClear = needClear; |
1861 } | 1861 } |
OLD | NEW |