aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGr.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-08 15:32:02 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-08 21:01:50 +0000
commit7619b646881c9a346a3c760d2ab9ab2f3fca0390 (patch)
tree530c5facc0cb8a3876f50c1619efcabfabe33f4d /src/gpu/SkGr.cpp
parent457469c7a0c879b9d8ff8ed9fabe3f3dcab06097 (diff)
Make GrUploadBitmapToTexutreProxy to support lazy proxies
Bug: skia: Change-Id: I876646f104c2ad22d912a269beadd5c0cd9bfded Reviewed-on: https://skia-review.googlesource.com/105723 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/SkGr.cpp')
-rw-r--r--src/gpu/SkGr.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index cf8b3ab864..6cb93bdc2f 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -70,14 +70,28 @@ void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrProxyProvider* proxyProvider,
const SkBitmap& bitmap,
SkColorSpace* dstColorSpace) {
- if (!bitmap.readyToDraw()) {
+ if (!bitmap.peekPixels(nullptr)) {
return nullptr;
}
- SkPixmap pixmap;
- if (!bitmap.peekPixels(&pixmap)) {
+
+ SkDestinationSurfaceColorMode colorMode = dstColorSpace
+ ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
+ : SkDestinationSurfaceColorMode::kLegacy;
+
+ if (!SkImageInfoIsValid(bitmap.info(), colorMode)) {
return nullptr;
}
- return GrUploadPixmapToTextureProxy(proxyProvider, pixmap, SkBudgeted::kYes, dstColorSpace);
+
+ // In non-ddl we will always instantiate right away. Thus we never want to copy the SkBitmap
+ // even if it's mutable. In ddl, if the bitmap is mutable then we must make a copy since the
+ // upload of the data to the gpu can happen at anytime and the bitmap may change by then.
+ SkCopyPixelsMode cpyMode = proxyProvider->mutableBitmapsNeedCopy() ? kIfMutable_SkCopyPixelsMode
+ : kNever_SkCopyPixelsMode;
+ sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(bitmap, cpyMode);
+
+ return proxyProvider->createTextureProxy(std::move(image), kNone_GrSurfaceFlags,
+ kTopLeft_GrSurfaceOrigin, 1, SkBudgeted::kYes,
+ SkBackingFit::kExact);
}
sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrProxyProvider* proxyProvider,