From 8b656c6db40a99af241e38eae853f887413040cc Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 21 Nov 2013 15:23:15 +0000 Subject: [PATCH] Avoid printing draw target info to stderr while running unit tests Change draw target dump function to return a SkString. Clients can do whatever they want with the string. BUG=skia:1837 R=caryclark@google.com, bsalomon@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/72353003 git-svn-id: http://skia.googlecode.com/svn/trunk@12340 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrDrawTarget.cpp | 36 +++++++++++---------- src/gpu/GrDrawTargetCaps.h | 10 +++--- src/gpu/gl/GrGLCaps.cpp | 65 +++++++++++++++++++------------------- src/gpu/gl/GrGLCaps.h | 4 +-- src/gpu/gl/GrGpuGL.cpp | 2 +- tests/GrDrawTargetTest.cpp | 3 +- 6 files changed, 62 insertions(+), 58 deletions(-) diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 9397d1488f..6a1c4544b9 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -1008,23 +1008,24 @@ GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { return *this; } -void GrDrawTargetCaps::print() const { +SkString GrDrawTargetCaps::dump() const { + SkString r; static const char* gNY[] = {"NO", "YES"}; - GrPrintf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]); - GrPrintf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]); - GrPrintf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]); - GrPrintf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]); - GrPrintf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); - GrPrintf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]); - GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); - GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSupport]); - GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); - GrPrintf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); - GrPrintf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]); - GrPrintf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); - GrPrintf("Max Texture Size : %d\n", fMaxTextureSize); - GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize); - GrPrintf("Max Sample Count : %d\n", fMaxSampleCount); + r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]); + r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]); + r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]); + r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]); + r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); + r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]); + r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); + r.appendf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSupport]); + r.appendf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); + r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); + r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]); + r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); + r.appendf("Max Texture Size : %d\n", fMaxTextureSize); + r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); + r.appendf("Max Sample Count : %d\n", fMaxSampleCount); static const char* kConfigNames[] = { "Unknown", // kUnknown_GrPixelConfig @@ -1048,10 +1049,11 @@ void GrDrawTargetCaps::print() const { SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]); for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) { if (i != kUnknown_GrPixelConfig) { - GrPrintf("%s is renderable: %s, with MSAA: %s\n", + r.appendf("%s is renderable: %s, with MSAA: %s\n", kConfigNames[i], gNY[fConfigRenderSupport[i][0]], gNY[fConfigRenderSupport[i][1]]); } } + return r; } diff --git a/src/gpu/GrDrawTargetCaps.h b/src/gpu/GrDrawTargetCaps.h index f6a6dc8a59..e597e099c9 100644 --- a/src/gpu/GrDrawTargetCaps.h +++ b/src/gpu/GrDrawTargetCaps.h @@ -5,13 +5,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - -#include "SkRefCnt.h" -#include "GrTypes.h" - #ifndef GrDrawTargetCaps_DEFINED #define GrDrawTargetCaps_DEFINED +#include "GrTypes.h" +#include "SkRefCnt.h" +#include "SkString.h" + /** * Represents the draw target capabilities. */ @@ -24,7 +24,7 @@ public: GrDrawTargetCaps& operator= (const GrDrawTargetCaps&); virtual void reset(); - virtual void print() const; + virtual SkString dump() const; bool eightBitPaletteSupport() const { return f8BitPaletteSupport; } bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 17e7b69fda..1a39ba597c 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -586,13 +586,13 @@ bool GrGLCaps::isColorConfigAndStencilFormatVerified( return false; } -void GrGLCaps::print() const { +SkString GrGLCaps::dump() const { - INHERITED::print(); + SkString r = INHERITED::dump(); - GrPrintf("--- GL-Specific ---\n"); + r.appendf("--- GL-Specific ---\n"); for (int i = 0; i < fStencilFormats.count(); ++i) { - GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", + r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", i, fStencilFormats[i].fStencilBits, fStencilFormats[i].fTotalBits); @@ -627,35 +627,36 @@ void GrGLCaps::print() const { GR_STATIC_ASSERT(GR_ARRAY_COUNT(kFBFetchTypeStr) == kLast_FBFetchType + 1); - GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); - GrPrintf("Fixed Function Support: %s\n", (fFixedFunctionSupport ? "YES" : "NO")); - GrPrintf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); - GrPrintf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); - GrPrintf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); - GrPrintf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); + r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); + r.appendf("Fixed Function Support: %s\n", (fFixedFunctionSupport ? "YES" : "NO")); + r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); + r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); + r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); + r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); if (fFixedFunctionSupport) { - GrPrintf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords); - } - GrPrintf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); - GrPrintf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); - GrPrintf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); - GrPrintf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); - GrPrintf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); - GrPrintf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); - GrPrintf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); - GrPrintf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); - GrPrintf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); - - GrPrintf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); - GrPrintf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); - GrPrintf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); - GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); - GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); - GrPrintf("Fragment coord conventions support: %s\n", + r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords); + } + r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); + r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); + r.appendf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); + r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); + r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); + r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); + r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); + r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); + r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); + + r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); + r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); + r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); + r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); + r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); + r.appendf("Fragment coord conventions support: %s\n", (fFragCoordsConventionSupport ? "YES": "NO")); - GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); - GrPrintf("Use non-VBO for dynamic data: %s\n", + r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); + r.appendf("Use non-VBO for dynamic data: %s\n", (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); - GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "NO")); - GrPrintf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO")); + r.appendf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "NO")); + r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO")); + return r; } diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index c126a76774..7f0c8874ca 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -160,9 +160,9 @@ public: FBFetchType fbFetchType() const { return fFBFetchType; } /** - * Prints the caps info using GrPrintf. + * Returs a string containeng the caps info. */ - virtual void print() const SK_OVERRIDE; + virtual SkString dump() const SK_OVERRIDE; /** * Gets an array of legal stencil formats. These formats are not guaranteed diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 0d1ea8e041..9cf39b6534 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -140,7 +140,7 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) GrPrintf("------ EXTENSIONS\n"); ctx.info().extensions().print(); GrPrintf("\n"); - ctx.info().caps()->print(); + GrPrintf(ctx.info().caps()->dump().c_str()); } fProgramCache = SkNEW_ARGS(ProgramCache, (this)); diff --git a/tests/GrDrawTargetTest.cpp b/tests/GrDrawTargetTest.cpp index a82524e88c..f2bcdc415a 100644 --- a/tests/GrDrawTargetTest.cpp +++ b/tests/GrDrawTargetTest.cpp @@ -16,7 +16,8 @@ static void test_print(skiatest::Reporter*, const GrDrawTargetCaps* caps) { // This used to assert. - caps->print(); + SkString result = caps->dump(); + SkASSERT(!result.isEmpty()); } static void TestGrDrawTarget(skiatest::Reporter* reporter, GrContextFactory* factory) { -- 2.34.1