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

Unified Diff: src/gpu/GrLayerHoister.cpp

Issue 769533004: Fuse GrReplacements and GrLayerCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clang Created 6 years 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/GrLayerHoister.h ('k') | src/gpu/GrRecordReplaceDraw.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerHoister.cpp
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index 4e7836830ca784d723a3ce2a9d63c298614baa58..a17c7ddf97cb95dbc35331e44884a0b89dcb56f5 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -72,7 +72,6 @@ static void prepare_for_hoisting(GrLayerCache* layerCache,
layerCache->addUse(layer);
hl->fLayer = layer;
hl->fPicture = pict;
- hl->fOffset = SkIPoint::Make(layerRect.fLeft, layerRect.fTop);
hl->fLocalMat = info.fLocalMat;
hl->fInitialMat = initialMat;
hl->fPreMat = initialMat;
@@ -185,46 +184,6 @@ void GrLayerHoister::FindLayersToHoist(GrContext* context,
}
}
-static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* result) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- result->setInfo(info);
- result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
-}
-
-void GrLayerHoister::ConvertLayersToReplacements(const SkPicture* topLevelPicture,
- const SkTDArray<GrHoistedLayer>& layers,
- GrReplacements* replacements) {
- // TODO: just replace GrReplacements::ReplacementInfo with GrCachedLayer?
- for (int i = 0; i < layers.count(); ++i) {
- GrCachedLayer* layer = layers[i].fLayer;
-
- GrReplacements::ReplacementInfo* layerInfo =
- replacements->newReplacement(topLevelPicture->uniqueID(),
- layers[i].fInitialMat,
- layer->key(), layer->keySize());
- layerInfo->fStop = layer->stop();
- layerInfo->fPos = layers[i].fOffset;
-
- SkBitmap bm;
- wrap_texture(layers[i].fLayer->texture(),
- !layers[i].fLayer->isAtlased() ? layers[i].fLayer->rect().width()
- : layers[i].fLayer->texture()->width(),
- !layers[i].fLayer->isAtlased() ? layers[i].fLayer->rect().height()
- : layers[i].fLayer->texture()->height(),
- &bm);
- layerInfo->fImage = SkImage::NewTexture(bm);
-
- layerInfo->fPaint = layers[i].fLayer->paint()
- ? SkNEW_ARGS(SkPaint, (*layers[i].fLayer->paint()))
- : NULL;
-
- layerInfo->fSrcRect = SkIRect::MakeXYWH(layers[i].fLayer->rect().fLeft,
- layers[i].fLayer->rect().fTop,
- layers[i].fLayer->rect().width(),
- layers[i].fLayer->rect().height());
- }
-}
-
void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
const SkTDArray<GrHoistedLayer>& atlased) {
if (atlased.count() > 0) {
@@ -241,7 +200,7 @@ 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 SkIPoint offset = atlased[i].fOffset;
+ const SkIPoint offset = SkIPoint::Make(layer->bound().fLeft, layer->bound().fTop);
SkDEBUGCODE(const SkPaint* layerPaint = layer->paint();)
SkASSERT(!layerPaint || !layerPaint->getImageFilter());
@@ -250,10 +209,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
// Add a rect clip to make sure the rendering doesn't
// extend beyond the boundaries of the atlased sub-rect
- SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
- SkIntToScalar(layer->rect().fTop),
- SkIntToScalar(layer->rect().width()),
- SkIntToScalar(layer->rect().height()));
+ const SkRect bound = SkRect::Make(layer->rect());
atlasCanvas->clipRect(bound);
// Since 'clear' doesn't respect the clip we need to draw a rect
@@ -285,7 +241,7 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay
for (int i = 0; i < layers.count(); ++i) {
GrCachedLayer* layer = layers[i].fLayer;
const SkPicture* pict = layers[i].fPicture;
- const SkIPoint& offset = layers[i].fOffset;
+ const SkIPoint offset = SkIPoint::Make(layer->bound().fLeft, layer->bound().fTop);
// Each non-atlased layer has its own GrTexture
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
@@ -297,11 +253,7 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay
// Add a rect clip to make sure the rendering doesn't
// extend beyond the boundaries of the layer
- SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
- SkIntToScalar(layer->rect().fTop),
- SkIntToScalar(layer->rect().width()),
- SkIntToScalar(layer->rect().height()));
-
+ const SkRect bound = SkRect::Make(layer->rect());
layerCanvas->clipRect(bound);
layerCanvas->clear(SK_ColorTRANSPARENT);
« no previous file with comments | « src/gpu/GrLayerHoister.h ('k') | src/gpu/GrRecordReplaceDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698