e20fcad156
This reverts commita4f207eb67
. Reason for revert: Landing with fix Original change's description: > Revert "Move makeDeferredRenderTargetContext calls to factory on RTC." > > This reverts commit1c16b43033
. > > Reason for revert: Red on tree > Original change's description: > > Move makeDeferredRenderTargetContext calls to factory on RTC. > > > > Change-Id: Iaa8f5829d9f8650ff27a60f75fb2216f016ab85e > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262058 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com > > Change-Id: I9e3c9d13c66b5437c87ad7136d283fa4ac81df1f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263019 > Reviewed-by: Jim Van Verth <jvanverth@google.com> > Commit-Queue: Jim Van Verth <jvanverth@google.com> TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com Change-Id: If4ec8316a952fb482471c22273f4724f9b30a998 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263022 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
// This is a GPU-backend specific test.
|
|
|
|
#include "tests/Test.h"
|
|
|
|
#include "src/gpu/GrContextPriv.h"
|
|
#include "src/gpu/GrImageInfo.h"
|
|
#include "src/gpu/GrRenderTargetContext.h"
|
|
#include "src/gpu/GrTextureProxy.h"
|
|
|
|
static const int kSize = 64;
|
|
|
|
static std::unique_ptr<GrRenderTargetContext> get_rtc(GrContext* ctx) {
|
|
return GrRenderTargetContext::Make(
|
|
ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kSize, kSize});
|
|
}
|
|
|
|
static void check_instantiation_status(skiatest::Reporter* reporter,
|
|
GrRenderTargetContext* rtCtx,
|
|
bool wrappedExpectation) {
|
|
REPORTER_ASSERT(reporter, rtCtx->testingOnly_IsInstantiated() == wrappedExpectation);
|
|
|
|
GrTextureProxy* tProxy = rtCtx->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
|
|
REPORTER_ASSERT(reporter, tProxy->isInstantiated() == wrappedExpectation);
|
|
}
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RenderTargetContextTest, reporter, ctxInfo) {
|
|
GrContext* ctx = ctxInfo.grContext();
|
|
|
|
// Calling instantiate on a GrRenderTargetContext's textureProxy also instantiates the
|
|
// GrRenderTargetContext
|
|
{
|
|
auto rtCtx = get_rtc(ctx);
|
|
|
|
check_instantiation_status(reporter, rtCtx.get(), false);
|
|
|
|
GrTextureProxy* tProxy = rtCtx->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
|
|
REPORTER_ASSERT(reporter, tProxy->instantiate(ctx->priv().resourceProvider()));
|
|
|
|
check_instantiation_status(reporter, rtCtx.get(), true);
|
|
}
|
|
|
|
// readPixels switches a deferred rtCtx to wrapped
|
|
{
|
|
auto rtCtx = get_rtc(ctx);
|
|
|
|
check_instantiation_status(reporter, rtCtx.get(), false);
|
|
|
|
SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(kSize, kSize);
|
|
SkAutoTMalloc<uint32_t> dstBuffer(kSize * kSize);
|
|
static const size_t kRowBytes = sizeof(uint32_t) * kSize;
|
|
|
|
bool result = rtCtx->readPixels(dstInfo, dstBuffer.get(), kRowBytes, {0, 0});
|
|
REPORTER_ASSERT(reporter, result);
|
|
|
|
check_instantiation_status(reporter, rtCtx.get(), true);
|
|
}
|
|
|
|
// TODO: in a future world we should be able to add a test that the majority of
|
|
// GrRenderTargetContext calls do not force the instantiation of a deferred
|
|
// GrRenderTargetContext
|
|
}
|