Remove create function in proxyProvider that takes a raster SkImage.
Instead in proxyProvider we just have a create a bitmap call which
does no special fallback or logic. All the callers now go through
GrBitmapTextureMaker which handles and special fallbacks or caching
support that we need.
Change-Id: I71bb896cc78f64f9d6d54b54af2490d48e0f5af5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266842
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 178554a..4cb2fe9 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -14,6 +14,7 @@
#include "src/core/SkCachedData.h"
#include "src/core/SkResourceCache.h"
#include "src/core/SkYUVPlanesCache.h"
+#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrColorSpaceXform.h"
@@ -97,7 +98,7 @@
return data;
}
-void GrYUVProvider::YUVGen_DataReleaseProc(const void*, void* data) {
+void GrYUVProvider::YUVGen_DataReleaseProc(void*, void* data) {
SkCachedData* cachedData = static_cast<SkCachedData*>(data);
SkASSERT(cachedData);
cachedData->unref();
@@ -137,21 +138,23 @@
? SkBackingFit::kExact : SkBackingFit::kApprox;
SkImageInfo imageInfo = SkImageInfo::MakeA8(componentWidth, componentHeight);
- SkPixmap pixmap(imageInfo, planes[i], yuvSizeInfo.fWidthBytes[i]);
SkCachedData* dataStoragePtr = dataStorage.get();
- // We grab a ref to cached yuv data. When the SkImage we create below goes away it will call
- // the YUVGen_DataReleaseProc which will release this ref.
+ // We grab a ref to cached yuv data. When the SkBitmap we create below goes away it will
+ // call the YUVGen_DataReleaseProc which will release this ref.
// DDL TODO: Currently we end up creating a lazy proxy that will hold onto a ref to the
// SkImage in its lambda. This means that we'll keep the ref on the YUV data around for the
// life time of the proxy and not just upload. For non-DDL draws we should look into
// releasing this SkImage after uploads (by deleting the lambda after instantiation).
dataStoragePtr->ref();
- sk_sp<SkImage> yuvImage = SkImage::MakeFromRaster(pixmap, YUVGen_DataReleaseProc,
- dataStoragePtr);
+ SkBitmap bitmap;
+ SkAssertResult(bitmap.installPixels(imageInfo, const_cast<void*>(planes[i]),
+ yuvSizeInfo.fWidthBytes[i],
+ YUVGen_DataReleaseProc, dataStoragePtr));
+ bitmap.setImmutable();
- auto proxyProvider = ctx->priv().proxyProvider();
- yuvTextureProxies[i] =
- proxyProvider->createTextureProxy(yuvImage, 1, SkBudgeted::kYes, fit);
+ GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
+ std::tie(yuvTextureProxies[i], std::ignore) = maker.refTextureProxy(GrMipMapped::kNo);
+
if (!yuvTextureProxies[i]) {
return nullptr;
}