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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 } | 1380 } |
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(left, top); |
1391 // This bitmap will own the filtered result as a texture. | 1391 // This bitmap will own the filtered result as a texture. |
1392 SkBitmap filteredBitmap; | 1392 SkBitmap filteredBitmap; |
1393 | 1393 |
1394 if (NULL != filter) { | 1394 if (NULL != filter) { |
1395 if (filter_texture(this, fContext, texture, filter, w, h, &filteredBitma
p, &offset)) { | 1395 if (filter_texture(this, fContext, texture, filter, w, h, &filteredBitma
p, &offset)) { |
1396 texture = (GrTexture*) filteredBitmap.getTexture(); | 1396 texture = (GrTexture*) filteredBitmap.getTexture(); |
1397 w = filteredBitmap.width(); | 1397 w = filteredBitmap.width(); |
1398 h = filteredBitmap.height(); | 1398 h = filteredBitmap.height(); |
1399 } | 1399 } |
1400 } | 1400 } |
1401 | 1401 |
1402 GrPaint grPaint; | 1402 GrPaint grPaint; |
1403 grPaint.addColorTextureEffect(texture, SkMatrix::I()); | 1403 grPaint.addColorTextureEffect(texture, SkMatrix::I()); |
1404 | 1404 |
1405 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { | 1405 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { |
1406 return; | 1406 return; |
1407 } | 1407 } |
1408 | 1408 |
1409 fContext->drawRectToRect(grPaint, | 1409 fContext->drawRectToRect(grPaint, |
1410 SkRect::MakeXYWH(SkIntToScalar(left), | 1410 SkRect::MakeXYWH(SkIntToScalar(offset.fX), |
1411 SkIntToScalar(top), | 1411 SkIntToScalar(offset.fY), |
1412 SkIntToScalar(w), | 1412 SkIntToScalar(w), |
1413 SkIntToScalar(h)), | 1413 SkIntToScalar(h)), |
1414 SkRect::MakeXYWH(SkIntToScalar(offset.fX), | 1414 SkRect::MakeXYWH(0, |
1415 SkIntToScalar(offset.fY), | 1415 0, |
1416 SK_Scalar1 * w / texture->width(), | 1416 SK_Scalar1 * w / texture->width(), |
1417 SK_Scalar1 * h / texture->height()
)); | 1417 SK_Scalar1 * h / texture->height()
)); |
1418 } | 1418 } |
1419 | 1419 |
1420 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, | 1420 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
1421 const SkRect* src, const SkRect& dst, | 1421 const SkRect* src, const SkRect& dst, |
1422 const SkPaint& paint) { | 1422 const SkPaint& paint) { |
1423 SkMatrix matrix; | 1423 SkMatrix matrix; |
1424 SkRect bitmapBounds, tmpSrc; | 1424 SkRect bitmapBounds, tmpSrc; |
1425 | 1425 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 GrTexture* texture, | 1763 GrTexture* texture, |
1764 bool needClear) | 1764 bool needClear) |
1765 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { | 1765 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { |
1766 | 1766 |
1767 GrAssert(texture && texture->asRenderTarget()); | 1767 GrAssert(texture && texture->asRenderTarget()); |
1768 // 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 |
1769 // 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. |
1770 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1770 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1771 fNeedClear = needClear; | 1771 fNeedClear = needClear; |
1772 } | 1772 } |
OLD | NEW |