1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2019 Google LLC 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "src/gpu/GrProgramInfo.h" 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ci#include "src/gpu/GrStencilSettings.h" 11cb93a386Sopenharmony_ci#include "src/gpu/effects/GrTextureEffect.h" 12cb93a386Sopenharmony_ci 13cb93a386Sopenharmony_ciGrStencilSettings GrProgramInfo::nonGLStencilSettings() const { 14cb93a386Sopenharmony_ci GrStencilSettings stencil; 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_ci if (this->isStencilEnabled()) { 17cb93a386Sopenharmony_ci stencil.reset(*fUserStencilSettings, this->pipeline().hasStencilClip(), 8); 18cb93a386Sopenharmony_ci } 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_ci return stencil; 21cb93a386Sopenharmony_ci} 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_ci#ifdef SK_DEBUG 24cb93a386Sopenharmony_ci#include "src/gpu/GrTexture.h" 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_civoid GrProgramInfo::validate(bool flushTime) const { 27cb93a386Sopenharmony_ci if (flushTime) { 28cb93a386Sopenharmony_ci SkASSERT(fPipeline->allProxiesInstantiated()); 29cb93a386Sopenharmony_ci } 30cb93a386Sopenharmony_ci} 31cb93a386Sopenharmony_ci 32cb93a386Sopenharmony_civoid GrProgramInfo::checkAllInstantiated() const { 33cb93a386Sopenharmony_ci this->pipeline().visitProxies([](GrSurfaceProxy* proxy, GrMipmapped) { 34cb93a386Sopenharmony_ci SkASSERT(proxy->isInstantiated()); 35cb93a386Sopenharmony_ci return true; 36cb93a386Sopenharmony_ci }); 37cb93a386Sopenharmony_ci} 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_civoid GrProgramInfo::checkMSAAAndMIPSAreResolved() const { 40cb93a386Sopenharmony_ci this->pipeline().visitTextureEffects([](const GrTextureEffect& te) { 41cb93a386Sopenharmony_ci GrTexture* tex = te.texture(); 42cb93a386Sopenharmony_ci SkASSERT(tex); 43cb93a386Sopenharmony_ci 44cb93a386Sopenharmony_ci // Ensure mipmaps were all resolved ahead of time by the DAG. 45cb93a386Sopenharmony_ci if (te.samplerState().mipmapped() == GrMipmapped::kYes && 46cb93a386Sopenharmony_ci (tex->width() != 1 || tex->height() != 1)) { 47cb93a386Sopenharmony_ci // There are some cases where we might be given a non-mipmapped texture with a 48cb93a386Sopenharmony_ci // mipmap filter. See skbug.com/7094. 49cb93a386Sopenharmony_ci SkASSERT(tex->mipmapped() != GrMipmapped::kYes || !tex->mipmapsAreDirty()); 50cb93a386Sopenharmony_ci } 51cb93a386Sopenharmony_ci }); 52cb93a386Sopenharmony_ci} 53cb93a386Sopenharmony_ci 54cb93a386Sopenharmony_ci#endif 55