aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-03 22:43:43 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-05 18:50:25 +0000
commit2a4f983c94e4f749fe24b08bc8b5ae7cc8550d1d (patch)
treee89d794eeffacf09124be0cee8bfc70001be2856 /gm
parent1a8d762a18d6f6494408a3a5e06a80097f8b85f7 (diff)
Remove GrSurfaceOrigin from GrSurfaceDesc.
This field has no interpretation at the GrTexture/GrGpu as the orientation is handled at the GrSurfaceProxy level. This change requires GrGpu to accept a GrSurfaceOrigin when creating a texture with initial data. The origin refers to the texel data to be uploaded. Longer term the plan is to remove this and require the data to be kTopLeft. Additionally, kBottomLeft will only be allowed for wrapped texture/RTs as this evolves. Change-Id: I7d25b0199aafd9bf3b74c39b2cae451acadcd772 Reviewed-on: https://skia-review.googlesource.com/111806 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/flippity.cpp8
-rw-r--r--gm/image_pict.cpp6
-rw-r--r--gm/texdata.cpp144
-rw-r--r--gm/texturedomaineffect.cpp7
-rw-r--r--gm/yuvtorgbeffect.cpp55
5 files changed, 29 insertions, 191 deletions
diff --git a/gm/flippity.cpp b/gm/flippity.cpp
index bd9930c9df..554b4d151b 100644
--- a/gm/flippity.cpp
+++ b/gm/flippity.cpp
@@ -111,15 +111,11 @@ static sk_sp<SkImage> make_reference_image(GrContext* context,
}
GrSurfaceDesc desc;
- desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = kImageSize;
desc.fHeight = kImageSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- if (bottomLeftOrigin) {
- // Note that Ganesh will flip the data when it is uploaded
- desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
- }
+ auto origin = bottomLeftOrigin ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
if (kN32_SkColorType == kBGRA_8888_SkColorType) {
// We're playing a game here and uploading N32 data into an RGB dest. We might have
@@ -132,7 +128,7 @@ static sk_sp<SkImage> make_reference_image(GrContext* context,
}
}
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, origin, SkBudgeted::kYes,
bm.getPixels(), bm.rowBytes());
if (!proxy) {
return nullptr;
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index bf1c651de6..f244fe8f35 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -181,7 +181,6 @@ protected:
// need to copy the subset into a new texture
GrSurfaceDesc desc;
- desc.fOrigin = fProxy->origin();
desc.fWidth = info.width();
desc.fHeight = info.height();
desc.fConfig = fProxy->config();
@@ -189,10 +188,7 @@ protected:
GrMipMapped mipMapped = willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo;
sk_sp<GrSurfaceContext> dstContext(fCtx->contextPriv().makeDeferredSurfaceContext(
- desc,
- mipMapped,
- SkBackingFit::kExact,
- SkBudgeted::kYes));
+ desc, fProxy->origin(), mipMapped, SkBackingFit::kExact, SkBudgeted::kYes));
if (!dstContext) {
return nullptr;
}
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
deleted file mode 100644
index b00daf52f5..0000000000
--- a/gm/texdata.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-// This test only works with the GPU backend.
-
-#include "gm.h"
-
-#if SK_SUPPORT_GPU
-#include "GrContext.h"
-#include "GrContextPriv.h"
-#include "GrProxyProvider.h"
-#include "GrRenderTargetContext.h"
-#include "GrTextureContext.h"
-#include "GrFixedClip.h"
-#include "SkColorPriv.h"
-#include "SkGr.h"
-#include "effects/GrPorterDuffXferProcessor.h"
-#include "effects/GrSimpleTextureEffect.h"
-
-constexpr int S = 200;
-constexpr int kStride = 2 * S;
-
-// Fill in the pixels:
-// gray | white
-// -------------
-// black | gray
-static void fill_in_pixels(SkPMColor* pixels) {
- const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40);
- const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff);
- const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00);
-
- int offset = 0;
-
- // fill upper-left
- for (int y = 0; y < S; ++y) {
- for (int x = 0; x < S; ++x) {
- pixels[offset + y * kStride + x] = gray;
- }
- }
- // fill upper-right
- offset = S;
- for (int y = 0; y < S; ++y) {
- for (int x = 0; x < S; ++x) {
- pixels[offset + y * kStride + x] = white;
- }
- }
- // fill lower left
- offset = S * kStride;
- for (int y = 0; y < S; ++y) {
- for (int x = 0; x < S; ++x) {
- pixels[offset + y * kStride + x] = black;
- }
- }
- // fill lower right
- offset = S * kStride + S;
- for (int y = 0; y < S; ++y) {
- for (int x = 0; x < S; ++x) {
- pixels[offset + y * kStride + x] = gray;
- }
- }
-}
-
-DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
- GrRenderTargetContext* renderTargetContext =
- canvas->internal_private_accessTopLayerRenderTargetContext();
- if (!renderTargetContext) {
- skiagm::GM::DrawGpuOnlyMessage(canvas);
- return;
- }
-
- GrContext* context = canvas->getGrContext();
- if (!context) {
- return;
- }
-
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- const SkImageInfo ii = SkImageInfo::Make(S, S, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
-
- SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
- const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00);
- const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80);
- const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00);
- for (int i = 0; i < 2; ++i) {
- fill_in_pixels(gTextureData.get());
-
- GrSurfaceDesc desc;
- desc.fOrigin = i ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
- desc.fWidth = 2 * S;
- desc.fHeight = 2 * S;
- desc.fConfig = SkImageInfo2GrPixelConfig(ii, *context->caps());
- SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
-
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kNo,
- gTextureData.get(), 0);
- if (!proxy) {
- return;
- }
-
- sk_sp<GrSurfaceContext> tContext = context->contextPriv().makeWrappedSurfaceContext(
- std::move(proxy));
-
- if (!tContext) {
- return;
- }
-
- // setup new clip
- GrFixedClip clip(SkIRect::MakeWH(2*S, 2*S));
-
- GrPaint paint;
- paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver);
-
- SkMatrix vm;
- if (i) {
- vm.setRotate(90 * SK_Scalar1, S * SK_Scalar1, S * SK_Scalar1);
- } else {
- vm.reset();
- }
- paint.addColorTextureProcessor(tContext->asTextureProxyRef(), vm);
-
- renderTargetContext->drawRect(clip, GrPaint::Clone(paint), GrAA::kNo, vm,
- SkRect::MakeWH(2 * S, 2 * S));
-
- // now update the lower right of the texture in first pass
- // or upper right in second pass
- for (int y = 0; y < S; ++y) {
- for (int x = 0; x < S; ++x) {
- gTextureData[y * kStride + x] = ((x + y) % 2) ? (i ? green : red) : blue;
- }
- }
-
- if (!tContext->writePixels(ii, gTextureData.get(), 4 * kStride, S, i ? 0 : S)) {
- continue;
- }
-
- renderTargetContext->drawRect(clip, std::move(paint), GrAA::kNo, vm,
- SkRect::MakeWH(2 * S, 2 * S));
- }
-}
-#endif
-
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 7f7f4c4817..716bbc3591 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -89,15 +89,14 @@ protected:
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
GrSurfaceDesc desc;
- desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = fBmp.width();
desc.fHeight = fBmp.height();
desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps());
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
- fBmp.getPixels(),
- fBmp.rowBytes());
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createTextureProxy(desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kYes,
+ fBmp.getPixels(), fBmp.rowBytes());
if (!proxy) {
return;
}
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 841f57488e..ee710ee678 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -86,22 +86,18 @@ protected:
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
sk_sp<GrTextureProxy> proxy[3];
- {
+ for (int i = 0; i < 3; ++i) {
GrSurfaceDesc desc;
- desc.fOrigin = kTopLeft_GrSurfaceOrigin;
-
- for (int i = 0; i < 3; ++i) {
- desc.fWidth = fBmp[i].width();
- desc.fHeight = fBmp[i].height();
- desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[i].info(), *context->caps());
- SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
-
- proxy[i] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
- fBmp[i].getPixels(),
- fBmp[i].rowBytes());
- if (!proxy[i]) {
- return;
- }
+ desc.fWidth = fBmp[i].width();
+ desc.fHeight = fBmp[i].height();
+ desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[i].info(), *context->caps());
+ SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
+
+ proxy[i] = proxyProvider->createTextureProxy(desc, kTopLeft_GrSurfaceOrigin,
+ SkBudgeted::kYes, fBmp[i].getPixels(),
+ fBmp[i].rowBytes());
+ if (!proxy[i]) {
+ return;
}
}
@@ -216,24 +212,19 @@ protected:
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
sk_sp<GrTextureProxy> proxy[3];
- {
+ for (int i = 0; i < 3; ++i) {
+ int index = (0 == i) ? 0 : 1;
GrSurfaceDesc desc;
- desc.fOrigin = kTopLeft_GrSurfaceOrigin;
-
- for (int i = 0; i < 3; ++i) {
- int index = (0 == i) ? 0 : 1;
-
- desc.fWidth = fBmp[index].width();
- desc.fHeight = fBmp[index].height();
- desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[index].info(), *context->caps());
- SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
-
- proxy[i] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
- fBmp[index].getPixels(),
- fBmp[index].rowBytes());
- if (!proxy[i]) {
- return;
- }
+ desc.fWidth = fBmp[index].width();
+ desc.fHeight = fBmp[index].height();
+ desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[index].info(), *context->caps());
+ SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
+
+ proxy[i] = proxyProvider->createTextureProxy(desc, kTopLeft_GrSurfaceOrigin,
+ SkBudgeted::kYes, fBmp[index].getPixels(),
+ fBmp[index].rowBytes());
+ if (!proxy[i]) {
+ return;
}
}