summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2018-09-05 16:35:11 -0400
committerStan Iliev <stani@google.com>2018-09-10 13:18:04 -0400
commit1a025a7163daa89b6cb2043c56fa0ddc0548db5c (patch)
treedf45e768a08dfaabec20c47941b7678c265d3a63 /libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
parentcf1c58cd473d927f4c12dbecd33cd99d02dd1e25 (diff)
Refactor HWUI readback code to be backend independent
Implement readback from Surface, TextureView and HW Bitmap for Vulkan pipeline by wrapping the graphics buffer in an SkImage. Refactor both Vulkan and GL readback to use common code. TextureView readback is moved from IRenderPipeline interface to Readback class. Refactor all 3 readback flows to use common implementation. Test: Passed all view, uirendering and graphics CTS tests with GL Test: Passed many CTS test with Vulkan, that require readback Bug: 113673613 Change-Id: Ifbfd8170a5401f87a709b4b1b9fa058e8e11768d
Diffstat (limited to 'libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp')
-rw-r--r--libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp59
1 files changed, 0 insertions, 59 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index 2ae37233098e..d58b59e83380 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -127,65 +127,6 @@ bool SkiaOpenGLPipeline::swapBuffers(const Frame& frame, bool drew, const SkRect
return *requireSwap;
}
-bool SkiaOpenGLPipeline::copyLayerInto(DeferredLayerUpdater* deferredLayer, SkBitmap* bitmap) {
- if (!mRenderThread.getGrContext()) {
- return false;
- }
-
- // acquire most recent buffer for drawing
- deferredLayer->updateTexImage();
- deferredLayer->apply();
-
- // drop the colorSpace as we only support readback into sRGB or extended sRGB
- SkImageInfo surfaceInfo = bitmap->info().makeColorSpace(nullptr);
-
- /* This intermediate surface is present to work around a bug in SwiftShader that
- * prevents us from reading the contents of the layer's texture directly. The
- * workaround involves first rendering that texture into an intermediate buffer and
- * then reading from the intermediate buffer into the bitmap.
- */
- sk_sp<SkSurface> tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(),
- SkBudgeted::kYes, surfaceInfo);
-
- if (!tmpSurface.get()) {
- surfaceInfo = surfaceInfo.makeColorType(SkColorType::kN32_SkColorType);
- tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), SkBudgeted::kYes,
- surfaceInfo);
- if (!tmpSurface.get()) {
- ALOGW("Unable to readback GPU contents into the provided bitmap");
- return false;
- }
- }
-
- Layer* layer = deferredLayer->backingLayer();
- const SkRect dstRect = SkRect::MakeIWH(bitmap->width(), bitmap->height());
- if (LayerDrawable::DrawLayer(mRenderThread.getGrContext(), tmpSurface->getCanvas(), layer,
- &dstRect)) {
- sk_sp<SkImage> tmpImage = tmpSurface->makeImageSnapshot();
- if (tmpImage->readPixels(surfaceInfo, bitmap->getPixels(), bitmap->rowBytes(), 0, 0)) {
- bitmap->notifyPixelsChanged();
- return true;
- }
-
- // if we fail to readback from the GPU directly (e.g. 565) then we attempt to read into 8888
- // and then draw that into the destination format before giving up.
- SkBitmap tmpBitmap;
- SkImageInfo bitmapInfo =
- SkImageInfo::MakeN32(bitmap->width(), bitmap->height(), bitmap->alphaType());
- if (tmpBitmap.tryAllocPixels(bitmapInfo) &&
- tmpImage->readPixels(bitmapInfo, tmpBitmap.getPixels(), tmpBitmap.rowBytes(), 0, 0)) {
- SkCanvas canvas(*bitmap);
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc);
- canvas.drawBitmap(tmpBitmap, 0, 0, &paint);
- bitmap->notifyPixelsChanged();
- return true;
- }
- }
-
- return false;
-}
-
DeferredLayerUpdater* SkiaOpenGLPipeline::createTextureLayer() {
mRenderThread.requireGlContext();
return new DeferredLayerUpdater(mRenderThread.renderState());