summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/hwui/pipeline/skia/SkiaPipeline.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
index 742f14d04db4..a967d2a10b58 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -83,7 +83,8 @@ void SkiaPipeline::renderLayers(const FrameBuilder::LightGeometry& lightGeometry
void SkiaPipeline::renderLayersImpl(const LayerUpdateQueue& layers,
bool opaque, bool wideColorGamut) {
- // TODO: Handle wide color gamut
+ sk_sp<GrContext> cachedContext;
+
// Render all layers that need to be updated, in order.
for (size_t i = 0; i < layers.entries().size(); i++) {
RenderNode* layerNode = layers.entries()[i].renderNode.get();
@@ -126,10 +127,23 @@ void SkiaPipeline::renderLayersImpl(const LayerUpdateQueue& layers,
RenderNodeDrawable root(layerNode, layerCanvas, false);
root.forceDraw(layerCanvas);
layerCanvas->restoreToCount(saveCount);
- layerCanvas->flush();
mLightCenter = savedLightCenter;
+
+ // cache the current context so that we can defer flushing it until
+ // either all the layers have been rendered or the context changes
+ GrContext* currentContext = layerCanvas->getGrContext();
+ if (cachedContext.get() != currentContext) {
+ if (cachedContext.get()) {
+ cachedContext->flush();
+ }
+ cachedContext.reset(SkSafeRef(currentContext));
+ }
}
}
+
+ if (cachedContext.get()) {
+ cachedContext->flush();
+ }
}
bool SkiaPipeline::createOrUpdateLayer(RenderNode* node,