| 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/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; | 1320 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; |
| 1321 SkRect paintRect; | 1321 SkRect paintRect; |
| 1322 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); | 1322 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); |
| 1323 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); | 1323 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); |
| 1324 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), | 1324 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), |
| 1325 SkScalarMul(srcRect.fTop, hInv), | 1325 SkScalarMul(srcRect.fTop, hInv), |
| 1326 SkScalarMul(srcRect.fRight, wInv), | 1326 SkScalarMul(srcRect.fRight, wInv), |
| 1327 SkScalarMul(srcRect.fBottom, hInv)); | 1327 SkScalarMul(srcRect.fBottom, hInv)); |
| 1328 | 1328 |
| 1329 SkRect textureDomain = SkRect::MakeEmpty(); | 1329 SkRect textureDomain = SkRect::MakeEmpty(); |
| 1330 SkAutoTUnref<GrEffectRef> effect; | 1330 SkAutoTUnref<GrEffect> effect; |
| 1331 if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) { | 1331 if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) { |
| 1332 // Use a constrained texture domain to avoid color bleeding | 1332 // Use a constrained texture domain to avoid color bleeding |
| 1333 SkScalar left, top, right, bottom; | 1333 SkScalar left, top, right, bottom; |
| 1334 if (srcRect.width() > SK_Scalar1) { | 1334 if (srcRect.width() > SK_Scalar1) { |
| 1335 SkScalar border = SK_ScalarHalf / texture->width(); | 1335 SkScalar border = SK_ScalarHalf / texture->width(); |
| 1336 left = paintRect.left() + border; | 1336 left = paintRect.left() + border; |
| 1337 right = paintRect.right() - border; | 1337 right = paintRect.right() - border; |
| 1338 } else { | 1338 } else { |
| 1339 left = right = SkScalarHalf(paintRect.left() + paintRect.right()); | 1339 left = right = SkScalarHalf(paintRect.left() + paintRect.right()); |
| 1340 } | 1340 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1361 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes))
; | 1361 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes))
; |
| 1362 } else { | 1362 } else { |
| 1363 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param
s)); | 1363 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param
s)); |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring | 1366 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring |
| 1367 // the rest from the SkPaint. | 1367 // the rest from the SkPaint. |
| 1368 GrPaint grPaint; | 1368 GrPaint grPaint; |
| 1369 grPaint.addColorEffect(effect); | 1369 grPaint.addColorEffect(effect); |
| 1370 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); | 1370 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); |
| 1371 GrColor grColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) : | 1371 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : |
| 1372 SkColor2GrColor(paint.getColor()); | 1372 SkColor2GrColor(paint.getColor()); |
| 1373 SkPaint2GrPaintNoShader(this->context(), paint, grColor, false, &grPaint); | 1373 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint)
; |
| 1374 | 1374 |
| 1375 fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL); | 1375 fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL); |
| 1376 } | 1376 } |
| 1377 | 1377 |
| 1378 static bool filter_texture(SkBaseDevice* device, GrContext* context, | 1378 static bool filter_texture(SkBaseDevice* device, GrContext* context, |
| 1379 GrTexture* texture, const SkImageFilter* filter, | 1379 GrTexture* texture, const SkImageFilter* filter, |
| 1380 int w, int h, const SkImageFilter::Context& ctx, | 1380 int w, int h, const SkImageFilter::Context& ctx, |
| 1381 SkBitmap* result, SkIPoint* offset) { | 1381 SkBitmap* result, SkIPoint* offset) { |
| 1382 SkASSERT(filter); | 1382 SkASSERT(filter); |
| 1383 SkDeviceImageFilterProxy proxy(device); | 1383 SkDeviceImageFilterProxy proxy(device); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 playback.draw(canvas, NULL); | 2026 playback.draw(canvas, NULL); |
| 2027 | 2027 |
| 2028 // unlock the layers | 2028 // unlock the layers |
| 2029 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 2029 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
| 2030 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); | 2030 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); |
| 2031 fContext->getLayerCache()->unlock(layer); | 2031 fContext->getLayerCache()->unlock(layer); |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 return true; | 2034 return true; |
| 2035 } | 2035 } |
| OLD | NEW |