2013-04-09 15:04:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2018-12-19 20:42:06 +00:00
|
|
|
#include <set>
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkSurface.h"
|
|
|
|
#include "include/gpu/GrContext.h"
|
|
|
|
#include "include/gpu/GrRenderTarget.h"
|
|
|
|
#include "include/gpu/GrTexture.h"
|
|
|
|
#include "src/core/SkAutoPixmapStorage.h"
|
|
|
|
#include "src/core/SkMipMap.h"
|
|
|
|
#include "src/gpu/GrClip.h"
|
|
|
|
#include "src/gpu/GrContextPriv.h"
|
2019-06-27 14:52:13 +00:00
|
|
|
#include "src/gpu/GrDataUtils.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrGpu.h"
|
|
|
|
#include "src/gpu/GrProxyProvider.h"
|
|
|
|
#include "src/gpu/GrResourceProvider.h"
|
|
|
|
#include "src/gpu/GrTexturePriv.h"
|
|
|
|
#include "tests/Test.h"
|
2019-05-07 17:29:22 +00:00
|
|
|
#include "tests/TestUtils.h"
|
2013-04-09 15:04:12 +00:00
|
|
|
|
2014-11-25 15:41:12 +00:00
|
|
|
// Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static upcasting of texture
|
|
|
|
// and render targets to GrSurface all work as expected.
|
2019-04-03 16:04:45 +00:00
|
|
|
DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
auto resourceProvider = context->priv().resourceProvider();
|
2018-01-16 20:07:54 +00:00
|
|
|
|
2015-12-01 12:35:26 +00:00
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fWidth = 256;
|
|
|
|
desc.fHeight = 256;
|
2017-07-27 20:16:25 +00:00
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
2019-04-09 22:41:27 +00:00
|
|
|
sk_sp<GrSurface> texRT1 = resourceProvider->createTexture(
|
2019-07-22 18:23:45 +00:00
|
|
|
desc, GrRenderable::kYes, 1, SkBudgeted::kNo, GrProtected::kNo,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
2014-11-25 15:41:12 +00:00
|
|
|
|
2017-04-06 11:59:41 +00:00
|
|
|
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
|
|
|
|
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture());
|
2015-12-01 12:35:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) ==
|
|
|
|
texRT1->asTexture());
|
|
|
|
REPORTER_ASSERT(reporter, texRT1->asRenderTarget() ==
|
|
|
|
static_cast<GrSurface*>(texRT1->asTexture()));
|
|
|
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) ==
|
|
|
|
static_cast<GrSurface*>(texRT1->asTexture()));
|
2014-11-25 15:41:12 +00:00
|
|
|
|
2019-04-09 22:41:27 +00:00
|
|
|
sk_sp<GrTexture> tex1 = resourceProvider->createTexture(
|
2019-07-22 18:23:45 +00:00
|
|
|
desc, GrRenderable::kNo, 1, SkBudgeted::kNo, GrProtected::kNo,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
2015-12-01 12:35:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
|
2017-04-06 11:59:41 +00:00
|
|
|
REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
|
|
|
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
|
2013-04-09 15:04:12 +00:00
|
|
|
|
2019-06-04 15:03:06 +00:00
|
|
|
GrBackendTexture backendTex = context->createBackendTexture(
|
2019-06-04 11:16:10 +00:00
|
|
|
256, 256, kRGBA_8888_SkColorType,
|
2019-07-01 19:04:06 +00:00
|
|
|
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
2015-11-10 19:54:56 +00:00
|
|
|
|
2019-01-24 21:03:07 +00:00
|
|
|
sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture(
|
2019-07-16 11:47:56 +00:00
|
|
|
backendTex, 1, GrColorType::kRGBA_8888, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo);
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
|
2016-10-27 16:30:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
|
|
|
|
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
|
2015-12-01 12:35:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
|
|
|
|
texRT2->asTexture());
|
|
|
|
REPORTER_ASSERT(reporter, texRT2->asRenderTarget() ==
|
|
|
|
static_cast<GrSurface*>(texRT2->asTexture()));
|
|
|
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
|
|
|
|
static_cast<GrSurface*>(texRT2->asTexture()));
|
2013-04-09 15:04:12 +00:00
|
|
|
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2013-04-09 15:04:12 +00:00
|
|
|
}
|
|
|
|
|
2017-05-22 17:23:19 +00:00
|
|
|
// This test checks that the isConfigTexturable and isConfigRenderable are
|
|
|
|
// consistent with createTexture's result.
|
|
|
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
|
|
|
GrContext* context = ctxInfo.grContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
|
|
|
const GrCaps* caps = context->priv().caps();
|
2017-05-22 17:23:19 +00:00
|
|
|
|
2019-06-27 14:52:13 +00:00
|
|
|
auto createTexture = [](int width, int height, GrPixelConfig config, GrRenderable renderable,
|
|
|
|
GrResourceProvider* rp) -> sk_sp<GrTexture> {
|
|
|
|
if (GrPixelConfigIsCompressed(config)) {
|
|
|
|
if (renderable == GrRenderable::kYes) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
SkImage::CompressionType type;
|
|
|
|
switch (config) {
|
|
|
|
case kRGB_ETC1_GrPixelConfig:
|
|
|
|
type = SkImage::kETC1_CompressionType;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SK_ABORT("Unexpected config");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
// Only supported compression type right now.
|
|
|
|
SkASSERT(config == kRGB_ETC1_GrPixelConfig);
|
|
|
|
auto size = GrCompressedDataSize(type, width, height);
|
|
|
|
auto data = SkData::MakeUninitialized(size);
|
|
|
|
SkColor4f color = {0, 0, 0, 0};
|
|
|
|
GrFillInCompressedData(type, width, height, (char*)data->writable_data(), color);
|
|
|
|
return rp->createCompressedTexture(width, height, SkImage::kETC1_CompressionType,
|
|
|
|
SkBudgeted::kNo, data.get());
|
|
|
|
} else {
|
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fWidth = width;
|
|
|
|
desc.fHeight = height;
|
|
|
|
desc.fConfig = config;
|
2019-07-22 18:23:45 +00:00
|
|
|
return rp->createTexture(desc, renderable, 1, SkBudgeted::kNo, GrProtected::kNo,
|
2019-06-27 14:52:13 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
|
|
|
}
|
|
|
|
};
|
2017-05-22 17:23:19 +00:00
|
|
|
|
2019-07-09 16:34:38 +00:00
|
|
|
for (int c = 0; c <= kLast_GrPixelConfig; ++c) {
|
|
|
|
GrPixelConfig config = static_cast<GrPixelConfig>(c);
|
|
|
|
|
2019-07-16 11:47:56 +00:00
|
|
|
// We don't round trip correctly going from pixelConfig to colorType to
|
|
|
|
// backendFormat with the RGBX config.
|
|
|
|
if (config == kRGB_888X_GrPixelConfig) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The specific kAlpha_* and kGray_8* pixel configs cause difficulties.
|
|
|
|
// The mapping from config -> colorType -> format doesn't necessarily
|
|
|
|
// resolve back to the expected pixel config. Just test the generic pixel configs.
|
|
|
|
if (config == kAlpha_8_as_Alpha_GrPixelConfig ||
|
|
|
|
config == kAlpha_8_as_Red_GrPixelConfig ||
|
|
|
|
config == kGray_8_as_Lum_GrPixelConfig ||
|
|
|
|
config == kGray_8_as_Red_GrPixelConfig ||
|
2019-07-22 12:48:18 +00:00
|
|
|
config == kAlpha_half_as_Red_GrPixelConfig ||
|
|
|
|
config == kAlpha_half_as_Lum_GrPixelConfig) {
|
2019-07-16 11:47:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-05-22 17:23:19 +00:00
|
|
|
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
2019-06-13 19:21:38 +00:00
|
|
|
if (config == kUnknown_GrPixelConfig) {
|
|
|
|
// It is not valid to be calling into GrProxyProvider with an unknown pixel config.
|
|
|
|
continue;
|
|
|
|
}
|
2019-06-27 14:52:13 +00:00
|
|
|
static constexpr int kW = 64;
|
|
|
|
static constexpr int kH = 64;
|
2019-06-27 00:55:39 +00:00
|
|
|
|
2019-06-27 14:52:13 +00:00
|
|
|
bool ict = caps->isConfigTexturable(config);
|
|
|
|
|
|
|
|
sk_sp<GrSurface> tex =
|
|
|
|
createTexture(kW, kH, config, GrRenderable::kNo, resourceProvider);
|
2018-01-29 14:50:47 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == ict,
|
|
|
|
"config:%d, tex:%d, isConfigTexturable:%d", config, SkToBool(tex), ict);
|
2017-05-22 17:23:19 +00:00
|
|
|
|
2019-07-11 14:52:43 +00:00
|
|
|
GrColorType colorType = GrPixelConfigToColorType(config);
|
|
|
|
const GrBackendFormat format = caps->getBackendFormatFromColorType(colorType);
|
2019-06-13 19:21:38 +00:00
|
|
|
if (!format.isValid()) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-11-16 20:43:41 +00:00
|
|
|
|
2019-06-27 14:52:13 +00:00
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fWidth = kW;
|
|
|
|
desc.fHeight = kH;
|
|
|
|
desc.fConfig = config;
|
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createMipMapProxy(
|
2019-07-22 18:23:45 +00:00
|
|
|
format, desc, GrRenderable::kNo, 1, origin, SkBudgeted::kNo, GrProtected::kNo);
|
2019-06-27 14:52:13 +00:00
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
SkToBool(proxy.get()) ==
|
|
|
|
(caps->isConfigTexturable(desc.fConfig) &&
|
|
|
|
caps->mipMapSupport() && !GrPixelConfigIsCompressed(config)));
|
2017-06-02 12:45:06 +00:00
|
|
|
|
2019-07-22 18:23:45 +00:00
|
|
|
tex = resourceProvider->createTexture(desc, GrRenderable::kYes, 1, SkBudgeted::kNo,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrProtected::kNo,
|
2019-04-09 22:41:27 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
2018-02-03 01:32:49 +00:00
|
|
|
bool isRenderable = caps->isConfigRenderable(config);
|
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
|
|
|
|
"config:%d, tex:%d, isRenderable:%d", config, SkToBool(tex),
|
|
|
|
isRenderable);
|
2017-05-22 17:23:19 +00:00
|
|
|
|
2019-07-22 18:23:45 +00:00
|
|
|
tex = resourceProvider->createTexture(desc, GrRenderable::kYes, 2, SkBudgeted::kNo,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrProtected::kNo,
|
2019-04-09 22:41:27 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
2018-02-03 01:32:49 +00:00
|
|
|
isRenderable = SkToBool(caps->getRenderTargetSampleCount(2, config));
|
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
|
|
|
|
"config:%d, tex:%d, isRenderable:%d", config, SkToBool(tex),
|
|
|
|
isRenderable);
|
2017-05-22 17:23:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrDrawingManager.h"
|
2019-06-18 13:58:02 +00:00
|
|
|
#include "src/gpu/GrSurfaceProxy.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrTextureContext.h"
|
2017-05-23 20:53:47 +00:00
|
|
|
|
2019-07-16 15:52:08 +00:00
|
|
|
DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
|
|
|
GrContextOptions options = baseOptions;
|
|
|
|
options.fClearAllTextures = true;
|
2017-05-23 20:53:47 +00:00
|
|
|
static constexpr int kSize = 100;
|
|
|
|
std::unique_ptr<uint32_t[]> data(new uint32_t[kSize * kSize]);
|
2019-07-16 15:52:08 +00:00
|
|
|
for (int ct = 0; ct < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++ct) {
|
|
|
|
sk_gpu_test::GrContextFactory factory(options);
|
|
|
|
auto contextType = static_cast<sk_gpu_test::GrContextFactory::ContextType>(ct);
|
|
|
|
if (!sk_gpu_test::GrContextFactory::IsRenderingContext(contextType)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
auto context = factory.get(contextType);
|
|
|
|
if (!context) {
|
2017-05-23 20:53:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-07-16 15:52:08 +00:00
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fWidth = desc.fHeight = kSize;
|
|
|
|
|
|
|
|
const GrCaps* caps = context->priv().caps();
|
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
|
|
|
|
for (int c = 0; c <= kLast_GrPixelConfig; ++c) {
|
|
|
|
desc.fConfig = static_cast<GrPixelConfig>(c);
|
|
|
|
if (!caps->isConfigTexturable(desc.fConfig)) {
|
2017-05-23 20:53:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-07-17 13:59:59 +00:00
|
|
|
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
|
|
|
|
if (renderable == GrRenderable::kYes && !caps->isConfigRenderable(desc.fConfig)) {
|
2019-07-16 15:52:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (GrSurfaceOrigin origin :
|
|
|
|
{kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
|
|
|
|
for (auto fit : {SkBackingFit::kApprox, SkBackingFit::kExact}) {
|
2018-09-27 15:28:03 +00:00
|
|
|
auto proxy = proxyProvider->testingOnly_createInstantiatedProxy(
|
2019-07-22 18:23:45 +00:00
|
|
|
desc, renderable, 1, origin, fit, SkBudgeted::kYes,
|
|
|
|
GrProtected::kNo);
|
2018-01-16 13:06:32 +00:00
|
|
|
if (!proxy) {
|
2017-09-25 16:26:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-06-24 16:12:36 +00:00
|
|
|
auto texCtx = context->priv().makeWrappedSurfaceContext(
|
2019-06-24 19:50:07 +00:00
|
|
|
std::move(proxy), GrPixelConfigToColorType(desc.fConfig),
|
|
|
|
kPremul_SkAlphaType);
|
2019-07-16 15:52:08 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType,
|
|
|
|
kPremul_SkAlphaType);
|
2017-09-25 16:26:58 +00:00
|
|
|
memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
|
2019-07-01 17:05:28 +00:00
|
|
|
if (texCtx->readPixels(info, data.get(), 0, {0, 0})) {
|
2017-09-25 16:26:58 +00:00
|
|
|
uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
|
|
|
|
for (int i = 0; i < kSize * kSize; ++i) {
|
|
|
|
if (cmp != data.get()[i]) {
|
2019-07-22 12:48:18 +00:00
|
|
|
ERRORF(reporter, "Failed on conf %d (pix %d) 0x%x != 0x%x",
|
|
|
|
desc.fConfig, i, cmp, data.get()[i]);
|
2017-09-25 16:26:58 +00:00
|
|
|
break;
|
2017-05-23 20:53:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-16 15:52:08 +00:00
|
|
|
context->priv().testingOnly_purgeAllUnlockedResources();
|
2019-07-16 11:47:56 +00:00
|
|
|
|
2019-07-16 15:52:08 +00:00
|
|
|
// We don't round trip correctly going from pixelConfig to colorType to
|
|
|
|
// backendFormat with the RGBX config. The actual config stored on the
|
|
|
|
// GrSurface will be RGBA_8888 but the format we create below will say it is
|
|
|
|
// RGB_888.
|
|
|
|
if (desc.fConfig == kRGB_888X_GrPixelConfig) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-07-16 11:47:56 +00:00
|
|
|
|
2019-07-16 15:52:08 +00:00
|
|
|
// The specific kAlpha_* pixel configs also cause difficulties with OpenGL.
|
|
|
|
// The mapping from config -> colorType -> format doesn't necessarily
|
|
|
|
// resolve back to the expected pixel config. In this case we just test
|
|
|
|
// the generics.
|
|
|
|
if (GrBackendApi::kOpenGL == context->backend() &&
|
|
|
|
(desc.fConfig == kAlpha_8_as_Alpha_GrPixelConfig ||
|
|
|
|
desc.fConfig == kAlpha_8_as_Red_GrPixelConfig ||
|
2019-07-22 12:48:18 +00:00
|
|
|
desc.fConfig == kAlpha_half_as_Red_GrPixelConfig ||
|
|
|
|
desc.fConfig == kAlpha_half_as_Lum_GrPixelConfig)) {
|
2019-07-16 15:52:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
2018-11-16 20:43:41 +00:00
|
|
|
|
2019-07-16 15:52:08 +00:00
|
|
|
// The specific kGray_8_* pixel configs also cause difficulties with OpenGL.
|
|
|
|
// The mapping from config -> colorType -> format doesn't necessarily
|
|
|
|
// resolve back to the expected pixel config. In this case we just test
|
|
|
|
// the generic.
|
|
|
|
if (GrBackendApi::kOpenGL == context->backend() &&
|
|
|
|
(desc.fConfig == kGray_8_as_Lum_GrPixelConfig ||
|
|
|
|
desc.fConfig == kGray_8_as_Red_GrPixelConfig)) {
|
2017-09-25 16:26:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-07-16 15:52:08 +00:00
|
|
|
|
|
|
|
GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
|
|
|
|
|
|
|
|
// Try creating the texture as a deferred proxy.
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
2019-07-16 19:36:11 +00:00
|
|
|
sk_sp<GrSurfaceContext> surfCtx;
|
2019-07-17 13:59:59 +00:00
|
|
|
if (renderable == GrRenderable::kYes) {
|
2019-07-16 19:36:11 +00:00
|
|
|
surfCtx = context->priv().makeDeferredRenderTargetContext(
|
2019-07-22 18:23:45 +00:00
|
|
|
fit, desc.fWidth, desc.fHeight, colorType, nullptr, 1,
|
|
|
|
GrMipMapped::kNo, origin, nullptr);
|
2019-07-16 19:36:11 +00:00
|
|
|
} else {
|
|
|
|
surfCtx = context->priv().makeDeferredTextureContext(
|
|
|
|
fit, desc.fWidth, desc.fHeight, colorType,
|
|
|
|
kUnknown_SkAlphaType, nullptr, GrMipMapped::kNo, origin);
|
|
|
|
}
|
2019-07-16 15:52:08 +00:00
|
|
|
if (!surfCtx) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SkImageInfo info = SkImageInfo::Make(
|
|
|
|
kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
|
|
|
memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
|
|
|
|
if (surfCtx->readPixels(info, data.get(), 0, {0, 0})) {
|
|
|
|
uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
|
|
|
|
for (int i = 0; i < kSize * kSize; ++i) {
|
|
|
|
if (cmp != data.get()[i]) {
|
2019-07-22 12:48:18 +00:00
|
|
|
ERRORF(reporter, "Failed on conf %d (pix %d) 0x%x != 0x%x",
|
|
|
|
desc.fConfig, i, cmp, data.get()[i]);
|
2019-07-16 15:52:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-05-23 20:53:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-16 15:52:08 +00:00
|
|
|
context->priv().testingOnly_purgeAllUnlockedResources();
|
2017-09-25 16:26:58 +00:00
|
|
|
}
|
2017-05-23 20:53:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-06 15:00:03 +00:00
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
2019-06-10 19:09:34 +00:00
|
|
|
auto fillPixels = [](SkPixmap* p, const std::function<uint32_t(int x, int y)>& f) {
|
2018-12-06 15:00:03 +00:00
|
|
|
for (int y = 0; y < p->height(); ++y) {
|
|
|
|
for (int x = 0; x < p->width(); ++x) {
|
|
|
|
*p->writable_addr32(x, y) = f(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto comparePixels = [](const SkPixmap& p1, const SkPixmap& p2, skiatest::Reporter* reporter) {
|
|
|
|
SkASSERT(p1.info() == p2.info());
|
|
|
|
for (int y = 0; y < p1.height(); ++y) {
|
|
|
|
for (int x = 0; x < p1.width(); ++x) {
|
|
|
|
REPORTER_ASSERT(reporter, p1.getColor(x, y) == p2.getColor(x, y));
|
|
|
|
if (p1.getColor(x, y) != p2.getColor(x, y)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr int kSize = 100;
|
|
|
|
SkAutoPixmapStorage pixels;
|
|
|
|
pixels.alloc(SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
|
2019-06-10 19:09:34 +00:00
|
|
|
fillPixels(&pixels,
|
|
|
|
[](int x, int y) {
|
|
|
|
return (0xFFU << 24) | (x << 16) | (y << 8) | uint8_t((x * y) & 0xFF);
|
|
|
|
});
|
2018-12-06 15:00:03 +00:00
|
|
|
|
|
|
|
GrContext* context = context_info.grContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
2018-12-06 15:00:03 +00:00
|
|
|
|
|
|
|
// We test both kRW in addition to kRead mostly to ensure that the calls are structured such
|
|
|
|
// that they'd succeed if the texture wasn't kRead. We want to be sure we're failing with
|
|
|
|
// kRead for the right reason.
|
|
|
|
for (auto ioType : {kRead_GrIOType, kRW_GrIOType}) {
|
2019-07-01 19:04:06 +00:00
|
|
|
auto backendTex = context->priv().createBackendTexture(&pixels, 1,
|
|
|
|
GrRenderable::kYes,
|
|
|
|
GrProtected::kNo);
|
2019-06-10 19:09:34 +00:00
|
|
|
|
2019-07-23 14:27:09 +00:00
|
|
|
auto proxy = proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
|
|
|
|
kTopLeft_GrSurfaceOrigin,
|
2019-01-24 21:03:07 +00:00
|
|
|
kBorrow_GrWrapOwnership,
|
|
|
|
GrWrapCacheable::kNo, ioType);
|
2019-06-24 19:50:07 +00:00
|
|
|
auto surfContext = context->priv().makeWrappedSurfaceContext(proxy, GrColorType::kRGBA_8888,
|
|
|
|
kPremul_SkAlphaType);
|
2018-12-06 15:00:03 +00:00
|
|
|
|
|
|
|
// Read pixels should work with a read-only texture.
|
|
|
|
SkAutoPixmapStorage read;
|
|
|
|
read.alloc(pixels.info());
|
2019-07-01 17:05:28 +00:00
|
|
|
auto readResult = surfContext->readPixels(pixels.info(), read.writable_addr(), 0, {0, 0});
|
2018-12-06 15:00:03 +00:00
|
|
|
REPORTER_ASSERT(reporter, readResult);
|
|
|
|
if (readResult) {
|
|
|
|
comparePixels(pixels, read, reporter);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write pixels should not work with a read-only texture.
|
|
|
|
SkAutoPixmapStorage write;
|
|
|
|
write.alloc(pixels.info());
|
|
|
|
fillPixels(&write, [&pixels](int x, int y) { return ~*pixels.addr32(); });
|
2019-07-01 17:05:28 +00:00
|
|
|
auto writeResult = surfContext->writePixels(pixels.info(), pixels.addr(), 0, {0, 0});
|
2018-12-06 15:00:03 +00:00
|
|
|
REPORTER_ASSERT(reporter, writeResult == (ioType == kRW_GrIOType));
|
|
|
|
// Try the low level write.
|
|
|
|
context->flush();
|
2019-02-04 18:26:26 +00:00
|
|
|
auto gpuWriteResult = context->priv().getGpu()->writePixels(
|
2018-12-06 15:00:03 +00:00
|
|
|
proxy->peekTexture(), 0, 0, kSize, kSize, GrColorType::kRGBA_8888, write.addr32(),
|
2019-07-02 16:25:21 +00:00
|
|
|
kSize * GrColorTypeBytesPerPixel(GrColorType::kRGBA_8888));
|
2018-12-06 15:00:03 +00:00
|
|
|
REPORTER_ASSERT(reporter, gpuWriteResult == (ioType == kRW_GrIOType));
|
|
|
|
|
|
|
|
// Copies should not work with a read-only texture
|
|
|
|
auto copySrc = proxyProvider->createTextureProxy(
|
2019-07-17 13:59:59 +00:00
|
|
|
SkImage::MakeFromRaster(write, nullptr, nullptr), GrRenderable::kNo, 1,
|
2018-12-06 15:00:03 +00:00
|
|
|
SkBudgeted::kYes, SkBackingFit::kExact);
|
|
|
|
REPORTER_ASSERT(reporter, copySrc);
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
auto copyResult = surfContext->testCopy(copySrc.get());
|
2018-12-06 15:00:03 +00:00
|
|
|
REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType));
|
|
|
|
// Try the low level copy.
|
|
|
|
context->flush();
|
2019-02-04 18:26:26 +00:00
|
|
|
auto gpuCopyResult = context->priv().getGpu()->copySurface(
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
proxy->peekTexture(), copySrc->peekTexture(), SkIRect::MakeWH(kSize, kSize),
|
|
|
|
{0, 0});
|
2018-12-06 15:00:03 +00:00
|
|
|
REPORTER_ASSERT(reporter, gpuCopyResult == (ioType == kRW_GrIOType));
|
|
|
|
|
|
|
|
// Mip regen should not work with a read only texture.
|
2019-02-04 18:26:26 +00:00
|
|
|
if (context->priv().caps()->mipMapSupport()) {
|
2019-05-29 18:24:32 +00:00
|
|
|
delete_backend_texture(context, backendTex);
|
2019-06-04 15:03:06 +00:00
|
|
|
backendTex = context->createBackendTexture(
|
2019-06-04 11:16:10 +00:00
|
|
|
kSize, kSize, kRGBA_8888_SkColorType,
|
2019-07-01 19:04:06 +00:00
|
|
|
SkColors::kTransparent, GrMipMapped::kYes, GrRenderable::kYes,
|
|
|
|
GrProtected::kNo);
|
2019-07-23 14:27:09 +00:00
|
|
|
proxy = proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
|
|
|
|
kTopLeft_GrSurfaceOrigin,
|
2019-01-24 21:03:07 +00:00
|
|
|
kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
|
|
|
ioType);
|
2018-12-06 15:00:03 +00:00
|
|
|
context->flush();
|
|
|
|
proxy->peekTexture()->texturePriv().markMipMapsDirty(); // avoids assert in GrGpu.
|
|
|
|
auto regenResult =
|
2019-02-04 18:26:26 +00:00
|
|
|
context->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
|
2018-12-06 15:00:03 +00:00
|
|
|
REPORTER_ASSERT(reporter, regenResult == (ioType == kRW_GrIOType));
|
|
|
|
}
|
2019-05-29 18:24:32 +00:00
|
|
|
delete_backend_texture(context, backendTex);
|
2018-12-06 15:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-19 20:42:06 +00:00
|
|
|
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
static const int kSurfSize = 10;
|
|
|
|
|
2019-05-13 14:40:06 +00:00
|
|
|
static sk_sp<GrTexture> make_wrapped_texture(GrContext* context, GrRenderable renderable) {
|
2019-06-04 15:03:06 +00:00
|
|
|
auto backendTexture = context->createBackendTexture(
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
kSurfSize, kSurfSize, kRGBA_8888_SkColorType, SkColors::kTransparent, GrMipMapped::kNo,
|
2019-07-01 19:04:06 +00:00
|
|
|
renderable, GrProtected::kNo);
|
2019-02-22 15:44:19 +00:00
|
|
|
sk_sp<GrTexture> texture;
|
2019-05-13 14:40:06 +00:00
|
|
|
if (GrRenderable::kYes == renderable) {
|
2019-02-22 15:44:19 +00:00
|
|
|
texture = context->priv().resourceProvider()->wrapRenderableBackendTexture(
|
2019-07-16 11:47:56 +00:00
|
|
|
backendTexture, 1, GrColorType::kRGBA_8888, kBorrow_GrWrapOwnership,
|
|
|
|
GrWrapCacheable::kNo);
|
2019-02-22 15:44:19 +00:00
|
|
|
} else {
|
|
|
|
texture = context->priv().resourceProvider()->wrapBackendTexture(
|
2019-07-23 14:27:09 +00:00
|
|
|
backendTexture, GrColorType::kRGBA_8888, kBorrow_GrWrapOwnership,
|
|
|
|
GrWrapCacheable::kNo, kRW_GrIOType);
|
2019-02-22 15:44:19 +00:00
|
|
|
}
|
|
|
|
// Add a release proc that deletes the GrBackendTexture.
|
|
|
|
struct ReleaseContext {
|
|
|
|
GrContext* fContext;
|
|
|
|
GrBackendTexture fBackendTexture;
|
2018-12-19 20:42:06 +00:00
|
|
|
};
|
2019-02-22 15:44:19 +00:00
|
|
|
auto release = [](void* rc) {
|
|
|
|
auto releaseContext = static_cast<ReleaseContext*>(rc);
|
2019-05-17 14:01:21 +00:00
|
|
|
auto context = releaseContext->fContext;
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(releaseContext->fBackendTexture);
|
2019-02-22 15:44:19 +00:00
|
|
|
delete releaseContext;
|
2018-12-19 20:42:06 +00:00
|
|
|
};
|
2019-03-05 18:28:58 +00:00
|
|
|
texture->setRelease(release, new ReleaseContext{context, backendTexture});
|
2019-02-22 15:44:19 +00:00
|
|
|
return texture;
|
|
|
|
}
|
2018-12-19 20:42:06 +00:00
|
|
|
|
2019-05-13 14:40:06 +00:00
|
|
|
static sk_sp<GrTexture> make_normal_texture(GrContext* context, GrRenderable renderable) {
|
2019-02-22 15:44:19 +00:00
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
desc.fWidth = desc.fHeight = kSurfSize;
|
2019-04-09 22:41:27 +00:00
|
|
|
return context->priv().resourceProvider()->createTexture(
|
2019-07-22 18:23:45 +00:00
|
|
|
desc, renderable, 1, SkBudgeted::kNo, GrProtected::kNo,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
2019-02-22 15:44:19 +00:00
|
|
|
}
|
2018-12-19 20:42:06 +00:00
|
|
|
|
2019-02-22 15:44:19 +00:00
|
|
|
DEF_GPUTEST(TextureIdleProcTest, reporter, options) {
|
|
|
|
// Various ways of making textures.
|
2019-05-13 14:40:06 +00:00
|
|
|
auto makeWrapped = [](GrContext* context) {
|
|
|
|
return make_wrapped_texture(context, GrRenderable::kNo);
|
|
|
|
};
|
2019-02-22 15:44:19 +00:00
|
|
|
auto makeWrappedRenderable = [](GrContext* context) {
|
2019-05-13 14:40:06 +00:00
|
|
|
return make_wrapped_texture(context, GrRenderable::kYes);
|
|
|
|
};
|
|
|
|
auto makeNormal = [](GrContext* context) {
|
|
|
|
return make_normal_texture(context, GrRenderable::kNo);
|
|
|
|
};
|
|
|
|
auto makeRenderable = [](GrContext* context) {
|
|
|
|
return make_normal_texture(context, GrRenderable::kYes);
|
2018-12-19 20:42:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::function<sk_sp<GrTexture>(GrContext*)> makers[] = {makeWrapped, makeWrappedRenderable,
|
|
|
|
makeNormal, makeRenderable};
|
|
|
|
|
|
|
|
// Add a unique key, or not.
|
|
|
|
auto addKey = [](GrTexture* texture) {
|
|
|
|
static uint32_t gN = 0;
|
|
|
|
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
|
|
|
|
GrUniqueKey key;
|
|
|
|
GrUniqueKey::Builder builder(&key, kDomain, 1);
|
|
|
|
builder[0] = gN++;
|
|
|
|
builder.finish();
|
|
|
|
texture->resourcePriv().setUniqueKey(key);
|
|
|
|
};
|
|
|
|
auto dontAddKey = [](GrTexture* texture) {};
|
|
|
|
std::function<void(GrTexture*)> keyAdders[] = {addKey, dontAddKey};
|
|
|
|
|
|
|
|
for (const auto& m : makers) {
|
|
|
|
for (const auto& keyAdder : keyAdders) {
|
|
|
|
for (int type = 0; type < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++type) {
|
|
|
|
sk_gpu_test::GrContextFactory factory;
|
|
|
|
auto contextType = static_cast<sk_gpu_test::GrContextFactory::ContextType>(type);
|
2019-01-24 17:18:33 +00:00
|
|
|
GrContext* context = factory.get(contextType);
|
2018-12-19 20:42:06 +00:00
|
|
|
if (!context) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The callback we add simply adds an integer to a set.
|
|
|
|
std::set<int> idleIDs;
|
|
|
|
struct Context {
|
|
|
|
std::set<int>* fIdleIDs;
|
|
|
|
int fNum;
|
|
|
|
};
|
|
|
|
auto proc = [](void* context) {
|
|
|
|
static_cast<Context*>(context)->fIdleIDs->insert(
|
|
|
|
static_cast<Context*>(context)->fNum);
|
|
|
|
delete static_cast<Context*>(context);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Makes a texture, possibly adds a key, and sets the callback.
|
|
|
|
auto make = [&m, &keyAdder, &proc, &idleIDs](GrContext* context, int num) {
|
|
|
|
sk_sp<GrTexture> texture = m(context);
|
2019-03-08 18:25:19 +00:00
|
|
|
texture->addIdleProc(proc, new Context{&idleIDs, num},
|
|
|
|
GrTexture::IdleState::kFinished);
|
2018-12-19 20:42:06 +00:00
|
|
|
keyAdder(texture.get());
|
|
|
|
return texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto texture = make(context, 1);
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(1) == idleIDs.end());
|
2019-07-17 13:59:59 +00:00
|
|
|
auto renderable = GrRenderable(SkToBool(texture->asRenderTarget()));
|
2018-12-19 20:42:06 +00:00
|
|
|
auto backendFormat = texture->backendFormat();
|
|
|
|
texture.reset();
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(1) != idleIDs.end());
|
|
|
|
|
|
|
|
texture = make(context, 2);
|
2019-02-22 15:44:19 +00:00
|
|
|
int w = texture->width();
|
|
|
|
int h = texture->height();
|
2018-12-19 20:42:06 +00:00
|
|
|
SkImageInfo info =
|
2019-02-22 15:44:19 +00:00
|
|
|
SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
2018-12-19 20:42:06 +00:00
|
|
|
auto rt = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
|
|
|
|
auto rtc = rt->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
|
|
|
|
auto singleUseLazyCB = [&texture](GrResourceProvider* rp) {
|
2019-04-01 16:29:34 +00:00
|
|
|
auto mode = GrSurfaceProxy::LazyInstantiationKeyMode::kSynced;
|
|
|
|
if (texture->getUniqueKey().isValid()) {
|
|
|
|
mode = GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced;
|
|
|
|
}
|
|
|
|
return GrSurfaceProxy::LazyInstantiationResult{std::move(texture), mode};
|
2018-12-19 20:42:06 +00:00
|
|
|
};
|
|
|
|
GrSurfaceDesc desc;
|
2019-02-22 15:44:19 +00:00
|
|
|
desc.fWidth = w;
|
|
|
|
desc.fHeight = h;
|
2018-12-19 20:42:06 +00:00
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
2019-01-24 20:58:58 +00:00
|
|
|
SkBudgeted budgeted;
|
|
|
|
if (texture->resourcePriv().budgetedType() == GrBudgetedType::kBudgeted) {
|
|
|
|
budgeted = SkBudgeted::kYes;
|
|
|
|
} else {
|
|
|
|
budgeted = SkBudgeted::kNo;
|
|
|
|
}
|
2019-02-04 18:26:26 +00:00
|
|
|
auto proxy = context->priv().proxyProvider()->createLazyProxy(
|
2019-07-22 18:23:45 +00:00
|
|
|
singleUseLazyCB, backendFormat, desc, renderable, 1,
|
2018-12-19 20:42:06 +00:00
|
|
|
GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
|
|
|
|
GrInternalSurfaceFlags ::kNone, SkBackingFit::kExact, budgeted,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrProtected::kNo, GrSurfaceProxy::LazyInstantiationType::kSingleUse);
|
2019-02-13 18:25:21 +00:00
|
|
|
rtc->drawTexture(GrNoClip(), proxy, GrSamplerState::Filter::kNearest,
|
2019-02-22 15:44:19 +00:00
|
|
|
SkBlendMode::kSrcOver, SkPMColor4f(), SkRect::MakeWH(w, h),
|
|
|
|
SkRect::MakeWH(w, h), GrAA::kNo, GrQuadAAFlags::kNone,
|
2019-02-13 18:25:21 +00:00
|
|
|
SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
|
2018-12-19 20:42:06 +00:00
|
|
|
// We still have the proxy, which should remain instantiated, thereby keeping the
|
|
|
|
// texture not purgeable.
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
|
|
|
|
context->flush();
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
|
2019-02-04 18:26:26 +00:00
|
|
|
context->priv().getGpu()->testingOnly_flushGpuAndSync();
|
2018-12-19 20:42:06 +00:00
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
|
|
|
|
|
|
|
|
// This time we move the proxy into the draw.
|
|
|
|
rtc->drawTexture(GrNoClip(), std::move(proxy), GrSamplerState::Filter::kNearest,
|
2019-02-22 15:44:19 +00:00
|
|
|
SkBlendMode::kSrcOver, SkPMColor4f(), SkRect::MakeWH(w, h),
|
|
|
|
SkRect::MakeWH(w, h), GrAA::kNo, GrQuadAAFlags::kNone,
|
2019-02-13 18:25:21 +00:00
|
|
|
SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
|
2018-12-19 20:42:06 +00:00
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
|
|
|
|
context->flush();
|
2019-02-04 18:26:26 +00:00
|
|
|
context->priv().getGpu()->testingOnly_flushGpuAndSync();
|
2018-12-19 20:42:06 +00:00
|
|
|
// Now that the draw is fully consumed by the GPU, the texture should be idle.
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(2) != idleIDs.end());
|
|
|
|
|
2019-03-08 16:12:14 +00:00
|
|
|
// Make a proxy that should deinstantiate even if we keep a ref on it.
|
|
|
|
auto deinstantiateLazyCB = [&make, &context](GrResourceProvider* rp) {
|
2019-04-01 16:29:34 +00:00
|
|
|
auto texture = make(context, 3);
|
|
|
|
auto mode = GrSurfaceProxy::LazyInstantiationKeyMode::kSynced;
|
|
|
|
if (texture->getUniqueKey().isValid()) {
|
|
|
|
mode = GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced;
|
|
|
|
}
|
|
|
|
return GrSurfaceProxy::LazyInstantiationResult{std::move(texture), mode};
|
2019-03-08 16:12:14 +00:00
|
|
|
};
|
|
|
|
proxy = context->priv().proxyProvider()->createLazyProxy(
|
2019-07-22 18:23:45 +00:00
|
|
|
deinstantiateLazyCB, backendFormat, desc, renderable, 1,
|
2019-03-08 16:12:14 +00:00
|
|
|
GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
|
|
|
|
GrInternalSurfaceFlags ::kNone, SkBackingFit::kExact, budgeted,
|
2019-07-19 18:24:36 +00:00
|
|
|
GrProtected::kNo, GrSurfaceProxy::LazyInstantiationType::kDeinstantiate);
|
2019-03-08 16:12:14 +00:00
|
|
|
rtc->drawTexture(GrNoClip(), std::move(proxy), GrSamplerState::Filter::kNearest,
|
|
|
|
SkBlendMode::kSrcOver, SkPMColor4f(), SkRect::MakeWH(w, h),
|
|
|
|
SkRect::MakeWH(w, h), GrAA::kNo, GrQuadAAFlags::kNone,
|
|
|
|
SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
|
|
|
|
// At this point the proxy shouldn't even be instantiated, there is no texture with
|
|
|
|
// id 3.
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(3) == idleIDs.end());
|
|
|
|
context->flush();
|
|
|
|
context->priv().getGpu()->testingOnly_flushGpuAndSync();
|
|
|
|
// Now that the draw is fully consumed, we should have deinstantiated the proxy and
|
|
|
|
// the texture it made should be idle.
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(3) != idleIDs.end());
|
|
|
|
|
2019-01-24 17:18:33 +00:00
|
|
|
// Make sure we make the call during various shutdown scenarios where the texture
|
|
|
|
// might persist after context is destroyed, abandoned, etc. We test three
|
|
|
|
// variations of each scenario. One where the texture is just created. Another,
|
|
|
|
// where the texture has been used in a draw and then the context is flushed. And
|
|
|
|
// one where the the texture was drawn but the context is not flushed.
|
|
|
|
// In each scenario we test holding a ref beyond the context shutdown and not.
|
|
|
|
|
|
|
|
// These tests are difficult to get working with Vulkan. See http://skbug.com/8705
|
|
|
|
// and http://skbug.com/8275
|
|
|
|
GrBackendApi api = sk_gpu_test::GrContextFactory::ContextTypeBackend(contextType);
|
|
|
|
if (api == GrBackendApi::kVulkan) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-08 16:12:14 +00:00
|
|
|
int id = 4;
|
2019-01-24 17:18:33 +00:00
|
|
|
enum class DrawType {
|
|
|
|
kNoDraw,
|
|
|
|
kDraw,
|
|
|
|
kDrawAndFlush,
|
|
|
|
};
|
|
|
|
for (auto drawType :
|
|
|
|
{DrawType::kNoDraw, DrawType::kDraw, DrawType::kDrawAndFlush}) {
|
|
|
|
for (bool unrefFirst : {false, true}) {
|
2019-02-22 15:44:19 +00:00
|
|
|
auto possiblyDrawAndFlush = [&context, &texture, drawType, unrefFirst, w,
|
|
|
|
h] {
|
2019-01-24 17:18:33 +00:00
|
|
|
if (drawType == DrawType::kNoDraw) {
|
|
|
|
return;
|
|
|
|
}
|
2019-02-22 15:44:19 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType,
|
2019-01-24 17:18:33 +00:00
|
|
|
kPremul_SkAlphaType);
|
|
|
|
auto rt = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0,
|
|
|
|
nullptr);
|
2019-02-04 18:26:26 +00:00
|
|
|
auto rtc = rt->getCanvas()
|
2019-01-24 17:18:33 +00:00
|
|
|
->internal_private_accessTopLayerRenderTargetContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
auto proxy = context->priv().proxyProvider()->testingOnly_createWrapped(
|
2019-01-24 17:18:33 +00:00
|
|
|
texture, kTopLeft_GrSurfaceOrigin);
|
2019-02-22 15:44:19 +00:00
|
|
|
rtc->drawTexture(
|
|
|
|
GrNoClip(), proxy, GrSamplerState::Filter::kNearest,
|
|
|
|
SkBlendMode::kSrcOver, SkPMColor4f(), SkRect::MakeWH(w, h),
|
|
|
|
SkRect::MakeWH(w, h), GrAA::kNo, GrQuadAAFlags::kNone,
|
|
|
|
SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
|
2019-01-24 17:18:33 +00:00
|
|
|
if (drawType == DrawType::kDrawAndFlush) {
|
|
|
|
context->flush();
|
|
|
|
}
|
|
|
|
if (unrefFirst) {
|
|
|
|
texture.reset();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
texture = make(context, id);
|
|
|
|
possiblyDrawAndFlush();
|
|
|
|
context->abandonContext();
|
|
|
|
texture.reset();
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(id) != idleIDs.end());
|
|
|
|
factory.destroyContexts();
|
|
|
|
context = factory.get(contextType);
|
|
|
|
++id;
|
|
|
|
|
|
|
|
// Similar to previous, but reset the texture after the context was
|
|
|
|
// abandoned and then destroyed.
|
|
|
|
texture = make(context, id);
|
|
|
|
possiblyDrawAndFlush();
|
|
|
|
context->abandonContext();
|
|
|
|
factory.destroyContexts();
|
|
|
|
texture.reset();
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(id) != idleIDs.end());
|
|
|
|
context = factory.get(contextType);
|
|
|
|
id++;
|
|
|
|
|
|
|
|
texture = make(context, id);
|
|
|
|
possiblyDrawAndFlush();
|
|
|
|
factory.destroyContexts();
|
|
|
|
texture.reset();
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(id) != idleIDs.end());
|
|
|
|
context = factory.get(contextType);
|
|
|
|
id++;
|
|
|
|
|
|
|
|
texture = make(context, id);
|
|
|
|
possiblyDrawAndFlush();
|
|
|
|
factory.releaseResourcesAndAbandonContexts();
|
|
|
|
texture.reset();
|
|
|
|
REPORTER_ASSERT(reporter, idleIDs.find(id) != idleIDs.end());
|
|
|
|
context = factory.get(contextType);
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
2018-12-19 20:42:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-22 15:44:19 +00:00
|
|
|
|
|
|
|
// Tests an idle proc that unrefs another resource down to zero.
|
|
|
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcCacheManipulationTest, reporter, contextInfo) {
|
|
|
|
GrContext* context = contextInfo.grContext();
|
|
|
|
|
|
|
|
// idle proc that releases another texture.
|
|
|
|
auto idleProc = [](void* texture) { reinterpret_cast<GrTexture*>(texture)->unref(); };
|
|
|
|
|
|
|
|
for (const auto& idleMaker : {make_wrapped_texture, make_normal_texture}) {
|
|
|
|
for (const auto& otherMaker : {make_wrapped_texture, make_normal_texture}) {
|
2019-03-08 18:25:19 +00:00
|
|
|
for (auto idleState :
|
|
|
|
{GrTexture::IdleState::kFlushed, GrTexture::IdleState::kFinished}) {
|
2019-05-13 14:40:06 +00:00
|
|
|
auto idleTexture = idleMaker(context, GrRenderable::kNo);
|
|
|
|
auto otherTexture = otherMaker(context, GrRenderable::kNo);
|
2019-03-08 18:25:19 +00:00
|
|
|
otherTexture->ref();
|
|
|
|
idleTexture->addIdleProc(idleProc, otherTexture.get(), idleState);
|
|
|
|
otherTexture.reset();
|
|
|
|
idleTexture.reset();
|
|
|
|
}
|
2019-02-22 15:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Similar to above but more complicated. This flushes the context from the idle proc.
|
|
|
|
// crbug.com/933526.
|
|
|
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcFlushTest, reporter, contextInfo) {
|
|
|
|
GrContext* context = contextInfo.grContext();
|
|
|
|
|
|
|
|
// idle proc that flushes the context.
|
|
|
|
auto idleProc = [](void* context) { reinterpret_cast<GrContext*>(context)->flush(); };
|
|
|
|
|
|
|
|
for (const auto& idleMaker : {make_wrapped_texture, make_normal_texture}) {
|
2019-03-08 18:25:19 +00:00
|
|
|
for (auto idleState : {GrTexture::IdleState::kFlushed, GrTexture::IdleState::kFinished}) {
|
2019-05-13 14:40:06 +00:00
|
|
|
auto idleTexture = idleMaker(context, GrRenderable::kNo);
|
2019-03-08 18:25:19 +00:00
|
|
|
idleTexture->addIdleProc(idleProc, context, idleState);
|
|
|
|
auto info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
|
|
|
auto surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 1, nullptr);
|
|
|
|
// We'll draw two images to the canvas. One is a normal texture-backed image. The other
|
|
|
|
// is a wrapped-texture backed image.
|
|
|
|
surf->getCanvas()->clear(SK_ColorWHITE);
|
|
|
|
auto img1 = surf->makeImageSnapshot();
|
2019-05-07 17:29:22 +00:00
|
|
|
|
|
|
|
GrBackendTexture backendTexture;
|
|
|
|
|
|
|
|
if (!create_backend_texture(context, &backendTexture, info,
|
2019-05-13 14:40:06 +00:00
|
|
|
GrMipMapped::kNo, SK_ColorBLACK, GrRenderable::kNo)) {
|
2019-05-07 17:29:22 +00:00
|
|
|
REPORTER_ASSERT(reporter, false);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-03-08 18:25:19 +00:00
|
|
|
auto img2 = SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
|
|
|
|
info.colorType(), info.alphaType(), nullptr);
|
|
|
|
surf->getCanvas()->drawImage(std::move(img1), 0, 0);
|
|
|
|
surf->getCanvas()->drawImage(std::move(img2), 1, 1);
|
|
|
|
idleTexture.reset();
|
2019-05-07 17:29:22 +00:00
|
|
|
|
|
|
|
delete_backend_texture(context, backendTexture);
|
2019-03-08 18:25:19 +00:00
|
|
|
}
|
2019-02-22 15:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcRerefTest, reporter, contextInfo) {
|
|
|
|
GrContext* context = contextInfo.grContext();
|
|
|
|
// idle proc that refs the texture
|
|
|
|
auto idleProc = [](void* texture) { reinterpret_cast<GrTexture*>(texture)->ref(); };
|
|
|
|
// release proc to check whether the texture was released or not.
|
|
|
|
auto releaseProc = [](void* isReleased) { *reinterpret_cast<bool*>(isReleased) = true; };
|
2019-03-08 18:25:19 +00:00
|
|
|
for (auto idleState : {GrTexture::IdleState::kFlushed, GrTexture::IdleState::kFinished}) {
|
|
|
|
bool isReleased = false;
|
2019-05-13 14:40:06 +00:00
|
|
|
auto idleTexture = make_normal_texture(context, GrRenderable::kNo);
|
2019-03-08 18:25:19 +00:00
|
|
|
// This test assumes the texture won't be cached (or else the release proc doesn't get
|
|
|
|
// called).
|
|
|
|
idleTexture->resourcePriv().removeScratchKey();
|
|
|
|
context->flush();
|
|
|
|
idleTexture->addIdleProc(idleProc, idleTexture.get(), idleState);
|
|
|
|
idleTexture->setRelease(releaseProc, &isReleased);
|
|
|
|
auto* raw = idleTexture.get();
|
|
|
|
idleTexture.reset();
|
|
|
|
REPORTER_ASSERT(reporter, !isReleased);
|
|
|
|
raw->unref();
|
|
|
|
REPORTER_ASSERT(reporter, isReleased);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleStateTest, reporter, contextInfo) {
|
|
|
|
GrContext* context = contextInfo.grContext();
|
|
|
|
for (const auto& idleMaker : {make_wrapped_texture, make_normal_texture}) {
|
2019-05-13 14:40:06 +00:00
|
|
|
auto idleTexture = idleMaker(context, GrRenderable::kNo);
|
2019-03-08 18:25:19 +00:00
|
|
|
|
|
|
|
uint32_t flags = 0;
|
|
|
|
static constexpr uint32_t kFlushFlag = 0x1;
|
|
|
|
static constexpr uint32_t kFinishFlag = 0x2;
|
|
|
|
auto flushProc = [](void* flags) { *static_cast<uint32_t*>(flags) |= kFlushFlag; };
|
|
|
|
auto finishProc = [](void* flags) { *static_cast<uint32_t*>(flags) |= kFinishFlag; };
|
|
|
|
idleTexture->addIdleProc(flushProc, &flags, GrTexture::IdleState::kFlushed);
|
|
|
|
idleTexture->addIdleProc(finishProc, &flags, GrTexture::IdleState::kFinished);
|
|
|
|
|
|
|
|
// Insert a copy from idleTexture to another texture so that we have some queued IO on
|
|
|
|
// idleTexture.
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(kSurfSize, kSurfSize, kRGBA_8888_SkColorType,
|
|
|
|
kPremul_SkAlphaType);
|
2019-03-08 18:25:19 +00:00
|
|
|
auto rt = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
|
|
|
|
auto rtc = rt->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
auto proxy = context->priv().proxyProvider()->testingOnly_createWrapped(
|
|
|
|
std::move(idleTexture), rtc->asSurfaceProxy()->origin());
|
2019-03-08 18:25:19 +00:00
|
|
|
context->flush();
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
SkAssertResult(rtc->testCopy(proxy.get()));
|
2019-03-08 18:25:19 +00:00
|
|
|
proxy.reset();
|
|
|
|
REPORTER_ASSERT(reporter, flags == 0);
|
|
|
|
|
|
|
|
// After a flush we expect idleTexture to have reached the kFlushed state on all backends.
|
|
|
|
// On "managed" backends we expect it to reach kFinished as well. On Vulkan, the only
|
|
|
|
// current "unmanaged" backend, we *may* need a sync to reach kFinished.
|
|
|
|
context->flush();
|
|
|
|
if (contextInfo.backend() == kVulkan_GrBackend) {
|
|
|
|
REPORTER_ASSERT(reporter, flags & kFlushFlag);
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, flags == (kFlushFlag | kFinishFlag));
|
|
|
|
}
|
|
|
|
context->priv().getGpu()->testingOnly_flushGpuAndSync();
|
|
|
|
REPORTER_ASSERT(reporter, flags == (kFlushFlag | kFinishFlag));
|
|
|
|
}
|
2019-02-22 15:44:19 +00:00
|
|
|
}
|