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

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

Issue 19775006: Implement crop rect for SkImageFilter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkGpuBlurUtils.cpp ('k') | src/gpu/effects/GrConvolutionEffect.h » ('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/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } else {
1400 return;
1399 } 1401 }
1400 } 1402 }
1401 1403
1402 GrPaint grPaint; 1404 GrPaint grPaint;
1403 grPaint.addColorTextureEffect(texture, SkMatrix::I()); 1405 grPaint.addColorTextureEffect(texture, SkMatrix::I());
1404 1406
1405 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { 1407 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) {
1406 return; 1408 return;
1407 } 1409 }
1408 1410
1409 fContext->drawRectToRect(grPaint, 1411 fContext->drawRectToRect(grPaint,
1410 SkRect::MakeXYWH(SkIntToScalar(left), 1412 SkRect::MakeXYWH(SkIntToScalar(offset.fX),
1411 SkIntToScalar(top), 1413 SkIntToScalar(offset.fY),
1412 SkIntToScalar(w), 1414 SkIntToScalar(w),
1413 SkIntToScalar(h)), 1415 SkIntToScalar(h)),
1414 SkRect::MakeXYWH(SkIntToScalar(offset.fX), 1416 SkRect::MakeXYWH(0,
1415 SkIntToScalar(offset.fY), 1417 0,
1416 SK_Scalar1 * w / texture->width(), 1418 SK_Scalar1 * w / texture->width(),
1417 SK_Scalar1 * h / texture->height() )); 1419 SK_Scalar1 * h / texture->height() ));
1418 } 1420 }
1419 1421
1420 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 1422 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
1421 const SkRect* src, const SkRect& dst, 1423 const SkRect* src, const SkRect& dst,
1422 const SkPaint& paint) { 1424 const SkPaint& paint) {
1423 SkMatrix matrix; 1425 SkMatrix matrix;
1424 SkRect bitmapBounds, tmpSrc; 1426 SkRect bitmapBounds, tmpSrc;
1425 1427
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 SkBitmap filteredBitmap; 1476 SkBitmap filteredBitmap;
1475 1477
1476 if (NULL != filter) { 1478 if (NULL != filter) {
1477 SkIPoint offset = SkIPoint::Make(0, 0); 1479 SkIPoint offset = SkIPoint::Make(0, 0);
1478 if (filter_texture(this, fContext, devTex, filter, w, h, &filteredBitmap , &offset)) { 1480 if (filter_texture(this, fContext, devTex, filter, w, h, &filteredBitmap , &offset)) {
1479 devTex = filteredBitmap.getTexture(); 1481 devTex = filteredBitmap.getTexture();
1480 w = filteredBitmap.width(); 1482 w = filteredBitmap.width();
1481 h = filteredBitmap.height(); 1483 h = filteredBitmap.height();
1482 x += offset.fX; 1484 x += offset.fX;
1483 y += offset.fY; 1485 y += offset.fY;
1486 } else {
1487 return;
1484 } 1488 }
1485 } 1489 }
1486 1490
1487 GrPaint grPaint; 1491 GrPaint grPaint;
1488 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); 1492 grPaint.addColorTextureEffect(devTex, SkMatrix::I());
1489 1493
1490 if (!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { 1494 if (!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) {
1491 return; 1495 return;
1492 } 1496 }
1493 1497
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 GrTexture* texture, 1767 GrTexture* texture,
1764 bool needClear) 1768 bool needClear)
1765 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { 1769 : SkDevice(make_bitmap(context, texture->asRenderTarget())) {
1766 1770
1767 GrAssert(texture && texture->asRenderTarget()); 1771 GrAssert(texture && texture->asRenderTarget());
1768 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1772 // 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. 1773 // cache. We pass true for the third argument so that it will get unlocked.
1770 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1774 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1771 fNeedClear = needClear; 1775 fNeedClear = needClear;
1772 } 1776 }
OLDNEW
« no previous file with comments | « src/effects/SkGpuBlurUtils.cpp ('k') | src/gpu/effects/GrConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698