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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 243 |
244 SkMatrix matrix = *draw.fMatrix; | 244 SkMatrix matrix = *draw.fMatrix; |
245 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 245 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
246 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-left, -top); | 246 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-left, -top); |
247 SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); | 247 SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); |
248 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 248 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
249 | 249 |
250 return filter->filterImage(srcImg, ctx, offset); | 250 return filter->filterImage(srcImg, ctx, offset); |
251 } | 251 } |
252 | 252 |
253 | |
254 void SkGpuDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitma
p, | |
255 int left, int top, const SkPaint& paint)
{ | |
256 ASSERT_SINGLE_OWNER | |
257 CHECK_SHOULD_DRAW(draw); | |
258 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSpriteWithFilter", fConte
xt); | |
259 | |
260 SkASSERT(paint.getImageFilter()); | |
261 this->drawSprite(draw, bitmap, left, top, paint); | |
262 } | |
263 | |
264 /////////////////////////////////////////////////////////////////////////////// | 253 /////////////////////////////////////////////////////////////////////////////// |
265 | 254 |
266 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, | 255 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, |
267 int x, int y) { | 256 int x, int y) { |
268 ASSERT_SINGLE_OWNER | 257 ASSERT_SINGLE_OWNER |
269 | 258 |
270 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels | 259 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
271 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps())
; | 260 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps())
; |
272 if (kUnknown_GrPixelConfig == config) { | 261 if (kUnknown_GrPixelConfig == config) { |
273 return false; | 262 return false; |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); | 1450 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); |
1462 | 1451 |
1463 return SkSpecialImage::MakeFromGpu(srcRect, | 1452 return SkSpecialImage::MakeFromGpu(srcRect, |
1464 kNeedNewImageUniqueID_SpecialImage, | 1453 kNeedNewImageUniqueID_SpecialImage, |
1465 std::move(texture), | 1454 std::move(texture), |
1466 &this->surfaceProps()); | 1455 &this->surfaceProps()); |
1467 } | 1456 } |
1468 | 1457 |
1469 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, | 1458 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
1470 int left, int top, const SkPaint& paint) { | 1459 int left, int top, const SkPaint& paint) { |
| 1460 SkASSERT(!paint.getImageFilter()); |
| 1461 |
1471 ASSERT_SINGLE_OWNER | 1462 ASSERT_SINGLE_OWNER |
1472 // clear of the source device must occur before CHECK_SHOULD_DRAW | 1463 // clear of the source device must occur before CHECK_SHOULD_DRAW |
1473 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); | 1464 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); |
1474 | 1465 |
1475 // drawDevice is defined to be in device coords. | 1466 // drawDevice is defined to be in device coords. |
1476 CHECK_SHOULD_DRAW(draw); | 1467 CHECK_SHOULD_DRAW(draw); |
1477 | 1468 |
1478 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); | 1469 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); |
1479 sk_sp<SkSpecialImage> srcImg(dev->snapSpecial()); | 1470 sk_sp<SkSpecialImage> srcImg(dev->snapSpecial()); |
1480 if (!srcImg) { | 1471 if (!srcImg) { |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 } | 1891 } |
1901 | 1892 |
1902 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1893 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1903 ASSERT_SINGLE_OWNER | 1894 ASSERT_SINGLE_OWNER |
1904 // We always return a transient cache, so it is freed after each | 1895 // We always return a transient cache, so it is freed after each |
1905 // filter traversal. | 1896 // filter traversal. |
1906 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1897 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1907 } | 1898 } |
1908 | 1899 |
1909 #endif | 1900 #endif |
OLD | NEW |