GrSurfaceContext::read/writePixels takes GrPixmap
Change readPixels contract to allow unknown->unknown AT reads, but
fail if one side is unknown and the other isn't (and update GPU read
pixels test accordingly).
Also, ProxyUtils::MakeTextureProxyViewFromData takes GrPixmap.
Bug: skia:8862
Change-Id: I771c154833408e666f860413c1a711714696326d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347196
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 9a21cb8..7c65774 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -5,54 +5,57 @@
* found in the LICENSE file.
*/
+#include "tools/gpu/ProxyUtils.h"
+
#include "include/core/SkColor.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrDrawingManager.h"
#include "src/gpu/GrGpu.h"
-#include "src/gpu/GrImageInfo.h"
+#include "src/gpu/GrPixmap.h"
#include "src/gpu/GrProgramInfo.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
-#include "tools/gpu/ProxyUtils.h"
namespace sk_gpu_test {
GrSurfaceProxyView MakeTextureProxyViewFromData(GrDirectContext* dContext,
GrRenderable renderable,
GrSurfaceOrigin origin,
- const GrImageInfo& imageInfo,
- const void* data,
- size_t rowBytes) {
+ GrPixmap pixmap) {
if (dContext->abandoned()) {
return {};
}
const GrCaps* caps = dContext->priv().caps();
- const GrBackendFormat format = caps->getDefaultBackendFormat(imageInfo.colorType(), renderable);
+ const GrBackendFormat format = caps->getDefaultBackendFormat(pixmap.colorType(), renderable);
if (!format.isValid()) {
return {};
}
- GrSwizzle swizzle = caps->getReadSwizzle(format, imageInfo.colorType());
+ GrSwizzle swizzle = caps->getReadSwizzle(format, pixmap.colorType());
sk_sp<GrTextureProxy> proxy;
- proxy = dContext->priv().proxyProvider()->createProxy(format, imageInfo.dimensions(),
- renderable, 1, GrMipmapped::kNo,
- SkBackingFit::kExact, SkBudgeted::kYes,
+ proxy = dContext->priv().proxyProvider()->createProxy(format,
+ pixmap.dimensions(),
+ renderable,
+ /*sample count*/ 1,
+ GrMipmapped::kNo,
+ SkBackingFit::kExact,
+ SkBudgeted::kYes,
GrProtected::kNo);
if (!proxy) {
return {};
}
GrSurfaceProxyView view(proxy, origin, swizzle);
- auto sContext = GrSurfaceContext::Make(dContext, std::move(view), imageInfo.colorInfo());
+ auto sContext = GrSurfaceContext::Make(dContext, std::move(view), pixmap.colorInfo());
if (!sContext) {
return {};
}
- if (!sContext->writePixels(dContext, imageInfo, data, rowBytes, {0, 0})) {
+ if (!sContext->writePixels(dContext, pixmap, {0, 0})) {
return {};
}
return sContext->readSurfaceView();