6a67f1f40f
This reverts commit35ef74b7a4
. Reason for revert: causing chrome roll failure? Original change's description: > Reland "Create updateResourceLabel method." > > This is a reland of commit605f92c7d7
> > Original change's description: > > Create updateResourceLabel method. > > > > In this CL, the GrSurfaceProxy's and GrDrawOpAtlas's label strings > > are plumbed so that it can be stored in the label string of > > GrGpuResource. updateResourceLabel method, which is called from > > setLabel method, will add labels to Skia OpenGL backend using ANGLE's > > labeling API. > > > > Bug: chromium:1164111 > > Change-Id: I370715d186357e920d260d624d77586cdddd11e8 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541230 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Bug: chromium:1164111 > Change-Id: Ia20a81d22e320813cbc4ad1d41e06e47dc3827bb > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544058 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> Bug: chromium:1164111 Change-Id: Icacb3a0f2f2ee03afc09e03c2ee59b03d5bdd811 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544241 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Auto-Submit: Tyler Denniston <tdenniston@google.com>
173 lines
7.4 KiB
C++
173 lines
7.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 "include/gpu/GrBackendSurface.h"
|
|
#include "include/gpu/GrDirectContext.h"
|
|
#include "src/gpu/ganesh/GrDirectContextPriv.h"
|
|
#include "src/gpu/ganesh/GrGpu.h"
|
|
#include "src/gpu/ganesh/GrProxyProvider.h"
|
|
#include "src/gpu/ganesh/GrRenderTarget.h"
|
|
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
|
|
#include "src/gpu/ganesh/GrSurfaceProxy.h"
|
|
#include "src/gpu/ganesh/GrTexture.h"
|
|
#include "src/gpu/ganesh/GrTextureProxy.h"
|
|
|
|
static sk_sp<GrSurfaceProxy> make_wrapped_rt(GrProxyProvider* provider,
|
|
GrGpu* gpu,
|
|
skiatest::Reporter* reporter,
|
|
const SkISize& size,
|
|
GrColorType colorType) {
|
|
auto backendRT = gpu->createTestingOnlyBackendRenderTarget(size, colorType);
|
|
return provider->wrapBackendRenderTarget(backendRT, nullptr);
|
|
}
|
|
|
|
void clean_up_wrapped_rt(GrGpu* gpu, sk_sp<GrSurfaceProxy> proxy) {
|
|
SkASSERT(proxy->unique());
|
|
SkASSERT(proxy->peekRenderTarget());
|
|
GrBackendRenderTarget rt = proxy->peekRenderTarget()->getBackendRenderTarget();
|
|
proxy.reset();
|
|
gpu->deleteTestingOnlyBackendRenderTarget(rt);
|
|
}
|
|
|
|
static sk_sp<GrSurfaceProxy> make_offscreen_rt(GrProxyProvider* provider,
|
|
SkISize dimensions,
|
|
GrColorType colorType) {
|
|
return provider->testingOnly_createInstantiatedProxy(dimensions, colorType, GrRenderable::kYes,
|
|
1, SkBackingFit::kExact, SkBudgeted::kYes,
|
|
GrProtected::kNo);
|
|
}
|
|
|
|
static sk_sp<GrSurfaceProxy> make_texture(GrProxyProvider* provider,
|
|
SkISize dimensions,
|
|
GrColorType colorType,
|
|
GrRenderable renderable) {
|
|
return provider->testingOnly_createInstantiatedProxy(dimensions, colorType, renderable, 1,
|
|
SkBackingFit::kExact, SkBudgeted::kYes,
|
|
GrProtected::kNo);
|
|
}
|
|
|
|
// Test converting between RenderTargetProxies and TextureProxies for preinstantiated Proxies
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PreinstantiatedProxyConversionTest, reporter, ctxInfo) {
|
|
auto context = ctxInfo.directContext();
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
GrGpu* gpu = context->priv().getGpu();
|
|
|
|
static constexpr auto kSize = SkISize::Make(64, 64);
|
|
static constexpr auto kColorType = GrColorType::kRGBA_8888;
|
|
|
|
{
|
|
// External on-screen render target.
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
|
make_wrapped_rt(proxyProvider, gpu, reporter, kSize, kColorType));
|
|
if (sProxy) {
|
|
// RenderTarget-only
|
|
GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy();
|
|
REPORTER_ASSERT(reporter, rtProxy);
|
|
REPORTER_ASSERT(reporter, !rtProxy->asTextureProxy());
|
|
REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
|
|
clean_up_wrapped_rt(gpu, std::move(sProxy));
|
|
}
|
|
}
|
|
|
|
{
|
|
// Internal offscreen render target.
|
|
sk_sp<GrSurfaceProxy> sProxy(make_offscreen_rt(proxyProvider, kSize, kColorType));
|
|
if (sProxy) {
|
|
// Both RenderTarget and Texture
|
|
GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy();
|
|
REPORTER_ASSERT(reporter, rtProxy);
|
|
GrTextureProxy* tProxy = rtProxy->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
REPORTER_ASSERT(reporter, tProxy->asRenderTargetProxy() == rtProxy);
|
|
REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
|
|
}
|
|
}
|
|
|
|
{
|
|
// Internal offscreen render target - but through GrTextureProxy
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
|
make_texture(proxyProvider, kSize, kColorType, GrRenderable::kYes));
|
|
if (sProxy) {
|
|
// Both RenderTarget and Texture
|
|
GrTextureProxy* tProxy = sProxy->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
GrRenderTargetProxy* rtProxy = tProxy->asRenderTargetProxy();
|
|
REPORTER_ASSERT(reporter, rtProxy);
|
|
REPORTER_ASSERT(reporter, rtProxy->asTextureProxy() == tProxy);
|
|
REPORTER_ASSERT(reporter, tProxy->asTextureProxy() == tProxy);
|
|
}
|
|
}
|
|
|
|
{
|
|
// force no-RT
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
|
make_texture(proxyProvider, kSize, kColorType, GrRenderable::kNo));
|
|
if (sProxy) {
|
|
// Texture-only
|
|
GrTextureProxy* tProxy = sProxy->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
REPORTER_ASSERT(reporter, tProxy->asTextureProxy() == tProxy);
|
|
REPORTER_ASSERT(reporter, !tProxy->asRenderTargetProxy());
|
|
}
|
|
}
|
|
}
|
|
|
|
// Test converting between RenderTargetProxies and TextureProxies for deferred
|
|
// Proxies
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxInfo) {
|
|
auto context = ctxInfo.directContext();
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
const GrCaps* caps = context->priv().caps();
|
|
|
|
static constexpr SkISize kDims = {64, 64};
|
|
|
|
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
|
|
GrRenderable::kYes);
|
|
{
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
|
|
format, kDims, GrRenderable::kYes, 1, GrMipmapped::kNo, SkBackingFit::kApprox,
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
|
|
|
// Both RenderTarget and Texture
|
|
GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy();
|
|
REPORTER_ASSERT(reporter, rtProxy);
|
|
GrTextureProxy* tProxy = rtProxy->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
REPORTER_ASSERT(reporter, tProxy->asRenderTargetProxy() == rtProxy);
|
|
REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
|
|
}
|
|
|
|
{
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
|
|
format, kDims, GrRenderable::kYes, 1, GrMipmapped::kNo, SkBackingFit::kApprox,
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
|
|
|
// Both RenderTarget and Texture - but via GrTextureProxy
|
|
GrTextureProxy* tProxy = proxy->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
GrRenderTargetProxy* rtProxy = tProxy->asRenderTargetProxy();
|
|
REPORTER_ASSERT(reporter, rtProxy);
|
|
REPORTER_ASSERT(reporter, rtProxy->asTextureProxy() == tProxy);
|
|
REPORTER_ASSERT(reporter, tProxy->asTextureProxy() == tProxy);
|
|
}
|
|
|
|
{
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
|
|
format, kDims, GrRenderable::kNo, 1, GrMipmapped::kNo, SkBackingFit::kApprox,
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
|
// Texture-only
|
|
GrTextureProxy* tProxy = proxy->asTextureProxy();
|
|
REPORTER_ASSERT(reporter, tProxy);
|
|
REPORTER_ASSERT(reporter, tProxy->asTextureProxy() == tProxy);
|
|
REPORTER_ASSERT(reporter, !tProxy->asRenderTargetProxy());
|
|
}
|
|
}
|