Reduce texture uploads for font atlas.
authorjvanverth <jvanverth@google.com>
Thu, 19 Jun 2014 19:01:10 +0000 (12:01 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 19 Jun 2014 19:01:11 +0000 (12:01 -0700)
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
src/gpu/GrBitmapTextContext.cpp
src/gpu/GrDistanceFieldTextContext.cpp
src/gpu/GrInOrderDrawBuffer.cpp

index 331f5d9..ea5ad50 100644 (file)
@@ -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;
index 696077d..4f6a1af 100755 (executable)
@@ -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);
index c792767..fe6e50f 100755 (executable)
@@ -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);
index 6a503bb..deea72b 100644 (file)
@@ -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);