| 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 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 if (!texture) { | 1419 if (!texture) { |
| 1420 return nullptr; | 1420 return nullptr; |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), | 1423 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), |
| 1424 bitmap.getGenerationID(), | 1424 bitmap.getGenerationID(), |
| 1425 sk_ref_sp(texture), | 1425 sk_ref_sp(texture), |
| 1426 &this->surfaceProps()); | 1426 &this->surfaceProps()); |
| 1427 } | 1427 } |
| 1428 | 1428 |
| 1429 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(SkImage* image) { | 1429 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { |
| 1430 SkPixmap pm; | 1430 SkPixmap pm; |
| 1431 if (image->isTextureBacked()) { | 1431 if (image->isTextureBacked()) { |
| 1432 GrTexture* texture = as_IB(image)->peekTexture(); | 1432 GrTexture* texture = as_IB(image)->peekTexture(); |
| 1433 | 1433 |
| 1434 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image
->height()), | 1434 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image
->height()), |
| 1435 image->uniqueID(), | 1435 image->uniqueID(), |
| 1436 sk_ref_sp(texture), | 1436 sk_ref_sp(texture), |
| 1437 &this->surfaceProps()); | 1437 &this->surfaceProps()); |
| 1438 } else if (image->peekPixels(&pm)) { | 1438 } else if (image->peekPixels(&pm)) { |
| 1439 SkBitmap bm; | 1439 SkBitmap bm; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1450 if (!texture) { | 1450 if (!texture) { |
| 1451 // When the device doesn't have a texture, we create a temporary texture
. | 1451 // When the device doesn't have a texture, we create a temporary texture
. |
| 1452 // TODO: we should actually only copy the portion of the source needed t
o apply the image | 1452 // TODO: we should actually only copy the portion of the source needed t
o apply the image |
| 1453 // filter | 1453 // filter |
| 1454 texture.reset(fContext->textureProvider()->createTexture(this->accessDra
wContext()->desc(), | 1454 texture.reset(fContext->textureProvider()->createTexture(this->accessDra
wContext()->desc(), |
| 1455 SkBudgeted::kYe
s)); | 1455 SkBudgeted::kYe
s)); |
| 1456 if (!texture) { | 1456 if (!texture) { |
| 1457 return nullptr; | 1457 return nullptr; |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 if (!fContext->copySurface(this->accessDrawContext()->accessRenderTarget
(), | 1460 if (!fContext->copySurface(texture.get(), this->accessDrawContext()->acc
essRenderTarget())){ |
| 1461 texture.get())) { | |
| 1462 return nullptr; | 1461 return nullptr; |
| 1463 } | 1462 } |
| 1464 } | 1463 } |
| 1465 | 1464 |
| 1466 const SkImageInfo ii = this->imageInfo(); | 1465 const SkImageInfo ii = this->imageInfo(); |
| 1467 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); | 1466 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); |
| 1468 | 1467 |
| 1469 return SkSpecialImage::MakeFromGpu(srcRect, | 1468 return SkSpecialImage::MakeFromGpu(srcRect, |
| 1470 kNeedNewImageUniqueID_SpecialImage, | 1469 kNeedNewImageUniqueID_SpecialImage, |
| 1471 std::move(texture), | 1470 std::move(texture), |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 } | 1905 } |
| 1907 | 1906 |
| 1908 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1907 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
| 1909 ASSERT_SINGLE_OWNER | 1908 ASSERT_SINGLE_OWNER |
| 1910 // We always return a transient cache, so it is freed after each | 1909 // We always return a transient cache, so it is freed after each |
| 1911 // filter traversal. | 1910 // filter traversal. |
| 1912 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1911 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
| 1913 } | 1912 } |
| 1914 | 1913 |
| 1915 #endif | 1914 #endif |
| OLD | NEW |