diff options
author | 2015-05-18 14:53:43 -0700 | |
---|---|---|
committer | 2015-05-18 14:53:43 -0700 | |
commit | 72743b165424efc4ef6f6614add9033ea1ef31db (patch) | |
tree | 26ebea2ec4df12ec4d94cb3089b4f3d82a032322 /src/gpu | |
parent | 4f2dba625dd858ea3591974d793ef18c10c2ca67 (diff) |
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #25 id:480001 of https://codereview.chromium.org/1112523006/)
Reason for revert:
win_chromium_compile_dbg_ng
FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma/gomacc "E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\skia\src\core\skia.SkBitmapHeap.obj.rsp /c ..\..\third_party\skia\src\core\SkBitmapHeap.cpp /Foobj\third_party\skia\src\core\skia.SkBitmapHeap.obj /Fdobj\skia\skia.cc.pdb
e:\b\build\slave\win\build\src\third_party\skia\include\core\skpicture.h(176) : error C2487: 'CURRENT_PICTURE_VERSION' : member of dll interface class may not be declared with dll interface
Original issue's description:
> 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:
>
> Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b
>
> Latest blink_linux_rel:
>
> http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248
>
> Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec
TBR=reed@google.com,robertphillips@google.com,fmalita@chromium.org,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1130283004
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrLayerHoister.cpp | 42 | ||||
-rw-r--r-- | src/gpu/GrRecordReplaceDraw.cpp | 47 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 7 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 2 |
4 files changed, 42 insertions, 56 deletions
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index 67e3c19a2f..70c10d7f69 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -9,7 +9,6 @@ #include "GrLayerHoister.h" #include "GrRecordReplaceDraw.h" -#include "SkBigPicture.h" #include "SkCanvas.h" #include "SkDeviceImageFilterProxy.h" #include "SkDeviceProperties.h" @@ -22,7 +21,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, @@ -75,7 +74,7 @@ static void prepare_for_hoisting(GrLayerCache* layerCache, } else { hl = recycled->append(); } - + layerCache->addUse(layer); hl->fLayer = layer; hl->fPicture = pict; @@ -130,12 +129,12 @@ void GrLayerHoister::FindLayersToAtlas(GrContext* context, } GrLayerCache* layerCache = context->getLayerCache(); + layerCache->processDeletedPictures(); - const SkBigPicture::AccelData* topLevelData = NULL; - if (const SkBigPicture* bp = topLevelPicture->asSkBigPicture()) { - topLevelData = bp->accelData(); - } + SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); + + const SkPicture::AccelData* topLevelData = topLevelPicture->EXPERIMENTAL_getAccelData(key); if (!topLevelData) { return; } @@ -190,10 +189,9 @@ void GrLayerHoister::FindLayersToHoist(GrContext* context, layerCache->processDeletedPictures(); - const SkBigPicture::AccelData* topLevelData = NULL; - if (const SkBigPicture* bp = topLevelPicture->asSkBigPicture()) { - topLevelData = bp->accelData(); - } + SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); + + const SkPicture::AccelData* topLevelData = topLevelPicture->EXPERIMENTAL_getAccelData(key); if (!topLevelData) { return; } @@ -241,11 +239,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, for (int i = 0; i < atlased.count(); ++i) { const GrCachedLayer* layer = atlased[i].fLayer; - const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture(); - if (!pict) { - // TODO: can we assume / assert this? - continue; - } + const SkPicture* pict = atlased[i].fPicture; const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcIR().fTop); SkDEBUGCODE(const SkPaint* layerPaint = layer->paint();) @@ -271,7 +265,10 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, atlasCanvas->setMatrix(initialCTM); atlasCanvas->concat(atlased[i].fLocalMat); - pict->partialPlayback(atlasCanvas, layer->start() + 1, layer->stop(), initialCTM); + SkRecordPartialDraw(*pict->fRecord.get(), atlasCanvas, + pict->drawablePicts(), pict->drawableCount(), + layer->start() + 1, layer->stop(), initialCTM); + atlasCanvas->restore(); } @@ -331,11 +328,7 @@ 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 SkBigPicture* pict = layers[i].fPicture->asSkBigPicture(); - if (!pict) { - // TODO: can we assume / assert this? - continue; - } + const SkPicture* pict = layers[i].fPicture; const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcIR().fTop); // Each non-atlased layer has its own GrTexture @@ -360,7 +353,10 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay layerCanvas->setMatrix(initialCTM); layerCanvas->concat(layers[i].fLocalMat); - pict->partialPlayback(layerCanvas, layer->start()+1, layer->stop(), initialCTM); + SkRecordPartialDraw(*pict->fRecord.get(), layerCanvas, + pict->drawablePicts(), pict->drawableCount(), + layer->start()+1, layer->stop(), initialCTM); + layerCanvas->flush(); if (layer->filter()) { diff --git a/src/gpu/GrRecordReplaceDraw.cpp b/src/gpu/GrRecordReplaceDraw.cpp index 6f05206dcc..dacc939e62 100644 --- a/src/gpu/GrRecordReplaceDraw.cpp +++ b/src/gpu/GrRecordReplaceDraw.cpp @@ -8,7 +8,6 @@ #include "GrContext.h" #include "GrLayerCache.h" #include "GrRecordReplaceDraw.h" -#include "SkBigPicture.h" #include "SkCanvasPriv.h" #include "SkGrPixelRef.h" #include "SkImage.h" @@ -46,7 +45,7 @@ static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva canvas->drawBitmapRectToRect(bm, &src, dst, layer->paint()); canvas->restore(); } else { - canvas->drawSprite(bm, + canvas->drawSprite(bm, layer->srcIR().fLeft + layer->offset().fX, layer->srcIR().fTop + layer->offset().fY, layer->paint()); @@ -60,7 +59,7 @@ public: ReplaceDraw(SkCanvas* canvas, GrLayerCache* layerCache, SkPicture const* const drawablePicts[], int drawableCount, const SkPicture* topLevelPicture, - const SkBigPicture* picture, + const SkPicture* picture, const SkMatrix& initialMatrix, SkPicture::AbortCallback* callback, const unsigned* opIndices, int numIndices) @@ -77,8 +76,8 @@ public: } int draw() { - const SkBBoxHierarchy* bbh = fPicture->bbh(); - const SkRecord* record = fPicture->record(); + const SkBBoxHierarchy* bbh = fPicture->fBBH.get(); + const SkRecord* record = fPicture->fRecord.get(); if (NULL == record) { return 0; } @@ -136,17 +135,13 @@ public: SkAutoCanvasMatrixPaint acmp(fCanvas, &dp.matrix, dp.paint, dp.picture->cullRect()); - if (const SkBigPicture* bp = dp.picture->asSkBigPicture()) { - // Draw sub-pictures with the same replacement list but a different picture - ReplaceDraw draw(fCanvas, fLayerCache, - this->drawablePicts(), this->drawableCount(), - fTopLevelPicture, bp, fInitialMatrix, fCallback, - fOpIndexStack.begin(), fOpIndexStack.count()); - fNumReplaced += draw.draw(); - } else { - // TODO: can we assume / assert this doesn't happen? - dp.picture->playback(fCanvas, fCallback); - } + // Draw sub-pictures with the same replacement list but a different picture + ReplaceDraw draw(fCanvas, fLayerCache, + this->drawablePicts(), this->drawableCount(), + fTopLevelPicture, dp.picture, fInitialMatrix, fCallback, + fOpIndexStack.begin(), fOpIndexStack.count()); + + fNumReplaced += draw.draw(); fOpIndexStack.pop(); } @@ -173,7 +168,7 @@ public: draw_replacement_bitmap(layer, fCanvas); - if (fPicture->bbh()) { + if (fPicture->fBBH.get()) { while (fOps[fIndex] < layer->stop()) { ++fIndex; } @@ -195,7 +190,7 @@ private: SkCanvas* fCanvas; GrLayerCache* fLayerCache; const SkPicture* fTopLevelPicture; - const SkBigPicture* fPicture; + const SkPicture* fPicture; const SkMatrix fInitialMatrix; SkPicture::AbortCallback* fCallback; @@ -216,15 +211,9 @@ int GrRecordReplaceDraw(const SkPicture* picture, SkPicture::AbortCallback* callback) { SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); - if (const SkBigPicture* bp = picture->asSkBigPicture()) { - // TODO: drawablePicts? - ReplaceDraw draw(canvas, layerCache, NULL, 0, - bp, bp, - initialMatrix, callback, NULL, 0); - return draw.draw(); - } else { - // TODO: can we assume / assert this doesn't happen? - picture->playback(canvas, callback); - return 0; - } + // TODO: drawablePicts? + ReplaceDraw draw(canvas, layerCache, NULL, 0, + picture, picture, + initialMatrix, callback, NULL, 0); + return draw.draw(); } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 25f6fd370f..7b363635e2 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1999,10 +1999,9 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture return false; } - const SkBigPicture::AccelData* data = NULL; - if (const SkBigPicture* bp = mainPicture->asSkBigPicture()) { - data = bp->accelData(); - } + SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); + + const SkPicture::AccelData* data = mainPicture->EXPERIMENTAL_getAccelData(key); if (!data) { return false; } diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index c1ea4fe873..89959e1f9c 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -217,6 +217,8 @@ private: bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); + static SkPicture::AccelData::Key ComputeAccelDataKey(); + static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, const SkImageInfo&, int sampleCount); |