Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 559603004: Separate replacement creation from layer discovery (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed initializer list order Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0ec2b858c43c23bbaab8ee7741345c3c33e096df..ebe3a566800d6307ee3d0369a94453259966a12e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1842,6 +1842,34 @@ static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* re
result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
}
+static void convert_layers_to_replacements(const SkTDArray<GrCachedLayer*>& layers,
+ GrReplacements* replacements) {
+ // TODO: just replace GrReplacements::ReplacementInfo with GrCachedLayer?
+ for (int i = 0; i < layers.count(); ++i) {
+ GrReplacements::ReplacementInfo* layerInfo = replacements->push();
+ layerInfo->fStart = layers[i]->start();
+ layerInfo->fStop = layers[i]->stop();
+ layerInfo->fPos = layers[i]->offset();;
+
+ SkBitmap bm;
+ wrap_texture(layers[i]->texture(),
+ !layers[i]->isAtlased() ? layers[i]->rect().width()
+ : layers[i]->texture()->width(),
+ !layers[i]->isAtlased() ? layers[i]->rect().height()
+ : layers[i]->texture()->height(),
+ &bm);
+ layerInfo->fImage = SkImage::NewTexture(bm);
+
+ // TODO: copy this?
+ layerInfo->fPaint = layers[i]->paint();
+
+ layerInfo->fSrcRect = SkIRect::MakeXYWH(layers[i]->rect().fLeft,
+ layers[i]->rect().fTop,
+ layers[i]->rect().width(),
+ layers[i]->rect().height());
+ }
+}
+
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture* picture,
const SkMatrix* matrix, const SkPaint* paint) {
// todo: should handle these natively
@@ -1875,8 +1903,6 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
return false;
}
- GrReplacements replacements;
-
SkTDArray<GrCachedLayer*> atlased, nonAtlased;
atlased.setReserve(gpuData->numSaveLayers());
@@ -1885,16 +1911,12 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
if (pullForward[i]) {
const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
- GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(picture->uniqueID(),
+ GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(picture->uniqueID(),
info.fSaveLayerOpID,
info.fRestoreOpID,
info.fOffset,
- info.fOriginXform);
-
- GrReplacements::ReplacementInfo* layerInfo = replacements.push();
- layerInfo->fStart = info.fSaveLayerOpID;
- layerInfo->fStop = info.fRestoreOpID;
- layerInfo->fPos = info.fOffset;
+ info.fOriginXform,
+ info.fPaint);
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
@@ -1909,21 +1931,6 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
continue;
}
- SkBitmap bm;
- wrap_texture(layer->texture(),
- !layer->isAtlased() ? desc.fWidth : layer->texture()->width(),
- !layer->isAtlased() ? desc.fHeight : layer->texture()->height(),
- &bm);
- layerInfo->fImage = SkImage::NewTexture(bm);
-
- SkASSERT(info.fPaint);
- layerInfo->fPaint = info.fPaint;
-
- layerInfo->fSrcRect = SkIRect::MakeXYWH(layer->rect().fLeft,
- layer->rect().fTop,
- layer->rect().width(),
- layer->rect().height());
-
if (needsRendering) {
if (layer->isAtlased()) {
*atlased.append() = layer;
@@ -1936,6 +1943,11 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
GrLayerHoister::DrawLayers(picture, atlased, nonAtlased);
+ GrReplacements replacements;
+
+ convert_layers_to_replacements(atlased, &replacements);
+ convert_layers_to_replacements(nonAtlased, &replacements);
+
// Render the entire picture using new layers
GrRecordReplaceDraw(*picture->fRecord, mainCanvas, picture->fBBH.get(), &replacements, NULL);
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698