b7b7e5fba0
This CL fixes: isConfigTexturable was returning true for: kRG_float for ANGLE ES2 configs isConfigRenderable was returning true for: kAlpha_8 for ANGLE ES2 configs isConfigTexturable and isConfigRenderable were returning true for: SBGRA on ES2 The NexusPlayer was marking RGBA & RG float configs as renderable but not textureable Bug: 720325 Change-Id: If21361870dbdde8f3e09bc9dff3a394f2a329157 Reviewed-on: https://skia-review.googlesource.com/17387 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
127 lines
5.2 KiB
C++
127 lines
5.2 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SkTypes.h"
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContext.h"
|
|
#include "GrContextPriv.h"
|
|
#include "GrGpu.h"
|
|
#include "GrRenderTarget.h"
|
|
#include "GrResourceProvider.h"
|
|
#include "GrTest.h"
|
|
#include "GrTexture.h"
|
|
#include "GrSurfacePriv.h"
|
|
#include "Test.h"
|
|
|
|
// Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static upcasting of texture
|
|
// and render targets to GrSurface all work as expected.
|
|
DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
|
GrContext* context = ctxInfo.grContext();
|
|
GrSurfaceDesc desc;
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
|
desc.fWidth = 256;
|
|
desc.fHeight = 256;
|
|
desc.fSampleCnt = 0;
|
|
sk_sp<GrSurface> texRT1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
|
|
|
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
|
|
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture());
|
|
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()));
|
|
|
|
desc.fFlags = kNone_GrSurfaceFlags;
|
|
sk_sp<GrTexture> tex1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
|
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
|
|
REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
|
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
|
|
|
|
GrBackendObject backendTexHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
|
nullptr, 256, 256, kRGBA_8888_GrPixelConfig);
|
|
GrBackendTexture backendTex = GrTest::CreateBackendTexture(context->contextPriv().getBackend(),
|
|
256,
|
|
256,
|
|
kRGBA_8888_GrPixelConfig,
|
|
backendTexHandle);
|
|
|
|
sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapBackendTexture(
|
|
backendTex, kTopLeft_GrSurfaceOrigin, kRenderTarget_GrBackendTextureFlag, 0,
|
|
kBorrow_GrWrapOwnership);
|
|
|
|
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
|
|
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
|
|
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()));
|
|
|
|
context->getGpu()->deleteTestingOnlyBackendTexture(backendTexHandle);
|
|
}
|
|
|
|
#if 0
|
|
// 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();
|
|
const GrCaps* caps = context->caps();
|
|
|
|
GrPixelConfig configs[] = {
|
|
kUnknown_GrPixelConfig,
|
|
kAlpha_8_GrPixelConfig,
|
|
kGray_8_GrPixelConfig,
|
|
kRGB_565_GrPixelConfig,
|
|
kRGBA_4444_GrPixelConfig,
|
|
kRGBA_8888_GrPixelConfig,
|
|
kBGRA_8888_GrPixelConfig,
|
|
kSRGBA_8888_GrPixelConfig,
|
|
kSBGRA_8888_GrPixelConfig,
|
|
kRGBA_8888_sint_GrPixelConfig,
|
|
kETC1_GrPixelConfig,
|
|
kRGBA_float_GrPixelConfig,
|
|
kRG_float_GrPixelConfig,
|
|
kAlpha_half_GrPixelConfig,
|
|
kRGBA_half_GrPixelConfig,
|
|
};
|
|
SkASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));
|
|
|
|
GrSurfaceDesc desc;
|
|
desc.fWidth = 64;
|
|
desc.fHeight = 64;
|
|
|
|
for (GrPixelConfig config : configs) {
|
|
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
|
desc.fFlags = kNone_GrSurfaceFlags;
|
|
desc.fOrigin = origin;
|
|
desc.fSampleCnt = 0;
|
|
desc.fConfig = config;
|
|
|
|
sk_sp<GrSurface> tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
|
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigTexturable(desc.fConfig,
|
|
desc.fOrigin));
|
|
|
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
|
tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
|
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false));
|
|
|
|
desc.fSampleCnt = 4;
|
|
tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
|
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, true));
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#endif
|