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

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

Issue 22209002: Added ctm matrix to GPU path (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Removed dummy matrix Created 7 years, 4 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') | no next file » | 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 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); 1365 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config());
1366 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) { 1366 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) {
1367 return; 1367 return;
1368 } 1368 }
1369 1369
1370 fContext->drawRectToRect(grPaint, dstRect, paintRect, &m); 1370 fContext->drawRectToRect(grPaint, dstRect, paintRect, &m);
1371 } 1371 }
1372 1372
1373 static bool filter_texture(SkDevice* device, GrContext* context, 1373 static bool filter_texture(SkDevice* device, GrContext* context,
1374 GrTexture* texture, SkImageFilter* filter, 1374 GrTexture* texture, SkImageFilter* filter,
1375 int w, int h, SkBitmap* result, SkIPoint* offset) { 1375 int w, int h, const SkMatrix& ctm, SkBitmap* result,
1376 SkIPoint* offset) {
1376 GrAssert(filter); 1377 GrAssert(filter);
1377 SkDeviceImageFilterProxy proxy(device); 1378 SkDeviceImageFilterProxy proxy(device);
1378 1379
1379 if (filter->canFilterImageGPU()) { 1380 if (filter->canFilterImageGPU()) {
1380 // Save the render target and set it to NULL, so we don't accidentally d raw to it in the 1381 // Save the render target and set it to NULL, so we don't accidentally d raw to it in the
1381 // filter. Also set the clip wide open and the matrix to identity. 1382 // filter. Also set the clip wide open and the matrix to identity.
1382 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); 1383 GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
1383 return filter->filterImageGPU(&proxy, wrap_texture(texture), result, off set); 1384 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctm, result , offset);
1384 } else { 1385 } else {
1385 return false; 1386 return false;
1386 } 1387 }
1387 } 1388 }
1388 1389
1389 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, 1390 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
1390 int left, int top, const SkPaint& paint) { 1391 int left, int top, const SkPaint& paint) {
1391 // drawSprite is defined to be in device coords. 1392 // drawSprite is defined to be in device coords.
1392 CHECK_SHOULD_DRAW(draw, true); 1393 CHECK_SHOULD_DRAW(draw, true);
1393 1394
1394 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); 1395 SkAutoLockPixels alp(bitmap, !bitmap.getTexture());
1395 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { 1396 if (!bitmap.getTexture() && !bitmap.readyToDraw()) {
1396 return; 1397 return;
1397 } 1398 }
1398 1399
1399 int w = bitmap.width(); 1400 int w = bitmap.width();
1400 int h = bitmap.height(); 1401 int h = bitmap.height();
1401 1402
1402 GrTexture* texture; 1403 GrTexture* texture;
1403 // draw sprite uses the default texture params 1404 // draw sprite uses the default texture params
1404 SkAutoCachedTexture act(this, bitmap, NULL, &texture); 1405 SkAutoCachedTexture act(this, bitmap, NULL, &texture);
1405 1406
1406 SkImageFilter* filter = paint.getImageFilter(); 1407 SkImageFilter* filter = paint.getImageFilter();
1407 SkIPoint offset = SkIPoint::Make(left, top); 1408 SkIPoint offset = SkIPoint::Make(left, top);
1408 // This bitmap will own the filtered result as a texture. 1409 // This bitmap will own the filtered result as a texture.
1409 SkBitmap filteredBitmap; 1410 SkBitmap filteredBitmap;
1410 1411
1411 if (NULL != filter) { 1412 if (NULL != filter) {
1412 if (filter_texture(this, fContext, texture, filter, w, h, &filteredBitma p, &offset)) { 1413 if (filter_texture(this, fContext, texture, filter, w, h, SkMatrix::I(), &filteredBitmap,
1414 &offset)) {
1413 texture = (GrTexture*) filteredBitmap.getTexture(); 1415 texture = (GrTexture*) filteredBitmap.getTexture();
1414 w = filteredBitmap.width(); 1416 w = filteredBitmap.width();
1415 h = filteredBitmap.height(); 1417 h = filteredBitmap.height();
1416 } else { 1418 } else {
1417 return; 1419 return;
1418 } 1420 }
1419 } 1421 }
1420 1422
1421 GrPaint grPaint; 1423 GrPaint grPaint;
1422 grPaint.addColorTextureEffect(texture, SkMatrix::I()); 1424 grPaint.addColorTextureEffect(texture, SkMatrix::I());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 const SkBitmap& bm = dev->accessBitmap(false); 1489 const SkBitmap& bm = dev->accessBitmap(false);
1488 int w = bm.width(); 1490 int w = bm.width();
1489 int h = bm.height(); 1491 int h = bm.height();
1490 1492
1491 SkImageFilter* filter = paint.getImageFilter(); 1493 SkImageFilter* filter = paint.getImageFilter();
1492 // This bitmap will own the filtered result as a texture. 1494 // This bitmap will own the filtered result as a texture.
1493 SkBitmap filteredBitmap; 1495 SkBitmap filteredBitmap;
1494 1496
1495 if (NULL != filter) { 1497 if (NULL != filter) {
1496 SkIPoint offset = SkIPoint::Make(0, 0); 1498 SkIPoint offset = SkIPoint::Make(0, 0);
1497 if (filter_texture(this, fContext, devTex, filter, w, h, &filteredBitmap , &offset)) { 1499 if (filter_texture(this, fContext, devTex, filter, w, h, SkMatrix::I(), &filteredBitmap,
1500 &offset)) {
1498 devTex = filteredBitmap.getTexture(); 1501 devTex = filteredBitmap.getTexture();
1499 w = filteredBitmap.width(); 1502 w = filteredBitmap.width();
1500 h = filteredBitmap.height(); 1503 h = filteredBitmap.height();
1501 x += offset.fX; 1504 x += offset.fX;
1502 y += offset.fY; 1505 y += offset.fY;
1503 } else { 1506 } else {
1504 return; 1507 return;
1505 } 1508 }
1506 } 1509 }
1507 1510
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 SkAutoLockPixels alp(src, !src.getTexture()); 1543 SkAutoLockPixels alp(src, !src.getTexture());
1541 if (!src.getTexture() && !src.readyToDraw()) { 1544 if (!src.getTexture() && !src.readyToDraw()) {
1542 return false; 1545 return false;
1543 } 1546 }
1544 1547
1545 GrTexture* texture; 1548 GrTexture* texture;
1546 // We assume here that the filter will not attempt to tile the src. Otherwis e, this cache lookup 1549 // We assume here that the filter will not attempt to tile the src. Otherwis e, this cache lookup
1547 // must be pushed upstack. 1550 // must be pushed upstack.
1548 SkAutoCachedTexture act(this, src, NULL, &texture); 1551 SkAutoCachedTexture act(this, src, NULL, &texture);
1549 1552
1550 return filter_texture(this, fContext, texture, filter, src.width(), src.heig ht(), result, offset); 1553 return filter_texture(this, fContext, texture, filter, src.width(), src.heig ht(), ctm, result,
1554 offset);
1551 } 1555 }
1552 1556
1553 /////////////////////////////////////////////////////////////////////////////// 1557 ///////////////////////////////////////////////////////////////////////////////
1554 1558
1555 // must be in SkCanvas::VertexMode order 1559 // must be in SkCanvas::VertexMode order
1556 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1560 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1557 kTriangles_GrPrimitiveType, 1561 kTriangles_GrPrimitiveType,
1558 kTriangleStrip_GrPrimitiveType, 1562 kTriangleStrip_GrPrimitiveType,
1559 kTriangleFan_GrPrimitiveType, 1563 kTriangleFan_GrPrimitiveType,
1560 }; 1564 };
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 GrTexture* texture, 1788 GrTexture* texture,
1785 bool needClear) 1789 bool needClear)
1786 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { 1790 : SkDevice(make_bitmap(context, texture->asRenderTarget())) {
1787 1791
1788 GrAssert(texture && texture->asRenderTarget()); 1792 GrAssert(texture && texture->asRenderTarget());
1789 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1793 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1790 // cache. We pass true for the third argument so that it will get unlocked. 1794 // cache. We pass true for the third argument so that it will get unlocked.
1791 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1795 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1792 fNeedClear = needClear; 1796 fNeedClear = needClear;
1793 } 1797 }
OLDNEW
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698