diff options
author | 2015-05-07 13:41:07 -0700 | |
---|---|---|
committer | 2015-05-07 13:41:07 -0700 | |
commit | c92c129ff85b05a714bd1bf921c02d5e14651f8b (patch) | |
tree | ea2f915b36a5f6abb746827a4a6f650d5ff13310 /src/gpu/GrLayerHoister.cpp | |
parent | 2fbd4068bde6a9fb50341c0bdfbb8bf18b70d015 (diff) |
Sketch splitting SkPicture into an interface and SkBigPicture.
Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
These cover about 89% of draw calls from Blink SKPs,
and about 25% of draw calls from our GMs.
SkPicture handles:
- serialization and deserialization
- unique IDs
Everything else is left to the subclasses:
- playback(), cullRect()
- hasBitmap(), hasText(), suitableForGPU(), etc.
- LayerInfo / AccelData if applicable.
The time to record a 1-op picture improves a good chunk
(2 mallocs to 1), and the time to record a 0-op picture
greatly improves (2 mallocs to none):
picture_overhead_draw: 450ns -> 350ns
picture_overhead_nodraw: 300ns -> 90ns
BUG=skia:
Review URL: https://codereview.chromium.org/1112523006
Diffstat (limited to 'src/gpu/GrLayerHoister.cpp')
-rw-r--r-- | src/gpu/GrLayerHoister.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index 70c10d7f69..67e3c19a2f 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -9,6 +9,7 @@ #include "GrLayerHoister.h" #include "GrRecordReplaceDraw.h" +#include "SkBigPicture.h" #include "SkCanvas.h" #include "SkDeviceImageFilterProxy.h" #include "SkDeviceProperties.h" @@ -21,7 +22,7 @@ // Create the layer information for the hoisted layer and secure the // required texture/render target resources. -static void prepare_for_hoisting(GrLayerCache* layerCache, +static void prepare_for_hoisting(GrLayerCache* layerCache, const SkPicture* topLevelPicture, const SkMatrix& initialMat, const SkLayerInfo::BlockInfo& info, @@ -74,7 +75,7 @@ static void prepare_for_hoisting(GrLayerCache* layerCache, } else { hl = recycled->append(); } - + layerCache->addUse(layer); hl->fLayer = layer; hl->fPicture = pict; @@ -129,12 +130,12 @@ void GrLayerHoister::FindLayersToAtlas(GrContext* context, } GrLayerCache* layerCache = context->getLayerCache(); - layerCache->processDeletedPictures(); - SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); - - const SkPicture::AccelData* topLevelData = topLevelPicture->EXPERIMENTAL_getAccelData(key); + const SkBigPicture::AccelData* topLevelData = NULL; + if (const SkBigPicture* bp = topLevelPicture->asSkBigPicture()) { + topLevelData = bp->accelData(); + } if (!topLevelData) { return; } @@ -189,9 +190,10 @@ void GrLayerHoister::FindLayersToHoist(GrContext* context, layerCache->processDeletedPictures(); - SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); - - const SkPicture::AccelData* topLevelData = topLevelPicture->EXPERIMENTAL_getAccelData(key); + const SkBigPicture::AccelData* topLevelData = NULL; + if (const SkBigPicture* bp = topLevelPicture->asSkBigPicture()) { + topLevelData = bp->accelData(); + } if (!topLevelData) { return; } @@ -239,7 +241,11 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, for (int i = 0; i < atlased.count(); ++i) { const GrCachedLayer* layer = atlased[i].fLayer; - const SkPicture* pict = atlased[i].fPicture; + const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture(); + if (!pict) { + // TODO: can we assume / assert this? + continue; + } const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcIR().fTop); SkDEBUGCODE(const SkPaint* layerPaint = layer->paint();) @@ -265,10 +271,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, atlasCanvas->setMatrix(initialCTM); atlasCanvas->concat(atlased[i].fLocalMat); - SkRecordPartialDraw(*pict->fRecord.get(), atlasCanvas, - pict->drawablePicts(), pict->drawableCount(), - layer->start() + 1, layer->stop(), initialCTM); - + pict->partialPlayback(atlasCanvas, layer->start() + 1, layer->stop(), initialCTM); atlasCanvas->restore(); } @@ -328,7 +331,11 @@ void GrLayerHoister::FilterLayer(GrContext* context, void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLayer>& layers) { for (int i = 0; i < layers.count(); ++i) { GrCachedLayer* layer = layers[i].fLayer; - const SkPicture* pict = layers[i].fPicture; + const SkBigPicture* pict = layers[i].fPicture->asSkBigPicture(); + if (!pict) { + // TODO: can we assume / assert this? + continue; + } const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcIR().fTop); // Each non-atlased layer has its own GrTexture @@ -353,10 +360,7 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay layerCanvas->setMatrix(initialCTM); layerCanvas->concat(layers[i].fLocalMat); - SkRecordPartialDraw(*pict->fRecord.get(), layerCanvas, - pict->drawablePicts(), pict->drawableCount(), - layer->start()+1, layer->stop(), initialCTM); - + pict->partialPlayback(layerCanvas, layer->start()+1, layer->stop(), initialCTM); layerCanvas->flush(); if (layer->filter()) { |