diff options
author | 2018-03-07 13:01:25 -0500 | |
---|---|---|
committer | 2018-03-07 18:22:40 +0000 | |
commit | 58389b90cd387533021c109eb28da40c08e0ead5 (patch) | |
tree | 7744ee9c23c74c61aa00a3cc01eff74cedb8f541 /tools | |
parent | ab6fd7ef91aeca8a3fbbc6c6670cb89a5a7b6d53 (diff) |
Initial texture data is never flipped when uploaded.
The first bytes of the data always refer to the pixel accessed by texture coord (0, 0).
Change-Id: I708702d90f35b3bc896a48c3c3fd6a0be73f505a
Reviewed-on: https://skia-review.googlesource.com/112261
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/fiddle/fiddle_main.cpp | 11 | ||||
-rw-r--r-- | tools/gpu/ProxyUtils.cpp | 40 | ||||
-rw-r--r-- | tools/gpu/ProxyUtils.h | 41 |
3 files changed, 86 insertions, 6 deletions
diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp index 891b1ffecc..578f7cbf0c 100644 --- a/tools/fiddle/fiddle_main.cpp +++ b/tools/fiddle/fiddle_main.cpp @@ -164,9 +164,9 @@ static bool setup_backend_objects(GrContext* context, texels[i].fRowBytes = 0; } - backingTexture = resourceProvider->createTexture( - backingDesc, SkBudgeted::kNo, kTopLeft_GrSurfaceOrigin, texels.get(), mipLevelCount, - SkDestinationSurfaceColorMode::kLegacy); + backingTexture = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo, texels.get(), + mipLevelCount, + SkDestinationSurfaceColorMode::kLegacy); if (!backingTexture) { return false; } @@ -193,8 +193,7 @@ static bool setup_backend_objects(GrContext* context, GrMipLevel level0 = { data.get(), backingDesc.fWidth*sizeof(uint32_t) }; sk_sp<GrTexture> tmp = resourceProvider->createTexture( - backingDesc, SkBudgeted::kNo, kTopLeft_GrSurfaceOrigin, &level0, 1, - SkDestinationSurfaceColorMode::kLegacy); + backingDesc, SkBudgeted::kNo, &level0, 1, SkDestinationSurfaceColorMode::kLegacy); if (!tmp || !tmp->asRenderTarget()) { return false; } @@ -222,7 +221,7 @@ static bool setup_backend_objects(GrContext* context, } backingTextureRenderTarget = resourceProvider->createTexture( - backingDesc, SkBudgeted::kNo, kTopLeft_GrSurfaceOrigin, texels.get(), mipLevelCount, + backingDesc, SkBudgeted::kNo, texels.get(), mipLevelCount, SkDestinationSurfaceColorMode::kLegacy); if (!backingTextureRenderTarget || !backingTextureRenderTarget->asRenderTarget()) { return false; diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp new file mode 100644 index 0000000000..e02bf5fd26 --- /dev/null +++ b/tools/gpu/ProxyUtils.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ProxyUtils.h" +#include "GrContextPriv.h" +#include "GrDrawingManager.h" +#include "GrProxyProvider.h" + +namespace sk_gpu_test { + +sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width, int height, + 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 sContext = context->contextPriv().makeWrappedSurfaceContext(proxy, nullptr); + if (!sContext) { + return nullptr; + } + if (!context->contextPriv().writeSurfacePixels(sContext.get(), 0, 0, width, height, ct, nullptr, + data, rowBytes)) { + return nullptr; + } + return proxy; +} + +} // namespace sk_gpu_test diff --git a/tools/gpu/ProxyUtils.h b/tools/gpu/ProxyUtils.h new file mode 100644 index 0000000000..6dfcd713f8 --- /dev/null +++ b/tools/gpu/ProxyUtils.h @@ -0,0 +1,41 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ProxyUtils_DEFINED +#define ProxyUtils_DEFINED + +#include "GrTextureProxy.h" +#include "GrTypesPriv.h" + +namespace sk_gpu_test { + +/** Makes a texture proxy containing the passed in color data. */ +sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width, int height, + GrColorType, GrSRGBEncoded, GrSurfaceOrigin, + const void* data, size_t rowBytes); + +/** Version that assumes GrSRGBEncoded::kNo. */ +inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width, + int height, GrColorType ct, + GrSurfaceOrigin origin, const void* data, + size_t rowBytes) { + return MakeTextureProxyFromData(context, isRT, width, height, ct, GrSRGBEncoded::kNo, origin, + data, rowBytes); +} + +/** Version that takes SkColorType rather than GrColorType and assumes GrSRGBEncoded::kNo. */ +inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width, + int height, SkColorType ct, + GrSurfaceOrigin origin, const void* data, + size_t rowBytes) { + return MakeTextureProxyFromData(context, isRT, width, height, SkColorTypeToGrColorType(ct), + origin, data, rowBytes); +} + +} // namespace sk_gpu_test + +#endif |