From 8e80d17d2b63fa84081236012f31bb10c58d344d Mon Sep 17 00:00:00 2001 From: jvanverth Date: Thu, 19 Jun 2014 12:01:10 -0700 Subject: [PATCH] Reduce texture uploads for font atlas. Also adds upload tracing for Chrome. R=bsalomon@google.com Author: jvanverth@google.com Review URL: https://codereview.chromium.org/347563005 --- src/gpu/GrAtlas.cpp | 5 ++++- src/gpu/GrBitmapTextContext.cpp | 2 -- src/gpu/GrDistanceFieldTextContext.cpp | 2 -- src/gpu/GrInOrderDrawBuffer.cpp | 3 +++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp index 331f5d9..ea5ad50 100644 --- a/src/gpu/GrAtlas.cpp +++ b/src/gpu/GrAtlas.cpp @@ -10,6 +10,7 @@ #include "GrContext.h" #include "GrGpu.h" #include "GrRectanizer.h" +#include "GrTracing.h" /////////////////////////////////////////////////////////////////////////////// @@ -90,6 +91,7 @@ bool GrPlot::addSubImage(int width, int height, const void* image, } else { adjust_for_offset(loc, fOffset); GrContext* context = fTexture->getContext(); + TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTexture"); context->writeTexturePixels(fTexture, loc->fX, loc->fY, width, height, fTexture->config(), image, 0, @@ -110,12 +112,13 @@ void GrPlot::uploadToTexture() { SkASSERT(fBatchUploads); if (fDirty) { + TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTexture"); SkASSERT(NULL != fTexture); GrContext* context = fTexture->getContext(); // We pass the flag that does not force a flush. We assume our caller is // smart and hasn't referenced the part of the texture we're about to update // since the last flush. - int rowBytes = fBytesPerPixel*fRects->width(); + size_t rowBytes = fBytesPerPixel*fRects->width(); const unsigned char* dataPtr = fPlotData; dataPtr += rowBytes*fDirtyRect.fTop; dataPtr += fBytesPerPixel*fDirtyRect.fLeft; diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp index 696077d..4f6a1af 100755 --- a/src/gpu/GrBitmapTextContext.cpp +++ b/src/gpu/GrBitmapTextContext.cpp @@ -88,8 +88,6 @@ void GrBitmapTextContext::flushGlyphs() { drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); if (fCurrVertex > 0) { - fContext->getFontCache()->updateTextures(); - // setup our sampler state for our text texture/atlas SkASSERT(SkIsAlign4(fCurrVertex)); SkASSERT(fCurrTexture); diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index c792767..fe6e50f 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -106,8 +106,6 @@ void GrDistanceFieldTextContext::flushGlyphs() { drawState->setFromPaint(fPaint, fContext->getMatrix(), fContext->getRenderTarget()); if (fCurrVertex > 0) { - fContext->getFontCache()->updateTextures(); - // setup our sampler state for our text texture/atlas SkASSERT(SkIsAlign4(fCurrVertex)); SkASSERT(fCurrTexture); diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 6a503bb..deea72b 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -9,6 +9,7 @@ #include "GrBufferAllocPool.h" #include "GrDrawTargetCaps.h" +#include "GrTextStrike.h" #include "GrGpu.h" #include "GrIndexBuffer.h" #include "GrPath.h" @@ -557,6 +558,8 @@ void GrInOrderDrawBuffer::flush() { return; } + this->getContext()->getFontCache()->updateTextures(); + SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc); SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc); -- 2.7.4