aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-07 15:20:21 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-07 21:23:30 +0000
commit02bd2950e04952398930ed179bb72e08ad5ed3d3 (patch)
treee7be26df052023b0e3d4504917e923dcccf54b53 /tools
parent88df8d2e5a87df5605b1d5530408cc6f534d8feb (diff)
Make ProxyUtils::MakeTextureProxyFromData use wrapped textures when origin is kBottomLeft
This is to prepare for only supporting kBottomLeft origin for wrapped texture/render targets. Change-Id: Iecb2e463867f746186695893276ebb5dc47a9d90 Reviewed-on: https://skia-review.googlesource.com/112860 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/gpu/ProxyUtils.cpp45
1 files changed, 36 insertions, 9 deletions
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index e02bf5fd26..0102eda9e7 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -6,8 +6,10 @@
*/
#include "ProxyUtils.h"
+#include "GrBackendSurface.h"
#include "GrContextPriv.h"
#include "GrDrawingManager.h"
+#include "GrGpu.h"
#include "GrProxyProvider.h"
namespace sk_gpu_test {
@@ -16,15 +18,40 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, in
GrColorType ct, GrSRGBEncoded srgbEncoded,
GrSurfaceOrigin origin, const void* data,
size_t rowBytes) {
- GrSurfaceDesc desc;
- desc.fConfig = GrColorTypeToPixelConfig(ct, srgbEncoded);
- desc.fWidth = width;
- desc.fHeight = height;
- desc.fFlags = isRT ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- auto proxy = context->contextPriv().proxyProvider()->createProxy(
- desc, origin, SkBackingFit::kExact, SkBudgeted::kYes);
- if (!proxy) {
- return nullptr;
+ auto config = GrColorTypeToPixelConfig(ct, srgbEncoded);
+ sk_sp<GrTextureProxy> proxy;
+ if (kBottomLeft_GrSurfaceOrigin == origin) {
+ // We (soon will) only support using kBottomLeft with wrapped textures.
+ auto backendTex = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
+ nullptr, width, height, config, isRT, GrMipMapped::kNo);
+ if (!backendTex.isValid()) {
+ return nullptr;
+ }
+ // Adopt ownership so our caller doesn't have to worry about deleting the backend texture.
+ if (isRT) {
+ proxy = context->contextPriv().proxyProvider()->wrapRenderableBackendTexture(
+ backendTex, origin, 1, kAdopt_GrWrapOwnership);
+ } else {
+ proxy = context->contextPriv().proxyProvider()->wrapBackendTexture(
+ backendTex, origin, kAdopt_GrWrapOwnership);
+ }
+
+ if (!proxy) {
+ context->contextPriv().getGpu()->deleteTestingOnlyBackendTexture(&backendTex);
+ return nullptr;
+ }
+
+ } else {
+ GrSurfaceDesc desc;
+ desc.fConfig = config;
+ desc.fWidth = width;
+ desc.fHeight = height;
+ desc.fFlags = isRT ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
+ proxy = context->contextPriv().proxyProvider()->createProxy(
+ desc, origin, SkBackingFit::kExact, SkBudgeted::kYes);
+ if (!proxy) {
+ return nullptr;
+ }
}
auto sContext = context->contextPriv().makeWrappedSurfaceContext(proxy, nullptr);
if (!sContext) {