diff options
author | Derek Sollenberger <djsollen@google.com> | 2016-11-04 10:46:18 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2016-11-07 10:05:56 -0500 |
commit | b7d34b64dd32e3d84bd43344c9c3d9ad098129af (patch) | |
tree | bf7125fc5a53b95f4bffd81cc724eef6b478e5fa /libs/hwui/pipeline/skia/SkiaPipeline.cpp | |
parent | 3d36fac2350cbce6dbdcd7502dc9adb0210d3d8b (diff) |
Refactor pin/unpinImages to work across pipelines.
Test: existing CTS tests still pass
Change-Id: Ib2607e9853396bad42f298829b5c5da0d210af32
Diffstat (limited to 'libs/hwui/pipeline/skia/SkiaPipeline.cpp')
-rw-r--r-- | libs/hwui/pipeline/skia/SkiaPipeline.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp index 03fa266a5c20..69e603b6c927 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp @@ -46,6 +46,22 @@ void SkiaPipeline::onDestroyHardwareResources() { // which will flush temporary resources over time. } +bool SkiaPipeline::pinImages(std::vector<SkImage*>& mutableImages) { + for (SkImage* image : mutableImages) { + mPinnedImages.emplace_back(sk_ref_sp(image)); + // TODO: return false if texture creation fails (see b/32691999) + SkImage_pinAsTexture(image, mRenderThread.getGrContext()); + } + return true; +} + +void SkiaPipeline::unpinImages() { + for (auto& image : mPinnedImages) { + SkImage_unpinAsTexture(image.get(), mRenderThread.getGrContext()); + } + mPinnedImages.clear(); +} + void SkiaPipeline::renderLayers(const FrameBuilder::LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue, bool opaque, const BakedOpRenderer::LightInfo& lightInfo) { @@ -154,9 +170,6 @@ void SkiaPipeline::renderFrame(const LayerUpdateQueue& layers, const SkRect& cli const std::vector<sp<RenderNode>>& nodes, bool opaque, const Rect &contentDrawBounds, sk_sp<SkSurface> surface) { - // unpin all mutable images that were attached to nodes deleted while on the UI thread - SkiaDisplayList::cleanupImages(surface->getCanvas()->getGrContext()); - // draw all layers up front renderLayersImpl(layers, opaque); |