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
This commit is contained in:
jvanverth 2014-06-19 12:01:10 -07:00 committed by Commit bot
parent d7f846bdd1
commit 8e80d17d2b
4 changed files with 7 additions and 5 deletions

View 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;

View File

@ -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);

View File

@ -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);

View 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);