diff options
author | Brian Salomon <bsalomon@google.com> | 2018-03-07 13:01:25 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-07 18:22:40 +0000 |
commit | 58389b90cd387533021c109eb28da40c08e0ead5 (patch) | |
tree | 7744ee9c23c74c61aa00a3cc01eff74cedb8f541 /tools/gpu/ProxyUtils.cpp | |
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/gpu/ProxyUtils.cpp')
-rw-r--r-- | tools/gpu/ProxyUtils.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
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 |