2016-05-04 19:47:41 +00:00
|
|
|
/*
|
|
|
|
* 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 "Test.h"
|
|
|
|
|
2017-05-01 13:50:58 +00:00
|
|
|
#include "GrBackendSurface.h"
|
2018-01-08 18:40:32 +00:00
|
|
|
#include "GrContextPriv.h"
|
2018-01-16 13:06:32 +00:00
|
|
|
#include "GrProxyProvider.h"
|
2016-10-28 17:25:24 +00:00
|
|
|
#include "GrRenderTargetPriv.h"
|
2016-05-04 19:47:41 +00:00
|
|
|
#include "GrRenderTargetProxy.h"
|
2017-03-04 13:12:46 +00:00
|
|
|
#include "GrResourceProvider.h"
|
2018-03-16 20:47:25 +00:00
|
|
|
#include "GrSurfacePriv.h"
|
2017-08-31 12:56:07 +00:00
|
|
|
#include "GrSurfaceProxyPriv.h"
|
2017-06-13 16:44:56 +00:00
|
|
|
#include "GrTexture.h"
|
2017-03-04 13:12:46 +00:00
|
|
|
#include "GrTextureProxy.h"
|
2018-02-20 15:25:54 +00:00
|
|
|
#include "SkGr.h"
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-08-31 21:04:06 +00:00
|
|
|
// Check that the surface proxy's member vars are set as expected
|
2016-05-04 19:47:41 +00:00
|
|
|
static void check_surface(skiatest::Reporter* reporter,
|
|
|
|
GrSurfaceProxy* proxy,
|
|
|
|
GrSurfaceOrigin origin,
|
2017-05-01 13:50:58 +00:00
|
|
|
int width, int height,
|
2016-08-31 21:04:06 +00:00
|
|
|
GrPixelConfig config,
|
2016-11-02 14:23:32 +00:00
|
|
|
SkBudgeted budgeted) {
|
2016-05-04 19:47:41 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxy->origin() == origin);
|
|
|
|
REPORTER_ASSERT(reporter, proxy->width() == width);
|
|
|
|
REPORTER_ASSERT(reporter, proxy->height() == height);
|
|
|
|
REPORTER_ASSERT(reporter, proxy->config() == config);
|
2018-01-16 13:06:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
|
2016-11-02 14:23:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_rendertarget(skiatest::Reporter* reporter,
|
2016-11-09 13:54:35 +00:00
|
|
|
const GrCaps& caps,
|
2017-03-04 13:12:46 +00:00
|
|
|
GrResourceProvider* provider,
|
2016-05-04 19:47:41 +00:00
|
|
|
GrRenderTargetProxy* rtProxy,
|
2016-11-02 14:23:32 +00:00
|
|
|
int numSamples,
|
2016-11-09 13:54:35 +00:00
|
|
|
SkBackingFit fit,
|
2018-02-20 15:25:54 +00:00
|
|
|
int expectedMaxWindowRects) {
|
2016-11-09 13:54:35 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
|
2016-11-02 14:23:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
|
|
|
|
|
2016-11-11 17:38:40 +00:00
|
|
|
GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
|
2018-07-31 21:25:29 +00:00
|
|
|
bool preinstantiated = rtProxy->isInstantiated();
|
2017-06-05 13:26:07 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->instantiate(provider));
|
2018-07-31 21:25:29 +00:00
|
|
|
GrRenderTarget* rt = rtProxy->peekRenderTarget();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-11-11 17:38:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
|
2018-02-20 15:25:54 +00:00
|
|
|
// Deferred resources should always have a different ID from their instantiated rendertarget
|
2018-03-08 15:13:17 +00:00
|
|
|
if (preinstantiated) {
|
|
|
|
REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
|
|
|
|
}
|
2016-11-11 17:38:40 +00:00
|
|
|
|
2016-05-04 19:47:41 +00:00
|
|
|
if (SkBackingFit::kExact == fit) {
|
|
|
|
REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
|
|
|
|
REPORTER_ASSERT(reporter, rt->height() == rtProxy->height());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
|
2016-11-11 17:38:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
|
|
|
|
|
2017-05-12 15:36:10 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->fsaaType() == rtProxy->fsaaType());
|
2016-05-04 19:47:41 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples());
|
|
|
|
REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamples());
|
2018-03-16 20:47:25 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->surfacePriv().flags() == rtProxy->testingOnly_getFlags());
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_texture(skiatest::Reporter* reporter,
|
2017-03-04 13:12:46 +00:00
|
|
|
GrResourceProvider* provider,
|
2016-05-04 19:47:41 +00:00
|
|
|
GrTextureProxy* texProxy,
|
2018-02-20 15:25:54 +00:00
|
|
|
SkBackingFit fit) {
|
2016-11-11 17:38:40 +00:00
|
|
|
GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
|
2017-06-05 13:26:07 +00:00
|
|
|
|
2018-07-31 21:25:29 +00:00
|
|
|
bool preinstantiated = texProxy->isInstantiated();
|
2017-06-05 13:26:07 +00:00
|
|
|
REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
|
2018-07-31 21:25:29 +00:00
|
|
|
GrTexture* tex = texProxy->peekTexture();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-11-11 17:38:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
|
2018-02-20 15:25:54 +00:00
|
|
|
// Deferred resources should always have a different ID from their instantiated texture
|
2018-03-08 15:13:17 +00:00
|
|
|
if (preinstantiated) {
|
|
|
|
REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
|
|
|
|
}
|
2016-11-11 17:38:40 +00:00
|
|
|
|
2016-05-04 19:47:41 +00:00
|
|
|
if (SkBackingFit::kExact == fit) {
|
|
|
|
REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
|
|
|
|
REPORTER_ASSERT(reporter, tex->height() == texProxy->height());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, tex->width() >= texProxy->width());
|
|
|
|
REPORTER_ASSERT(reporter, tex->height() >= texProxy->height());
|
|
|
|
}
|
|
|
|
REPORTER_ASSERT(reporter, tex->config() == texProxy->config());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-31 21:04:06 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
|
2018-01-08 18:40:32 +00:00
|
|
|
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
|
2018-01-16 20:07:54 +00:00
|
|
|
GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
|
2018-05-11 14:14:21 +00:00
|
|
|
const GrCaps& caps = *ctxInfo.grContext()->contextPriv().caps();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-02-01 14:20:00 +00:00
|
|
|
int attempt = 0; // useful for debugging
|
|
|
|
|
2016-05-04 19:47:41 +00:00
|
|
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
2017-01-30 19:15:59 +00:00
|
|
|
for (auto widthHeight : { 100, 128, 1048576 }) {
|
2017-02-01 14:20:00 +00:00
|
|
|
for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
|
2018-03-02 16:01:10 +00:00
|
|
|
kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
|
2016-05-04 19:47:41 +00:00
|
|
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
|
|
|
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
|
2018-02-03 01:32:49 +00:00
|
|
|
for (auto numSamples : {1, 4, 16, 128}) {
|
2016-05-04 19:47:41 +00:00
|
|
|
GrSurfaceDesc desc;
|
2016-11-04 15:59:10 +00:00
|
|
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
2016-05-04 19:47:41 +00:00
|
|
|
desc.fWidth = widthHeight;
|
|
|
|
desc.fHeight = widthHeight;
|
|
|
|
desc.fConfig = config;
|
|
|
|
desc.fSampleCnt = numSamples;
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
GrSRGBEncoded srgbEncoded;
|
|
|
|
GrColorType colorType =
|
|
|
|
GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
|
|
|
|
const GrBackendFormat format =
|
|
|
|
caps.getBackendFormatFromGrColorType(colorType, srgbEncoded);
|
|
|
|
|
2017-02-01 14:20:00 +00:00
|
|
|
{
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
2018-09-27 15:28:03 +00:00
|
|
|
tex = resourceProvider->createApproxTexture(
|
|
|
|
desc, GrResourceProvider::Flags::kNone);
|
2017-02-01 14:20:00 +00:00
|
|
|
} else {
|
2018-01-08 18:40:32 +00:00
|
|
|
tex = resourceProvider->createTexture(desc, budgeted);
|
2017-02-01 14:20:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 03:43:43 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy =
|
2018-11-16 20:43:41 +00:00
|
|
|
proxyProvider->createProxy(format, desc, origin, fit,
|
|
|
|
budgeted);
|
2017-03-02 23:18:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
|
|
|
|
if (proxy) {
|
|
|
|
REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
|
2017-01-30 19:15:59 +00:00
|
|
|
// This forces the proxy to compute and cache its
|
|
|
|
// pre-instantiation size guess. Later, when it is actually
|
|
|
|
// instantiated, it checks that the instantiated size is <= to
|
|
|
|
// the pre-computation. If the proxy never computed its
|
|
|
|
// pre-instantiation size then the check is skipped.
|
2017-03-02 23:18:38 +00:00
|
|
|
proxy->gpuMemorySize();
|
2017-01-30 19:15:59 +00:00
|
|
|
|
2017-03-02 23:18:38 +00:00
|
|
|
check_surface(reporter, proxy.get(), origin,
|
2018-01-16 13:06:32 +00:00
|
|
|
widthHeight, widthHeight, config, budgeted);
|
2018-02-03 01:32:49 +00:00
|
|
|
int supportedSamples =
|
|
|
|
caps.getRenderTargetSampleCount(numSamples, config);
|
2018-01-08 18:40:32 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
2017-03-02 23:18:38 +00:00
|
|
|
proxy->asRenderTargetProxy(),
|
2017-07-19 18:47:42 +00:00
|
|
|
supportedSamples,
|
2018-02-20 15:25:54 +00:00
|
|
|
fit, caps.maxWindowRectangles());
|
2017-01-30 19:15:59 +00:00
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
desc.fFlags = kNone_GrSurfaceFlags;
|
2017-02-01 14:20:00 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
2018-09-27 15:28:03 +00:00
|
|
|
tex = resourceProvider->createApproxTexture(
|
|
|
|
desc, GrResourceProvider::Flags::kNone);
|
2017-02-01 14:20:00 +00:00
|
|
|
} else {
|
2018-01-08 18:40:32 +00:00
|
|
|
tex = resourceProvider->createTexture(desc, budgeted);
|
2017-02-01 14:20:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 03:43:43 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy(
|
2018-11-16 20:43:41 +00:00
|
|
|
proxyProvider->createProxy(format, desc, origin, fit,
|
|
|
|
budgeted));
|
2017-03-02 23:18:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
|
|
|
|
if (proxy) {
|
2018-01-08 18:40:32 +00:00
|
|
|
// This forces the proxy to compute and cache its
|
|
|
|
// pre-instantiation size guess. Later, when it is actually
|
|
|
|
// instantiated, it checks that the instantiated size is <= to
|
|
|
|
// the pre-computation. If the proxy never computed its
|
|
|
|
// pre-instantiation size then the check is skipped.
|
2017-03-02 23:18:38 +00:00
|
|
|
proxy->gpuMemorySize();
|
2017-02-01 14:20:00 +00:00
|
|
|
|
2017-03-02 23:18:38 +00:00
|
|
|
check_surface(reporter, proxy.get(), origin,
|
2018-01-16 13:06:32 +00:00
|
|
|
widthHeight, widthHeight, config, budgeted);
|
2018-01-08 18:40:32 +00:00
|
|
|
check_texture(reporter, resourceProvider,
|
2018-02-20 15:25:54 +00:00
|
|
|
proxy->asTextureProxy(), fit);
|
2017-02-01 14:20:00 +00:00
|
|
|
}
|
2017-01-30 19:15:59 +00:00
|
|
|
}
|
2017-02-01 14:20:00 +00:00
|
|
|
|
|
|
|
attempt++;
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
2018-01-16 13:06:32 +00:00
|
|
|
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
|
2018-01-16 20:07:54 +00:00
|
|
|
GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
|
2018-02-20 15:25:54 +00:00
|
|
|
GrGpu* gpu = ctxInfo.grContext()->contextPriv().getGpu();
|
2018-05-11 14:14:21 +00:00
|
|
|
const GrCaps& caps = *ctxInfo.grContext()->contextPriv().caps();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
static const int kWidthHeight = 100;
|
|
|
|
|
|
|
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
2018-03-02 16:01:10 +00:00
|
|
|
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
|
|
|
|
kRGBA_1010102_SkColorType }) {
|
2018-03-13 13:32:39 +00:00
|
|
|
// External on-screen render target.
|
|
|
|
// Tests wrapBackendRenderTarget with a GrBackendRenderTarget
|
|
|
|
// Our test-only function that creates a backend render target doesn't currently support
|
|
|
|
// sample counts :(.
|
|
|
|
if (ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType)) {
|
|
|
|
GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
|
2018-08-09 14:55:09 +00:00
|
|
|
kWidthHeight, kWidthHeight, SkColorTypeToGrColorType(colorType));
|
2018-03-13 13:32:39 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
|
|
|
proxyProvider->wrapBackendRenderTarget(backendRT, origin));
|
|
|
|
check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
|
2018-07-03 20:18:29 +00:00
|
|
|
backendRT.pixelConfig(), SkBudgeted::kNo);
|
2018-03-13 13:32:39 +00:00
|
|
|
static constexpr int kExpectedNumSamples = 1;
|
|
|
|
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
|
|
|
|
kExpectedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
|
|
|
gpu->deleteTestingOnlyBackendRenderTarget(backendRT);
|
|
|
|
}
|
|
|
|
|
2018-02-20 15:25:54 +00:00
|
|
|
for (auto numSamples : {1, 4}) {
|
Dest color space no longer impacts mipmaps or texture sampling
PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap
mode on GrTexture, sRGB decode state per-texture. Because we
were often choosing sRGB configs for RGB color types, legacy
rendering would then be incorrect (too dark). So...
PS7: Stops ever using sRGB pixel configs when translating
image info or color type. Also removes a bunch of GrCaps bits
and a GrContextOption that are no longer relevant.
PS9: Adjusts surface creation unit test expectations, and
changes the raster rules accordingly.
At this point, sRGB configs are (obviously) going to be broken.
Locally, I ran 8888, gl, and the gbr- versions of both. Across
all GMs x configs, there are 13 diffs. 12 are GMs that create
surfaces with a color-space attached (and thus, the offscreen
is no longer getting sRGB pixel config). The only remainder
constructs an SkPictureImageGenerator, (with an attached color
space) and renders it to the gbr-gl canvas, which triggers a
a tagged surface inside the generator.
Bug: skia:
Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789
Reviewed-on: https://skia-review.googlesource.com/131282
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-06-01 16:25:08 +00:00
|
|
|
GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
|
2018-02-21 18:02:32 +00:00
|
|
|
SkASSERT(kUnknown_GrPixelConfig != config);
|
2018-02-20 15:25:54 +00:00
|
|
|
int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
|
2016-08-10 18:09:07 +00:00
|
|
|
|
2018-02-20 15:25:54 +00:00
|
|
|
if (!supportedNumSamples) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-01-16 13:06:32 +00:00
|
|
|
|
2018-03-13 13:32:39 +00:00
|
|
|
// Test wrapping FBO 0 (with made up properties). This tests sample count and the
|
|
|
|
// special case where FBO 0 doesn't support window rectangles.
|
2018-10-12 13:31:11 +00:00
|
|
|
if (GrBackendApi::kOpenGL == ctxInfo.backend()) {
|
2018-02-20 15:25:54 +00:00
|
|
|
GrGLFramebufferInfo fboInfo;
|
|
|
|
fboInfo.fFBOID = 0;
|
2018-03-13 13:32:39 +00:00
|
|
|
static constexpr int kStencilBits = 8;
|
|
|
|
GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
|
2018-07-03 20:18:29 +00:00
|
|
|
kStencilBits, fboInfo);
|
|
|
|
backendRT.setPixelConfig(config);
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
|
|
|
proxyProvider->wrapBackendRenderTarget(backendRT, origin));
|
2018-02-20 15:25:54 +00:00
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
|
|
|
kWidthHeight, kWidthHeight,
|
2018-07-03 20:18:29 +00:00
|
|
|
backendRT.pixelConfig(), SkBudgeted::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact, 0);
|
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
// Tests wrapBackendRenderTarget with a GrBackendTexture
|
2018-02-21 16:36:53 +00:00
|
|
|
{
|
|
|
|
GrBackendTexture backendTex =
|
|
|
|
gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
|
Dest color space no longer impacts mipmaps or texture sampling
PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap
mode on GrTexture, sRGB decode state per-texture. Because we
were often choosing sRGB configs for RGB color types, legacy
rendering would then be incorrect (too dark). So...
PS7: Stops ever using sRGB pixel configs when translating
image info or color type. Also removes a bunch of GrCaps bits
and a GrContextOption that are no longer relevant.
PS9: Adjusts surface creation unit test expectations, and
changes the raster rules accordingly.
At this point, sRGB configs are (obviously) going to be broken.
Locally, I ran 8888, gl, and the gbr- versions of both. Across
all GMs x configs, there are 13 diffs. 12 are GMs that create
surfaces with a color-space attached (and thus, the offscreen
is no longer getting sRGB pixel config). The only remainder
constructs an SkPictureImageGenerator, (with an attached color
space) and renders it to the gbr-gl canvas, which triggers a
a tagged surface inside the generator.
Bug: skia:
Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789
Reviewed-on: https://skia-review.googlesource.com/131282
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-06-01 16:25:08 +00:00
|
|
|
kWidthHeight, colorType,
|
2018-04-19 14:28:37 +00:00
|
|
|
true, GrMipMapped::kNo);
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
|
|
|
|
backendTex, origin, supportedNumSamples);
|
2018-02-21 16:36:53 +00:00
|
|
|
if (!sProxy) {
|
2018-03-09 14:33:19 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
2018-02-21 16:36:53 +00:00
|
|
|
continue; // This can fail on Mesa
|
|
|
|
}
|
|
|
|
|
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
|
|
|
kWidthHeight, kWidthHeight,
|
2018-07-03 20:18:29 +00:00
|
|
|
backendTex.pixelConfig(), SkBudgeted::kNo);
|
2018-02-21 16:36:53 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
|
|
|
|
2018-03-09 14:33:19 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
2018-02-21 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
// Tests wrapBackendTexture that is only renderable
|
2018-02-20 15:25:54 +00:00
|
|
|
{
|
|
|
|
GrBackendTexture backendTex =
|
|
|
|
gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
|
Dest color space no longer impacts mipmaps or texture sampling
PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap
mode on GrTexture, sRGB decode state per-texture. Because we
were often choosing sRGB configs for RGB color types, legacy
rendering would then be incorrect (too dark). So...
PS7: Stops ever using sRGB pixel configs when translating
image info or color type. Also removes a bunch of GrCaps bits
and a GrContextOption that are no longer relevant.
PS9: Adjusts surface creation unit test expectations, and
changes the raster rules accordingly.
At this point, sRGB configs are (obviously) going to be broken.
Locally, I ran 8888, gl, and the gbr- versions of both. Across
all GMs x configs, there are 13 diffs. 12 are GMs that create
surfaces with a color-space attached (and thus, the offscreen
is no longer getting sRGB pixel config). The only remainder
constructs an SkPictureImageGenerator, (with an attached color
space) and renders it to the gbr-gl canvas, which triggers a
a tagged surface inside the generator.
Bug: skia:
Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789
Reviewed-on: https://skia-review.googlesource.com/131282
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-06-01 16:25:08 +00:00
|
|
|
kWidthHeight, colorType,
|
2018-04-19 14:28:37 +00:00
|
|
|
true, GrMipMapped::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
|
|
|
|
backendTex, origin, supportedNumSamples);
|
2018-02-20 15:25:54 +00:00
|
|
|
if (!sProxy) {
|
2018-03-09 14:33:19 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
2018-02-20 15:25:54 +00:00
|
|
|
continue; // This can fail on Mesa
|
|
|
|
}
|
|
|
|
|
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
|
|
|
kWidthHeight, kWidthHeight,
|
2018-07-03 20:18:29 +00:00
|
|
|
backendTex.pixelConfig(), SkBudgeted::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
2018-01-16 13:06:32 +00:00
|
|
|
|
2018-03-09 14:33:19 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
2018-02-20 15:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
// Tests wrapBackendTexture that is only textureable
|
2018-02-20 15:25:54 +00:00
|
|
|
{
|
|
|
|
// Internal offscreen texture
|
|
|
|
GrBackendTexture backendTex =
|
|
|
|
gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
|
Dest color space no longer impacts mipmaps or texture sampling
PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap
mode on GrTexture, sRGB decode state per-texture. Because we
were often choosing sRGB configs for RGB color types, legacy
rendering would then be incorrect (too dark). So...
PS7: Stops ever using sRGB pixel configs when translating
image info or color type. Also removes a bunch of GrCaps bits
and a GrContextOption that are no longer relevant.
PS9: Adjusts surface creation unit test expectations, and
changes the raster rules accordingly.
At this point, sRGB configs are (obviously) going to be broken.
Locally, I ran 8888, gl, and the gbr- versions of both. Across
all GMs x configs, there are 13 diffs. 12 are GMs that create
surfaces with a color-space attached (and thus, the offscreen
is no longer getting sRGB pixel config). The only remainder
constructs an SkPictureImageGenerator, (with an attached color
space) and renders it to the gbr-gl canvas, which triggers a
a tagged surface inside the generator.
Bug: skia:
Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789
Reviewed-on: https://skia-review.googlesource.com/131282
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-06-01 16:25:08 +00:00
|
|
|
kWidthHeight, colorType,
|
2018-04-19 14:28:37 +00:00
|
|
|
false, GrMipMapped::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
|
2018-12-06 15:00:03 +00:00
|
|
|
backendTex, origin, kBorrow_GrWrapOwnership, kRead_GrIOType);
|
2018-02-20 15:25:54 +00:00
|
|
|
if (!sProxy) {
|
2018-03-09 14:33:19 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
2018-02-20 15:25:54 +00:00
|
|
|
continue;
|
2018-01-16 13:06:32 +00:00
|
|
|
}
|
2018-02-20 15:25:54 +00:00
|
|
|
|
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
|
|
|
kWidthHeight, kWidthHeight,
|
2018-07-03 20:18:29 +00:00
|
|
|
backendTex.pixelConfig(), SkBudgeted::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
|
|
|
|
SkBackingFit::kExact);
|
|
|
|
|
2018-03-09 14:33:19 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 11:44:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
|
2018-01-08 18:40:32 +00:00
|
|
|
GrProxyProvider* provider = ctxInfo.grContext()->contextPriv().proxyProvider();
|
2017-04-26 11:44:26 +00:00
|
|
|
|
|
|
|
for (auto flags : { kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags }) {
|
|
|
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
|
|
|
for (int width : { 0, 100 }) {
|
|
|
|
for (int height : { 0, 100}) {
|
|
|
|
if (width && height) {
|
|
|
|
continue; // not zero-sized
|
|
|
|
}
|
|
|
|
|
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fFlags = flags;
|
|
|
|
desc.fWidth = width;
|
|
|
|
desc.fHeight = height;
|
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
2018-02-03 01:32:49 +00:00
|
|
|
desc.fSampleCnt = 1;
|
2017-04-26 11:44:26 +00:00
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
const GrBackendFormat format =
|
|
|
|
ctxInfo.grContext()->contextPriv().caps()->getBackendFormatFromColorType(
|
|
|
|
kRGBA_8888_SkColorType);
|
|
|
|
|
2018-03-04 03:43:43 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = provider->createProxy(
|
2018-11-16 20:43:41 +00:00
|
|
|
format, desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kNo);
|
2017-04-26 11:44:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|