summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/LayerDrawable.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2018-08-14 13:30:17 -0400
committerStan Iliev <stani@google.com>2018-08-29 10:22:03 -0400
commitc8e22a653297837da9a80b0ba65f6854c8986c96 (patch)
tree7344df1a8aff45ccbf5b9ffb5b4de49499cc7c94 /libs/hwui/pipeline/skia/LayerDrawable.cpp
parent660bb2f3a1dde0b5cca5c8293bf0e72d47b2b6fc (diff)
TextureView Vulkan support and optimized OpenGL draw
Render TextureView as hardware bitmaps, instead of GL textures. Cache SkImage for each observed GraphicBuffer, which is faster even for GL. Implement C++ SurfaceTexture, which allows Java SurfaceTexture to be used with Vulkan HWUI render thread and application GL. threads. Delete GLLayer and VkLayer classes and texture code from old HWUI pipeline. Test: Ran skiagl and skiavk pipeline with a TextureView app. Test: TextureView CTS tests pass for GL pipeline. Test: Ran Android NDK Native codec sample app. Change-Id: Idc94f864ce2d34fd6ceff4be4fc7d3327e99879c
Diffstat (limited to 'libs/hwui/pipeline/skia/LayerDrawable.cpp')
-rw-r--r--libs/hwui/pipeline/skia/LayerDrawable.cpp32
1 files changed, 6 insertions, 26 deletions
diff --git a/libs/hwui/pipeline/skia/LayerDrawable.cpp b/libs/hwui/pipeline/skia/LayerDrawable.cpp
index c41f6a6f0ee6..fb66b50f0159 100644
--- a/libs/hwui/pipeline/skia/LayerDrawable.cpp
+++ b/libs/hwui/pipeline/skia/LayerDrawable.cpp
@@ -15,8 +15,6 @@
*/
#include "LayerDrawable.h"
-#include "GlLayer.h"
-#include "VkLayer.h"
#include "GrBackendSurface.h"
#include "SkColorFilter.h"
@@ -41,35 +39,14 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
return false;
}
// transform the matrix based on the layer
- SkMatrix layerTransform;
- layer->getTransform().copyTo(layerTransform);
- sk_sp<SkImage> layerImage;
+ SkMatrix layerTransform = layer->getTransform();
+ sk_sp<SkImage> layerImage = layer->getImage();
const int layerWidth = layer->getWidth();
const int layerHeight = layer->getHeight();
- if (layer->getApi() == Layer::Api::OpenGL) {
- GlLayer* glLayer = static_cast<GlLayer*>(layer);
- GrGLTextureInfo externalTexture;
- externalTexture.fTarget = glLayer->getRenderTarget();
- externalTexture.fID = glLayer->getTextureId();
- // The format may not be GL_RGBA8, but given the DeferredLayerUpdater and GLConsumer don't
- // expose that info we use it as our default. Further, given that we only use this texture
- // as a source this will not impact how Skia uses the texture. The only potential affect
- // this is anticipated to have is that for some format types if we are not bound as an OES
- // texture we may get invalid results for SKP capture if we read back the texture.
- externalTexture.fFormat = GL_RGBA8;
- GrBackendTexture backendTexture(layerWidth, layerHeight, GrMipMapped::kNo, externalTexture);
- layerImage = SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
- } else {
- SkASSERT(layer->getApi() == Layer::Api::Vulkan);
- VkLayer* vkLayer = static_cast<VkLayer*>(layer);
- canvas->clear(SK_ColorGREEN);
- layerImage = vkLayer->getImage();
- }
if (layerImage) {
SkMatrix textureMatrixInv;
- layer->getTexTransform().copyTo(textureMatrixInv);
+ textureMatrixInv = layer->getTexTransform();
// TODO: after skia bug https://bugs.chromium.org/p/skia/issues/detail?id=7075 is fixed
// use bottom left origin and remove flipV and invert transformations.
SkMatrix flipV;
@@ -95,6 +72,9 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
paint.setAlpha(layer->getAlpha());
paint.setBlendMode(layer->getMode());
paint.setColorFilter(layer->getColorSpaceWithFilter());
+ if (layer->getForceFilter()) {
+ paint.setFilterQuality(kLow_SkFilterQuality);
+ }
const bool nonIdentityMatrix = !matrix.isIdentity();
if (nonIdentityMatrix) {