| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #include "SkSpecialImage.h" | 7 #include "SkSpecialImage.h" |
| 8 | 8 |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 return ib->getBitmapDeprecated(result); | 129 return ib->getBitmapDeprecated(result); |
| 130 } | 130 } |
| 131 | 131 |
| 132 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const { | 132 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const { |
| 133 return fProxy; | 133 return fProxy; |
| 134 } | 134 } |
| 135 | 135 |
| 136 /////////////////////////////////////////////////////////////////////////////// | 136 /////////////////////////////////////////////////////////////////////////////// |
| 137 #include "SkImage.h" | 137 #include "SkImage.h" |
| 138 #if SK_SUPPORT_GPU | 138 #if SK_SUPPORT_GPU |
| 139 #include "GrContext.h" |
| 139 #include "SkGrPriv.h" | 140 #include "SkGrPriv.h" |
| 140 #endif | 141 #endif |
| 141 | 142 |
| 142 class SkSpecialImage_Image : public SkSpecialImage_Base { | 143 class SkSpecialImage_Image : public SkSpecialImage_Base { |
| 143 public: | 144 public: |
| 144 SkSpecialImage_Image(SkImageFilter::Proxy* proxy, | 145 SkSpecialImage_Image(SkImageFilter::Proxy* proxy, |
| 145 const SkIRect& subset, | 146 const SkIRect& subset, |
| 146 sk_sp<SkImage> image) | 147 sk_sp<SkImage> image) |
| 147 : INHERITED(proxy, subset, image->uniqueID()) | 148 : INHERITED(proxy, subset, image->uniqueID()) |
| 148 , fImage(image) { | 149 , fImage(image) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 200 } |
| 200 | 201 |
| 201 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 202 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
| 202 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); | 203 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); |
| 203 } | 204 } |
| 204 | 205 |
| 205 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { | 206 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { |
| 206 #if SK_SUPPORT_GPU | 207 #if SK_SUPPORT_GPU |
| 207 GrTexture* texture = as_IB(fImage.get())->peekTexture(); | 208 GrTexture* texture = as_IB(fImage.get())->peekTexture(); |
| 208 if (texture) { | 209 if (texture) { |
| 209 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); | 210 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getCon
text()->caps()); |
| 210 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 211 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 211 | 212 |
| 212 return SkSpecialSurface::MakeRenderTarget(this->proxy(), texture->ge
tContext(), desc); | 213 return SkSpecialSurface::MakeRenderTarget(this->proxy(), texture->ge
tContext(), desc); |
| 213 } | 214 } |
| 214 #endif | 215 #endif |
| 215 return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); | 216 return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); |
| 216 } | 217 } |
| 217 | 218 |
| 218 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { | 219 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
| 219 sk_sp<SkImage> subsetImg(fImage->makeSubset(subset)); | 220 sk_sp<SkImage> subsetImg(fImage->makeSubset(subset)); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 if (!fTexture->readPixels(0, 0, result->width(), result->height(), kSkia
8888_GrPixelConfig, | 424 if (!fTexture->readPixels(0, 0, result->width(), result->height(), kSkia
8888_GrPixelConfig, |
| 424 result->getPixels(), result->rowBytes())) { | 425 result->getPixels(), result->rowBytes())) { |
| 425 return false; | 426 return false; |
| 426 } | 427 } |
| 427 | 428 |
| 428 result->pixelRef()->setImmutable(); | 429 result->pixelRef()->setImmutable(); |
| 429 return true; | 430 return true; |
| 430 } | 431 } |
| 431 | 432 |
| 432 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { | 433 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { |
| 433 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); | 434 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContex
t()->caps()); |
| 434 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 435 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 435 | 436 |
| 436 return SkSpecialSurface::MakeRenderTarget(this->proxy(), fTexture->getCo
ntext(), desc); | 437 return SkSpecialSurface::MakeRenderTarget(this->proxy(), fTexture->getCo
ntext(), desc); |
| 437 } | 438 } |
| 438 | 439 |
| 439 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { | 440 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
| 440 return SkSpecialImage::MakeFromGpu(this->internal_getProxy(), | 441 return SkSpecialImage::MakeFromGpu(this->internal_getProxy(), |
| 441 subset, | 442 subset, |
| 442 this->uniqueID(), | 443 this->uniqueID(), |
| 443 fTexture, | 444 fTexture, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 464 | 465 |
| 465 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, | 466 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, |
| 466 const SkIRect& subset, | 467 const SkIRect& subset, |
| 467 uint32_t uniqueID, | 468 uint32_t uniqueID, |
| 468 GrTexture* tex, | 469 GrTexture* tex, |
| 469 SkAlphaType at) { | 470 SkAlphaType at) { |
| 470 return nullptr; | 471 return nullptr; |
| 471 } | 472 } |
| 472 | 473 |
| 473 #endif | 474 #endif |
| OLD | NEW |