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