| 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 "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 | 1377 |
| 1378 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { | 1378 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { |
| 1379 return; | 1379 return; |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { | 1382 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { |
| 1383 // We don't have local coords in this case and have previously set the t
ransform | 1383 // We don't have local coords in this case and have previously set the t
ransform |
| 1384 // matrices directly on the texture processor. | 1384 // matrices directly on the texture processor. |
| 1385 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); | 1385 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); |
| 1386 } else { | 1386 } else { |
| 1387 fDrawContext->drawNonAARectToRect(fClip, grPaint, viewMatrix, dstRect, p
aintRect); | 1387 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); |
| 1388 } | 1388 } |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, | 1391 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
| 1392 int width, int height, | 1392 int width, int height, |
| 1393 const SkImageFilter* filter, | 1393 const SkImageFilter* filter, |
| 1394 const SkImageFilter::Context& ctx, | 1394 const SkImageFilter::Context& ctx, |
| 1395 SkBitmap* result, SkIPoint* offset) { | 1395 SkBitmap* result, SkIPoint* offset) { |
| 1396 SkASSERT(filter); | 1396 SkASSERT(filter); |
| 1397 | 1397 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 GrSimpleTextureEffect::Create(texture, SkMatrix::I())); | 1459 GrSimpleTextureEffect::Create(texture, SkMatrix::I())); |
| 1460 if (alphaOnly) { | 1460 if (alphaOnly) { |
| 1461 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); | 1461 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| 1462 } else { | 1462 } else { |
| 1463 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); | 1463 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| 1464 } | 1464 } |
| 1465 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { | 1465 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { |
| 1466 return; | 1466 return; |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 fDrawContext->drawNonAARectToRect(fClip, | 1469 fDrawContext->fillRectToRect(fClip, |
| 1470 grPaint, | 1470 grPaint, |
| 1471 SkMatrix::I(), | 1471 SkMatrix::I(), |
| 1472 SkRect::MakeXYWH(SkIntToScalar(left), | 1472 SkRect::MakeXYWH(SkIntToScalar(left), |
| 1473 SkIntToScalar(top), | 1473 SkIntToScalar(top), |
| 1474 SkIntToScalar(w), | 1474 SkIntToScalar(w), |
| 1475 SkIntToScalar(h)), | 1475 SkIntToScalar(h)), |
| 1476 SkRect::MakeXYWH(0, | 1476 SkRect::MakeXYWH(0, |
| 1477 0, | 1477 0, |
| 1478 SK_Scalar1 * w / texture-
>width(), | 1478 SK_Scalar1 * w / texture->widt
h(), |
| 1479 SK_Scalar1 * h / texture-
>height())); | 1479 SK_Scalar1 * h / texture->heig
ht())); |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap, | 1482 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap, |
| 1483 const SkRect* src, const SkRect& dst, | 1483 const SkRect* src, const SkRect& dst, |
| 1484 const SkPaint& paint, SkCanvas::SrcRectConstrai
nt constraint) { | 1484 const SkPaint& paint, SkCanvas::SrcRectConstrai
nt constraint) { |
| 1485 SkMatrix matrix; | 1485 SkMatrix matrix; |
| 1486 SkRect bitmapBounds, tmpSrc; | 1486 SkRect bitmapBounds, tmpSrc; |
| 1487 | 1487 |
| 1488 bitmapBounds.set(0, 0, | 1488 bitmapBounds.set(0, 0, |
| 1489 SkIntToScalar(bitmap.width()), | 1489 SkIntToScalar(bitmap.width()), |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), | 1589 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), |
| 1590 SkIntToScalar(y), | 1590 SkIntToScalar(y), |
| 1591 SkIntToScalar(w), | 1591 SkIntToScalar(w), |
| 1592 SkIntToScalar(h)); | 1592 SkIntToScalar(h)); |
| 1593 | 1593 |
| 1594 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate | 1594 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate |
| 1595 // scratch texture). | 1595 // scratch texture). |
| 1596 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), | 1596 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), |
| 1597 SK_Scalar1 * h / devTex->height()); | 1597 SK_Scalar1 * h / devTex->height()); |
| 1598 | 1598 |
| 1599 fDrawContext->drawNonAARectToRect(fClip, grPaint, SkMatrix::I(), dstRect, sr
cRect); | 1599 fDrawContext->fillRectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect
); |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { | 1602 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { |
| 1603 return filter->canFilterImageGPU(); | 1603 return filter->canFilterImageGPU(); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, | 1606 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, |
| 1607 const SkImageFilter::Context& ctx, | 1607 const SkImageFilter::Context& ctx, |
| 1608 SkBitmap* result, SkIPoint* offset) { | 1608 SkBitmap* result, SkIPoint* offset) { |
| 1609 // want explicitly our impl, so guard against a subclass of us overriding it | 1609 // want explicitly our impl, so guard against a subclass of us overriding it |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2025 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 2026 } | 2026 } |
| 2027 | 2027 |
| 2028 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2028 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 2029 // We always return a transient cache, so it is freed after each | 2029 // We always return a transient cache, so it is freed after each |
| 2030 // filter traversal. | 2030 // filter traversal. |
| 2031 return SkGpuDevice::NewImageFilterCache(); | 2031 return SkGpuDevice::NewImageFilterCache(); |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 #endif | 2034 #endif |
| OLD | NEW |