LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu - GrCaps.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 142 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2015 Google Inc.
       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 "GrCaps.h"
       9             : #include "GrContextOptions.h"
      10             : #include "GrWindowRectangles.h"
      11             : 
      12           0 : static const char* pixel_config_name(GrPixelConfig config) {
      13           0 :     switch (config) {
      14           0 :         case kUnknown_GrPixelConfig: return "Unknown";
      15           0 :         case kAlpha_8_GrPixelConfig: return "Alpha8";
      16           0 :         case kGray_8_GrPixelConfig: return "Gray8";
      17           0 :         case kRGB_565_GrPixelConfig: return "RGB565";
      18           0 :         case kRGBA_4444_GrPixelConfig: return "RGBA444";
      19           0 :         case kRGBA_8888_GrPixelConfig: return "RGBA8888";
      20           0 :         case kBGRA_8888_GrPixelConfig: return "BGRA8888";
      21           0 :         case kSRGBA_8888_GrPixelConfig: return "SRGBA8888";
      22           0 :         case kSBGRA_8888_GrPixelConfig: return "SBGRA8888";
      23           0 :         case kRGBA_8888_sint_GrPixelConfig: return "RGBA8888_sint";
      24           0 :         case kETC1_GrPixelConfig: return "ETC1";
      25           0 :         case kRGBA_float_GrPixelConfig: return "RGBAFloat";
      26           0 :         case kRG_float_GrPixelConfig: return "RGFloat";
      27           0 :         case kAlpha_half_GrPixelConfig: return "AlphaHalf";
      28           0 :         case kRGBA_half_GrPixelConfig: return "RGBAHalf";
      29             :     }
      30           0 :     SkFAIL("Invalid pixel config");
      31           0 :     return "<invalid>";
      32             : }
      33             : 
      34           0 : GrCaps::GrCaps(const GrContextOptions& options) {
      35           0 :     fMipMapSupport = false;
      36           0 :     fNPOTTextureTileSupport = false;
      37           0 :     fSRGBSupport = false;
      38           0 :     fSRGBWriteControl = false;
      39           0 :     fTwoSidedStencilSupport = false;
      40           0 :     fStencilWrapOpsSupport = false;
      41           0 :     fDiscardRenderTargetSupport = false;
      42           0 :     fReuseScratchTextures = true;
      43           0 :     fReuseScratchBuffers = true;
      44           0 :     fGpuTracingSupport = false;
      45           0 :     fCompressedTexSubImageSupport = false;
      46           0 :     fOversizedStencilSupport = false;
      47           0 :     fTextureBarrierSupport = false;
      48           0 :     fSampleLocationsSupport = false;
      49           0 :     fMultisampleDisableSupport = false;
      50           0 :     fUsesMixedSamples = false;
      51           0 :     fPreferClientSideDynamicBuffers = false;
      52           0 :     fFullClearIsFree = false;
      53           0 :     fMustClearUploadedBufferData = false;
      54           0 :     fSampleShadingSupport = false;
      55           0 :     fFenceSyncSupport = false;
      56           0 :     fCrossContextTextureSupport = false;
      57             : 
      58           0 :     fUseDrawInsteadOfClear = false;
      59             : 
      60           0 :     fInstancedSupport = InstancedSupport::kNone;
      61             : 
      62           0 :     fBlendEquationSupport = kBasic_BlendEquationSupport;
      63           0 :     fAdvBlendEqBlacklist = 0;
      64             : 
      65           0 :     fMapBufferFlags = kNone_MapFlags;
      66             : 
      67           0 :     fMaxVertexAttributes = 0;
      68           0 :     fMaxRenderTargetSize = 1;
      69           0 :     fMaxTextureSize = 1;
      70           0 :     fMaxColorSampleCount = 0;
      71           0 :     fMaxStencilSampleCount = 0;
      72           0 :     fMaxRasterSamples = 0;
      73           0 :     fMaxWindowRectangles = 0;
      74             : 
      75           0 :     fSuppressPrints = options.fSuppressPrints;
      76           0 :     fImmediateFlush = options.fImmediateMode;
      77           0 :     fBufferMapThreshold = options.fBufferMapThreshold;
      78           0 :     fUseDrawInsteadOfPartialRenderTargetWrite = options.fUseDrawInsteadOfPartialRenderTargetWrite;
      79           0 :     fUseDrawInsteadOfAllRenderTargetWrites = false;
      80           0 :     fAvoidInstancedDrawsToFPTargets = false;
      81             : 
      82           0 :     fPreferVRAMUseOverFlushes = true;
      83           0 : }
      84             : 
      85           0 : void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
      86           0 :     this->onApplyOptionsOverrides(options);
      87           0 :     fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride);
      88             :     // If the max tile override is zero, it means we should use the max texture size.
      89           0 :     if (!options.fMaxTileSizeOverride || options.fMaxTileSizeOverride > fMaxTextureSize) {
      90           0 :         fMaxTileSize = fMaxTextureSize;
      91             :     } else {
      92           0 :         fMaxTileSize = options.fMaxTileSizeOverride;
      93             :     }
      94           0 :     if (fMaxWindowRectangles > GrWindowRectangles::kMaxWindows) {
      95           0 :         SkDebugf("WARNING: capping window rectangles at %i. HW advertises support for %i.\n",
      96           0 :                  GrWindowRectangles::kMaxWindows, fMaxWindowRectangles);
      97           0 :         fMaxWindowRectangles = GrWindowRectangles::kMaxWindows;
      98             :     }
      99           0 : }
     100             : 
     101           0 : static SkString map_flags_to_string(uint32_t flags) {
     102           0 :     SkString str;
     103           0 :     if (GrCaps::kNone_MapFlags == flags) {
     104           0 :         str = "none";
     105             :     } else {
     106           0 :         SkASSERT(GrCaps::kCanMap_MapFlag & flags);
     107           0 :         SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag);
     108           0 :         str = "can_map";
     109             : 
     110           0 :         if (GrCaps::kSubset_MapFlag & flags) {
     111           0 :             str.append(" partial");
     112             :         } else {
     113           0 :             str.append(" full");
     114             :         }
     115           0 :         SkDEBUGCODE(flags &= ~GrCaps::kSubset_MapFlag);
     116             :     }
     117           0 :     SkASSERT(0 == flags); // Make sure we handled all the flags.
     118           0 :     return str;
     119             : }
     120             : 
     121           0 : SkString GrCaps::dump() const {
     122           0 :     SkString r;
     123             :     static const char* gNY[] = {"NO", "YES"};
     124           0 :     r.appendf("MIP Map Support                    : %s\n", gNY[fMipMapSupport]);
     125           0 :     r.appendf("NPOT Texture Tile Support          : %s\n", gNY[fNPOTTextureTileSupport]);
     126           0 :     r.appendf("sRGB Support                       : %s\n", gNY[fSRGBSupport]);
     127           0 :     r.appendf("sRGB Write Control                 : %s\n", gNY[fSRGBWriteControl]);
     128           0 :     r.appendf("Two Sided Stencil Support          : %s\n", gNY[fTwoSidedStencilSupport]);
     129           0 :     r.appendf("Stencil Wrap Ops  Support          : %s\n", gNY[fStencilWrapOpsSupport]);
     130           0 :     r.appendf("Discard Render Target Support      : %s\n", gNY[fDiscardRenderTargetSupport]);
     131           0 :     r.appendf("Reuse Scratch Textures             : %s\n", gNY[fReuseScratchTextures]);
     132           0 :     r.appendf("Reuse Scratch Buffers              : %s\n", gNY[fReuseScratchBuffers]);
     133           0 :     r.appendf("Gpu Tracing Support                : %s\n", gNY[fGpuTracingSupport]);
     134           0 :     r.appendf("Compressed Update Support          : %s\n", gNY[fCompressedTexSubImageSupport]);
     135           0 :     r.appendf("Oversized Stencil Support          : %s\n", gNY[fOversizedStencilSupport]);
     136           0 :     r.appendf("Texture Barrier Support            : %s\n", gNY[fTextureBarrierSupport]);
     137           0 :     r.appendf("Sample Locations Support           : %s\n", gNY[fSampleLocationsSupport]);
     138           0 :     r.appendf("Multisample disable support        : %s\n", gNY[fMultisampleDisableSupport]);
     139           0 :     r.appendf("Uses Mixed Samples                 : %s\n", gNY[fUsesMixedSamples]);
     140           0 :     r.appendf("Prefer client-side dynamic buffers : %s\n", gNY[fPreferClientSideDynamicBuffers]);
     141           0 :     r.appendf("Full screen clear is free          : %s\n", gNY[fFullClearIsFree]);
     142           0 :     r.appendf("Must clear buffer memory           : %s\n", gNY[fMustClearUploadedBufferData]);
     143           0 :     r.appendf("Sample shading support             : %s\n", gNY[fSampleShadingSupport]);
     144           0 :     r.appendf("Fence sync support                 : %s\n", gNY[fFenceSyncSupport]);
     145           0 :     r.appendf("Cross context texture support      : %s\n", gNY[fCrossContextTextureSupport]);
     146             : 
     147           0 :     r.appendf("Draw Instead of Clear [workaround] : %s\n", gNY[fUseDrawInsteadOfClear]);
     148           0 :     r.appendf("Draw Instead of TexSubImage [workaround] : %s\n",
     149           0 :               gNY[fUseDrawInsteadOfPartialRenderTargetWrite]);
     150           0 :     r.appendf("Prefer VRAM Use over flushes [workaround] : %s\n", gNY[fPreferVRAMUseOverFlushes]);
     151             : 
     152           0 :     if (this->advancedBlendEquationSupport()) {
     153           0 :         r.appendf("Advanced Blend Equation Blacklist  : 0x%x\n", fAdvBlendEqBlacklist);
     154             :     }
     155             : 
     156           0 :     r.appendf("Max Vertex Attributes              : %d\n", fMaxVertexAttributes);
     157           0 :     r.appendf("Max Texture Size                   : %d\n", fMaxTextureSize);
     158           0 :     r.appendf("Max Render Target Size             : %d\n", fMaxRenderTargetSize);
     159           0 :     r.appendf("Max Color Sample Count             : %d\n", fMaxColorSampleCount);
     160           0 :     r.appendf("Max Stencil Sample Count           : %d\n", fMaxStencilSampleCount);
     161           0 :     r.appendf("Max Raster Samples                 : %d\n", fMaxRasterSamples);
     162           0 :     r.appendf("Max Window Rectangles              : %d\n", fMaxWindowRectangles);
     163             : 
     164             :     static const char* kInstancedSupportNames[] = {
     165             :         "None",
     166             :         "Basic",
     167             :         "Multisampled",
     168             :         "Mixed Sampled",
     169             :     };
     170             :     GR_STATIC_ASSERT(0 == (int)InstancedSupport::kNone);
     171             :     GR_STATIC_ASSERT(1 == (int)InstancedSupport::kBasic);
     172             :     GR_STATIC_ASSERT(2 == (int)InstancedSupport::kMultisampled);
     173             :     GR_STATIC_ASSERT(3 == (int)InstancedSupport::kMixedSampled);
     174             :     GR_STATIC_ASSERT(4 == SK_ARRAY_COUNT(kInstancedSupportNames));
     175             : 
     176           0 :     r.appendf("Instanced Support                  : %s\n",
     177           0 :               kInstancedSupportNames[(int)fInstancedSupport]);
     178             : 
     179             :     static const char* kBlendEquationSupportNames[] = {
     180             :         "Basic",
     181             :         "Advanced",
     182             :         "Advanced Coherent",
     183             :     };
     184             :     GR_STATIC_ASSERT(0 == kBasic_BlendEquationSupport);
     185             :     GR_STATIC_ASSERT(1 == kAdvanced_BlendEquationSupport);
     186             :     GR_STATIC_ASSERT(2 == kAdvancedCoherent_BlendEquationSupport);
     187             :     GR_STATIC_ASSERT(SK_ARRAY_COUNT(kBlendEquationSupportNames) == kLast_BlendEquationSupport + 1);
     188             : 
     189           0 :     r.appendf("Blend Equation Support             : %s\n",
     190           0 :               kBlendEquationSupportNames[fBlendEquationSupport]);
     191           0 :     r.appendf("Map Buffer Support                 : %s\n",
     192           0 :               map_flags_to_string(fMapBufferFlags).c_str());
     193             : 
     194           0 :     SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, false));
     195           0 :     SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, true));
     196             : 
     197           0 :     for (size_t i = 1; i < kGrPixelConfigCnt; ++i)  {
     198           0 :         GrPixelConfig config = static_cast<GrPixelConfig>(i);
     199           0 :         r.appendf("%s is renderable: %s, with MSAA: %s\n",
     200             :                   pixel_config_name(config),
     201           0 :                   gNY[this->isConfigRenderable(config, false)],
     202           0 :                   gNY[this->isConfigRenderable(config, true)]);
     203             :     }
     204             : 
     205           0 :     SkASSERT(!this->isConfigTexturable(kUnknown_GrPixelConfig));
     206             : 
     207           0 :     for (size_t i = 1; i < kGrPixelConfigCnt; ++i)  {
     208           0 :         GrPixelConfig config = static_cast<GrPixelConfig>(i);
     209           0 :         r.appendf("%s is uploadable to a texture: %s\n",
     210             :                   pixel_config_name(config),
     211           0 :                   gNY[this->isConfigTexturable(config)]);
     212             :     }
     213             : 
     214           0 :     return r;
     215             : }

Generated by: LCOV version 1.13