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 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1249 } | 1249 } |
1250 } | 1250 } |
1251 | 1251 |
1252 SkIRect srcRect = SkIRect::MakeXYWH(bitmap.pixelRefOrigin().fX, | 1252 SkIRect srcRect = SkIRect::MakeXYWH(bitmap.pixelRefOrigin().fX, |
1253 bitmap.pixelRefOrigin().fY, | 1253 bitmap.pixelRefOrigin().fY, |
1254 bitmap.width(), | 1254 bitmap.width(), |
1255 bitmap.height()); | 1255 bitmap.height()); |
1256 | 1256 |
1257 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::MakeFromGpu(srcRect, | 1257 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::MakeFromGpu(srcRect, |
1258 bitmap.getGeneratio nID(), | 1258 bitmap.getGeneratio nID(), |
1259 std::move(texture), | 1259 std::move(texture), |
1260 sk_ref_sp(bitmap.co lorSpace()), | |
1260 &this->surfaceProps ())); | 1261 &this->surfaceProps ())); |
1261 | 1262 |
1262 this->drawSpecial(draw, srcImg.get(), left, top, paint); | 1263 this->drawSpecial(draw, srcImg.get(), left, top, paint); |
1263 } | 1264 } |
1264 | 1265 |
1265 | 1266 |
1266 void SkGpuDevice::drawSpecial(const SkDraw& draw, | 1267 void SkGpuDevice::drawSpecial(const SkDraw& draw, |
1267 SkSpecialImage* special1, | 1268 SkSpecialImage* special1, |
1268 int left, int top, | 1269 int left, int top, |
1269 const SkPaint& paint) { | 1270 const SkPaint& paint) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1415 | 1416 |
1416 GrTexture* texture; | 1417 GrTexture* texture; |
1417 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), | 1418 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), |
1418 SkSourceGammaTreatment::kRespect, &texture); | 1419 SkSourceGammaTreatment::kRespect, &texture); |
1419 if (!texture) { | 1420 if (!texture) { |
1420 return nullptr; | 1421 return nullptr; |
1421 } | 1422 } |
1422 | 1423 |
1423 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), | 1424 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), |
1424 bitmap.getGenerationID(), | 1425 bitmap.getGenerationID(), |
1425 sk_ref_sp(texture), | 1426 sk_ref_sp(texture), |
1427 sk_ref_sp(bitmap.colorSpace()), | |
1426 &this->surfaceProps()); | 1428 &this->surfaceProps()); |
1427 } | 1429 } |
1428 | 1430 |
1429 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { | 1431 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { |
1430 SkPixmap pm; | 1432 SkPixmap pm; |
1431 if (image->isTextureBacked()) { | 1433 if (image->isTextureBacked()) { |
1432 GrTexture* texture = as_IB(image)->peekTexture(); | 1434 GrTexture* texture = as_IB(image)->peekTexture(); |
1433 | 1435 |
1434 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image ->height()), | 1436 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image ->height()), |
1435 image->uniqueID(), | 1437 image->uniqueID(), |
1436 sk_ref_sp(texture), | 1438 sk_ref_sp(texture), |
1439 sk_ref_sp(as_IB(image)->onImageInfo() .colorSpace()), | |
1437 &this->surfaceProps()); | 1440 &this->surfaceProps()); |
1438 } else if (image->peekPixels(&pm)) { | 1441 } else if (image->peekPixels(&pm)) { |
1439 SkBitmap bm; | 1442 SkBitmap bm; |
1440 | 1443 |
1441 bm.installPixels(pm); | 1444 bm.installPixels(pm); |
1442 return this->makeSpecial(bm); | 1445 return this->makeSpecial(bm); |
1443 } else { | 1446 } else { |
1444 return nullptr; | 1447 return nullptr; |
1445 } | 1448 } |
1446 } | 1449 } |
(...skipping 13 matching lines...) Expand all Loading... | |
1460 if (!fContext->copySurface(texture.get(), this->accessDrawContext()->acc essRenderTarget())){ | 1463 if (!fContext->copySurface(texture.get(), this->accessDrawContext()->acc essRenderTarget())){ |
1461 return nullptr; | 1464 return nullptr; |
1462 } | 1465 } |
1463 } | 1466 } |
1464 | 1467 |
1465 const SkImageInfo ii = this->imageInfo(); | 1468 const SkImageInfo ii = this->imageInfo(); |
1466 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); | 1469 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); |
1467 | 1470 |
1468 return SkSpecialImage::MakeFromGpu(srcRect, | 1471 return SkSpecialImage::MakeFromGpu(srcRect, |
1469 kNeedNewImageUniqueID_SpecialImage, | 1472 kNeedNewImageUniqueID_SpecialImage, |
1470 std::move(texture), | 1473 std::move(texture), |
1474 sk_ref_sp(ii.colorSpace()), | |
Brian Osman
2016/07/20 19:16:01
This is still questionable, because the device's i
| |
1471 &this->surfaceProps()); | 1475 &this->surfaceProps()); |
1472 } | 1476 } |
1473 | 1477 |
1474 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, | 1478 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
1475 int left, int top, const SkPaint& paint) { | 1479 int left, int top, const SkPaint& paint) { |
1476 ASSERT_SINGLE_OWNER | 1480 ASSERT_SINGLE_OWNER |
1477 // clear of the source device must occur before CHECK_SHOULD_DRAW | 1481 // clear of the source device must occur before CHECK_SHOULD_DRAW |
1478 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); | 1482 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); |
1479 | 1483 |
1480 // drawDevice is defined to be in device coords. | 1484 // drawDevice is defined to be in device coords. |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1905 } | 1909 } |
1906 | 1910 |
1907 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1911 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1908 ASSERT_SINGLE_OWNER | 1912 ASSERT_SINGLE_OWNER |
1909 // We always return a transient cache, so it is freed after each | 1913 // We always return a transient cache, so it is freed after each |
1910 // filter traversal. | 1914 // filter traversal. |
1911 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1915 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1912 } | 1916 } |
1913 | 1917 |
1914 #endif | 1918 #endif |
OLD | NEW |