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

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

Issue 112803004: Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated to ToT Created 6 years, 11 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/SkXfermodeImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('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/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 } 1487 }
1488 1488
1489 int w = bitmap.width(); 1489 int w = bitmap.width();
1490 int h = bitmap.height(); 1490 int h = bitmap.height();
1491 1491
1492 GrTexture* texture; 1492 GrTexture* texture;
1493 // draw sprite uses the default texture params 1493 // draw sprite uses the default texture params
1494 SkAutoCachedTexture act(this, bitmap, NULL, &texture); 1494 SkAutoCachedTexture act(this, bitmap, NULL, &texture);
1495 1495
1496 SkImageFilter* filter = paint.getImageFilter(); 1496 SkImageFilter* filter = paint.getImageFilter();
1497 SkIPoint offset = SkIPoint::Make(left, top);
1498 // This bitmap will own the filtered result as a texture. 1497 // This bitmap will own the filtered result as a texture.
1499 SkBitmap filteredBitmap; 1498 SkBitmap filteredBitmap;
1500 1499
1501 if (NULL != filter) { 1500 if (NULL != filter) {
1501 SkIPoint offset = SkIPoint::Make(0, 0);
1502 SkMatrix matrix(*draw.fMatrix); 1502 SkMatrix matrix(*draw.fMatrix);
1503 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); 1503 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
1504 if (filter_texture(this, fContext, texture, filter, w, h, matrix, &filte redBitmap, 1504 if (filter_texture(this, fContext, texture, filter, w, h, matrix, &filte redBitmap,
1505 &offset)) { 1505 &offset)) {
1506 texture = (GrTexture*) filteredBitmap.getTexture(); 1506 texture = (GrTexture*) filteredBitmap.getTexture();
1507 w = filteredBitmap.width(); 1507 w = filteredBitmap.width();
1508 h = filteredBitmap.height(); 1508 h = filteredBitmap.height();
1509 left += offset.x();
1510 top += offset.y();
1509 } else { 1511 } else {
1510 return; 1512 return;
1511 } 1513 }
1512 } 1514 }
1513 1515
1514 GrPaint grPaint; 1516 GrPaint grPaint;
1515 grPaint.addColorTextureEffect(texture, SkMatrix::I()); 1517 grPaint.addColorTextureEffect(texture, SkMatrix::I());
1516 1518
1517 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { 1519 if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) {
1518 return; 1520 return;
1519 } 1521 }
1520 1522
1521 fContext->drawRectToRect(grPaint, 1523 fContext->drawRectToRect(grPaint,
1522 SkRect::MakeXYWH(SkIntToScalar(offset.fX), 1524 SkRect::MakeXYWH(SkIntToScalar(left),
1523 SkIntToScalar(offset.fY), 1525 SkIntToScalar(top),
1524 SkIntToScalar(w), 1526 SkIntToScalar(w),
1525 SkIntToScalar(h)), 1527 SkIntToScalar(h)),
1526 SkRect::MakeXYWH(0, 1528 SkRect::MakeXYWH(0,
1527 0, 1529 0,
1528 SK_Scalar1 * w / texture->width(), 1530 SK_Scalar1 * w / texture->width(),
1529 SK_Scalar1 * h / texture->height() )); 1531 SK_Scalar1 * h / texture->height() ));
1530 } 1532 }
1531 1533
1532 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 1534 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
1533 const SkRect* src, const SkRect& dst, 1535 const SkRect* src, const SkRect& dst,
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 GrTexture* texture, 1919 GrTexture* texture,
1918 bool needClear) 1920 bool needClear)
1919 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1921 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1920 1922
1921 SkASSERT(texture && texture->asRenderTarget()); 1923 SkASSERT(texture && texture->asRenderTarget());
1922 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1924 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1923 // cache. We pass true for the third argument so that it will get unlocked. 1925 // cache. We pass true for the third argument so that it will get unlocked.
1924 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1926 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1925 fNeedClear = needClear; 1927 fNeedClear = needClear;
1926 } 1928 }
OLDNEW
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698