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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 return nullptr; | 1444 return nullptr; |
1445 } | 1445 } |
1446 } | 1446 } |
1447 | 1447 |
1448 sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() { | 1448 sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() { |
1449 sk_sp<GrTexture> texture(this->accessDrawContext()->asTexture()); | 1449 sk_sp<GrTexture> texture(this->accessDrawContext()->asTexture()); |
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 const GrSurfaceDesc& desc = this->accessDrawContext()->desc(); |
1455 SkBudgeted::kYe
s)); | |
1456 if (!texture) { | |
1457 return nullptr; | |
1458 } | |
1459 | 1455 |
1460 if (!fContext->copySurface(this->accessDrawContext()->accessRenderTarget
(), | 1456 sk_sp<GrDrawContext> dc(fContext->newDrawContext(SkBackingFit::kApprox, |
1461 texture.get())) { | 1457 desc.fWidth, desc.fHeig
ht, |
1462 return nullptr; | 1458 desc.fConfig, |
1463 } | 1459 desc.fSampleCnt, |
| 1460 kDefault_GrSurfaceOrigi
n, |
| 1461 &this->surfaceProps()))
; |
| 1462 |
| 1463 dc->copySurface(this->accessDrawContext()->accessRenderTarget(), |
| 1464 SkIRect::MakeWH(desc.fWidth, desc.fHeight), |
| 1465 SkIPoint::Make(0, 0)); |
| 1466 |
| 1467 texture = dc->asTexture(); |
1464 } | 1468 } |
1465 | 1469 |
1466 const SkImageInfo ii = this->imageInfo(); | 1470 const SkImageInfo ii = this->imageInfo(); |
1467 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); | 1471 const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height()); |
1468 | 1472 |
1469 return SkSpecialImage::MakeFromGpu(srcRect, | 1473 return SkSpecialImage::MakeFromGpu(srcRect, |
1470 kNeedNewImageUniqueID_SpecialImage, | 1474 kNeedNewImageUniqueID_SpecialImage, |
1471 std::move(texture), | 1475 std::move(texture), |
1472 &this->surfaceProps()); | 1476 &this->surfaceProps()); |
1473 } | 1477 } |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 } | 1910 } |
1907 | 1911 |
1908 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1912 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1909 ASSERT_SINGLE_OWNER | 1913 ASSERT_SINGLE_OWNER |
1910 // We always return a transient cache, so it is freed after each | 1914 // We always return a transient cache, so it is freed after each |
1911 // filter traversal. | 1915 // filter traversal. |
1912 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1916 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1913 } | 1917 } |
1914 | 1918 |
1915 #endif | 1919 #endif |
OLD | NEW |