本文整理汇总了C++中GrContext::priv方法的典型用法代码示例。如果您正苦于以下问题:C++ GrContext::priv方法的具体用法?C++ GrContext::priv怎么用?C++ GrContext::priv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrContext
的用法示例。
在下文中一共展示了GrContext::priv方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
GrResourceCache* cache = context->priv().getResourceCache();
REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
}
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
sk_sp<GrTexture> backingTex;
sk_sp<GrTextureProxy> proxy = create_wrapped_backend(context, fit, &backingTex);
basic_test(context, reporter, std::move(proxy));
backingTex = nullptr;
cache->purgeAllUnlocked();
}
invalidation_test(context, reporter);
invalidation_and_instantiation_test(context, reporter);
}
示例2: SkPaint
// Tests that MIP maps are created and invalidated as expected when drawing to and from GrTextures.
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTextureMipMapInvalidationTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
if (!context->priv().caps()->mipMapSupport()) {
return;
}
auto isMipped = [] (SkSurface* surf) {
const GrTexture* texture = surf->makeImageSnapshot()->getTexture();
return GrMipMapped::kYes == texture->texturePriv().mipMapped();
};
auto mipsAreDirty = [] (SkSurface* surf) {
return surf->makeImageSnapshot()->getTexture()->texturePriv().mipMapsAreDirty();
};
auto info = SkImageInfo::MakeN32Premul(256, 256);
for (auto allocateMips : {false, true}) {
auto surf1 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0,
kBottomLeft_GrSurfaceOrigin, nullptr,
allocateMips);
auto surf2 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
// Draw something just in case we ever had a solid color optimization
surf1->getCanvas()->drawCircle(128, 128, 50, SkPaint());
surf1->flush();
// No mipmaps initially
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
// Painting with downscale and medium filter quality should result in mipmap creation
// Flush the context rather than the canvas as flushing the canvas triggers MIP level
// generation.
SkPaint paint;
paint.setFilterQuality(kMedium_SkFilterQuality);
surf2->getCanvas()->scale(0.2f, 0.2f);
surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
context->flush();
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
REPORTER_ASSERT(reporter, !allocateMips || !mipsAreDirty(surf1.get()));
// Changing the contents of the surface should invalidate the mipmap, but not de-allocate
surf1->getCanvas()->drawCircle(128, 128, 100, SkPaint());
context->flush();
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
REPORTER_ASSERT(reporter, mipsAreDirty(surf1.get()));
}
}
示例3: sizeof
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
static const int kW = 10;
static const int kH = 10;
static const size_t kRowBytes = sizeof(uint32_t) * kW;
SkAutoTMalloc<uint32_t> srcPixels(kW * kH);
for (int i = 0; i < kW * kH; ++i) {
srcPixels.get()[i] = i;
}
SkAutoTMalloc<uint32_t> dstPixels(kW * kH);
for (int i = 0; i < kW * kH; ++i) {
dstPixels.get()[i] = ~i;
}
static const SkIRect kSrcRects[] {
{ 0, 0, kW , kH },
{-1, -1, kW+1, kH+1},
{ 1, 1, kW-1, kH-1},
{ 5, 5, 6 , 6 },
};
static const SkIPoint kDstPoints[] {
{ 0 , 0 },
{ 1 , 1 },
{ kW/2, kH/4},
{ kW-1, kH-1},
{ kW , kH },
{ kW+1, kH+2},
{-1 , -1 },
};
static const SkImageInfo kImageInfos[] {
SkImageInfo::Make(kW, kH, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
SkImageInfo::Make(kW, kH, kBGRA_8888_SkColorType, kPremul_SkAlphaType)
};
SkAutoTMalloc<uint32_t> read(kW * kH);
for (auto sOrigin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
for (auto dOrigin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
for (auto sRenderable : {GrRenderable::kYes, GrRenderable::kNo}) {
for (auto dRenderable : {GrRenderable::kYes, GrRenderable::kNo}) {
for (auto srcRect : kSrcRects) {
for (auto dstPoint : kDstPoints) {
for (auto ii: kImageInfos) {
auto src = sk_gpu_test::MakeTextureProxyFromData(
context, sRenderable, kW, kH, ii.colorType(), sOrigin,
srcPixels.get(), kRowBytes);
auto dst = sk_gpu_test::MakeTextureProxyFromData(
context, dRenderable, kW, kH, ii.colorType(), dOrigin,
dstPixels.get(), kRowBytes);
// Should always work if the color type is RGBA, but may not work
// for BGRA
if (ii.colorType() == kRGBA_8888_SkColorType) {
if (!src || !dst) {
ERRORF(reporter,
"Could not create surfaces for copy surface test.");
continue;
}
} else {
GrPixelConfig config =
SkColorType2GrPixelConfig(kBGRA_8888_SkColorType);
if (!context->priv().caps()->isConfigTexturable(config)) {
continue;
}
if (!src || !dst) {
ERRORF(reporter,
"Could not create surfaces for copy surface test.");
continue;
}
}
sk_sp<GrSurfaceContext> dstContext =
context->priv().makeWrappedSurfaceContext(std::move(dst));
bool result = dstContext->copy(src.get(), srcRect, dstPoint);
bool expectedResult = true;
SkIPoint dstOffset = { dstPoint.fX - srcRect.fLeft,
dstPoint.fY - srcRect.fTop };
SkIRect copiedDstRect = SkIRect::MakeXYWH(dstPoint.fX,
dstPoint.fY,
srcRect.width(),
srcRect.height());
SkIRect copiedSrcRect;
if (!copiedSrcRect.intersect(srcRect, SkIRect::MakeWH(kW, kH))) {
expectedResult = false;
} else {
// If the src rect was clipped, apply same clipping to each side
// of copied dst rect.
copiedDstRect.fLeft += copiedSrcRect.fLeft - srcRect.fLeft;
copiedDstRect.fTop += copiedSrcRect.fTop - srcRect.fTop;
copiedDstRect.fRight -= copiedSrcRect.fRight - srcRect.fRight;
copiedDstRect.fBottom -= copiedSrcRect.fBottom -
srcRect.fBottom;
}
//.........这里部分代码省略.........
示例4: backendRT
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->priv().proxyProvider();
GrContext* context = ctxInfo.grContext();
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
GrGpu* gpu = context->priv().getGpu();
const GrCaps& caps = *context->priv().caps();
static const int kWidthHeight = 100;
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
kRGBA_1010102_SkColorType }) {
// 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(
kWidthHeight, kWidthHeight, SkColorTypeToGrColorType(colorType));
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, origin, nullptr,
nullptr));
check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
backendRT.pixelConfig(), SkBudgeted::kNo);
static constexpr int kExpectedNumSamples = 1;
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
kExpectedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles());
gpu->deleteTestingOnlyBackendRenderTarget(backendRT);
}
for (auto numSamples : {1, 4}) {
GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
SkASSERT(kUnknown_GrPixelConfig != config);
int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
if (!supportedNumSamples) {
continue;
}
// Test wrapping FBO 0 (with made up properties). This tests sample count and the
// special case where FBO 0 doesn't support window rectangles.
if (GrBackendApi::kOpenGL == ctxInfo.backend()) {
GrGLFramebufferInfo fboInfo;
fboInfo.fFBOID = 0;
fboInfo.fFormat = GR_GL_RGBA8;
static constexpr int kStencilBits = 8;
GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
kStencilBits, fboInfo);
backendRT.setPixelConfig(config);
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, origin, nullptr,
nullptr));
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
backendRT.pixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0);
}
// Tests wrapBackendRenderTarget with a GrBackendTexture
{
GrBackendTexture backendTex =
context->createBackendTexture(kWidthHeight, kWidthHeight,
colorType,
GrMipMapped::kNo,
GrRenderable::kYes);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
backendTex, origin, supportedNumSamples);
if (!sProxy) {
context->deleteBackendTexture(backendTex);
continue; // This can fail on Mesa
}
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
backendTex.pixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles());
context->deleteBackendTexture(backendTex);
}
// Tests wrapBackendTexture that is only renderable
{
GrBackendTexture backendTex =
context->createBackendTexture(kWidthHeight, kWidthHeight,
colorType,
GrMipMapped::kNo,
GrRenderable::kYes);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
backendTex, origin, supportedNumSamples, kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, nullptr, nullptr);
if (!sProxy) {
context->deleteBackendTexture(backendTex);
continue; // This can fail on Mesa
//.........这里部分代码省略.........