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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 } | 1233 } |
1234 } | 1234 } |
1235 | 1235 |
1236 SkIRect srcRect = SkIRect::MakeXYWH(bitmap.pixelRefOrigin().fX, | 1236 SkIRect srcRect = SkIRect::MakeXYWH(bitmap.pixelRefOrigin().fX, |
1237 bitmap.pixelRefOrigin().fY, | 1237 bitmap.pixelRefOrigin().fY, |
1238 bitmap.width(), | 1238 bitmap.width(), |
1239 bitmap.height()); | 1239 bitmap.height()); |
1240 | 1240 |
1241 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::MakeFromGpu(srcRect, | 1241 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::MakeFromGpu(srcRect, |
1242 bitmap.getGeneratio
nID(), | 1242 bitmap.getGeneratio
nID(), |
1243 std::move(texture),
| 1243 std::move(texture), |
| 1244 sk_ref_sp(bitmap.co
lorSpace()), |
1244 &this->surfaceProps
())); | 1245 &this->surfaceProps
())); |
1245 | 1246 |
1246 this->drawSpecial(draw, srcImg.get(), left, top, paint); | 1247 this->drawSpecial(draw, srcImg.get(), left, top, paint); |
1247 } | 1248 } |
1248 | 1249 |
1249 | 1250 |
1250 void SkGpuDevice::drawSpecial(const SkDraw& draw, | 1251 void SkGpuDevice::drawSpecial(const SkDraw& draw, |
1251 SkSpecialImage* special1, | 1252 SkSpecialImage* special1, |
1252 int left, int top, | 1253 int left, int top, |
1253 const SkPaint& paint) { | 1254 const SkPaint& paint) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 | 1400 |
1400 GrTexture* texture; | 1401 GrTexture* texture; |
1401 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), | 1402 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), |
1402 SkSourceGammaTreatment::kRespect, &texture); | 1403 SkSourceGammaTreatment::kRespect, &texture); |
1403 if (!texture) { | 1404 if (!texture) { |
1404 return nullptr; | 1405 return nullptr; |
1405 } | 1406 } |
1406 | 1407 |
1407 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), | 1408 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), |
1408 bitmap.getGenerationID(), | 1409 bitmap.getGenerationID(), |
1409 sk_ref_sp(texture), | 1410 sk_ref_sp(texture), |
| 1411 sk_ref_sp(bitmap.colorSpace()), |
1410 &this->surfaceProps()); | 1412 &this->surfaceProps()); |
1411 } | 1413 } |
1412 | 1414 |
1413 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { | 1415 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { |
1414 SkPixmap pm; | 1416 SkPixmap pm; |
1415 if (image->isTextureBacked()) { | 1417 if (image->isTextureBacked()) { |
1416 GrTexture* texture = as_IB(image)->peekTexture(); | 1418 GrTexture* texture = as_IB(image)->peekTexture(); |
1417 | 1419 |
1418 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image
->height()), | 1420 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image
->height()), |
1419 image->uniqueID(), | 1421 image->uniqueID(), |
1420 sk_ref_sp(texture), | 1422 sk_ref_sp(texture), |
| 1423 sk_ref_sp(as_IB(image)->onImageInfo()
.colorSpace()), |
1421 &this->surfaceProps()); | 1424 &this->surfaceProps()); |
1422 } else if (image->peekPixels(&pm)) { | 1425 } else if (image->peekPixels(&pm)) { |
1423 SkBitmap bm; | 1426 SkBitmap bm; |
1424 | 1427 |
1425 bm.installPixels(pm); | 1428 bm.installPixels(pm); |
1426 return this->makeSpecial(bm); | 1429 return this->makeSpecial(bm); |
1427 } else { | 1430 } else { |
1428 return nullptr; | 1431 return nullptr; |
1429 } | 1432 } |
1430 } | 1433 } |
(...skipping 13 matching lines...) Expand all Loading... |
1444 if (!fContext->copySurface(texture.get(), this->accessDrawContext()->acc
essRenderTarget())){ | 1447 if (!fContext->copySurface(texture.get(), this->accessDrawContext()->acc
essRenderTarget())){ |
1445 return nullptr; | 1448 return nullptr; |
1446 } | 1449 } |
1447 } | 1450 } |
1448 | 1451 |
1449 const SkImageInfo ii = this->imageInfo(); | 1452 const SkImageInfo ii = this->imageInfo(); |
1450 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); | 1453 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); |
1451 | 1454 |
1452 return SkSpecialImage::MakeFromGpu(srcRect, | 1455 return SkSpecialImage::MakeFromGpu(srcRect, |
1453 kNeedNewImageUniqueID_SpecialImage, | 1456 kNeedNewImageUniqueID_SpecialImage, |
1454 std::move(texture), | 1457 std::move(texture), |
| 1458 sk_ref_sp(ii.colorSpace()), |
1455 &this->surfaceProps()); | 1459 &this->surfaceProps()); |
1456 } | 1460 } |
1457 | 1461 |
1458 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, | 1462 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
1459 int left, int top, const SkPaint& paint) { | 1463 int left, int top, const SkPaint& paint) { |
1460 SkASSERT(!paint.getImageFilter()); | 1464 SkASSERT(!paint.getImageFilter()); |
1461 | 1465 |
1462 ASSERT_SINGLE_OWNER | 1466 ASSERT_SINGLE_OWNER |
1463 // clear of the source device must occur before CHECK_SHOULD_DRAW | 1467 // clear of the source device must occur before CHECK_SHOULD_DRAW |
1464 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); | 1468 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 } | 1895 } |
1892 | 1896 |
1893 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1897 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1894 ASSERT_SINGLE_OWNER | 1898 ASSERT_SINGLE_OWNER |
1895 // We always return a transient cache, so it is freed after each | 1899 // We always return a transient cache, so it is freed after each |
1896 // filter traversal. | 1900 // filter traversal. |
1897 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1901 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1898 } | 1902 } |
1899 | 1903 |
1900 #endif | 1904 #endif |
OLD | NEW |