DO NOT MERGE: Use GL_LINEAR filter when drawing scaled TextureView
Use GL_LINEAR instead of GL_NEAREST sampling, when drawing a TextureView, which has a buffer size that does not match layer size. Scale SkImage to layer size with a matrix, instead of passing wrong size to MakeFromTexture. This CL must not be merged in master, becase this issue has been fixed already by ag/4936023. Bug: 114324288 Test: Passed CtsViewTestCases and CtsUiRenderingTestCases Test: Ran apps using scaled TextureView including Instagram Change-Id: I9ee659d08998c932d8b708a64f3c879ab696fd9e
This commit is contained in:
@@ -133,9 +133,10 @@ void DeferredLayerUpdater::doUpdateTexImage() {
|
|||||||
bool forceFilter = false;
|
bool forceFilter = false;
|
||||||
sp<GraphicBuffer> buffer = mSurfaceTexture->getCurrentBuffer();
|
sp<GraphicBuffer> buffer = mSurfaceTexture->getCurrentBuffer();
|
||||||
if (buffer != nullptr) {
|
if (buffer != nullptr) {
|
||||||
|
mLayer->setBufferSize(buffer->getWidth(), buffer->getHeight());
|
||||||
// force filtration if buffer size != layer size
|
// force filtration if buffer size != layer size
|
||||||
forceFilter = mWidth != static_cast<int>(buffer->getWidth()) ||
|
forceFilter = mWidth != static_cast<int>(mLayer->getBufferWidth()) ||
|
||||||
mHeight != static_cast<int>(buffer->getHeight());
|
mHeight != static_cast<int>(mLayer->getBufferHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_RENDERER
|
#if DEBUG_RENDERER
|
||||||
|
|||||||
@@ -94,6 +94,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void postDecStrong();
|
void postDecStrong();
|
||||||
|
|
||||||
|
inline void setBufferSize(uint32_t width, uint32_t height) {
|
||||||
|
mBufferWidth = width;
|
||||||
|
mBufferHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t getBufferWidth() const { return mBufferWidth; }
|
||||||
|
|
||||||
|
inline uint32_t getBufferHeight() const { return mBufferHeight; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Layer(RenderState& renderState, Api api, sk_sp<SkColorFilter>, int alpha,
|
Layer(RenderState& renderState, Api api, sk_sp<SkColorFilter>, int alpha,
|
||||||
SkBlendMode mode);
|
SkBlendMode mode);
|
||||||
@@ -145,6 +154,9 @@ private:
|
|||||||
*/
|
*/
|
||||||
mat4 transform;
|
mat4 transform;
|
||||||
|
|
||||||
|
uint32_t mBufferWidth = 0;
|
||||||
|
|
||||||
|
uint32_t mBufferHeight = 0;
|
||||||
}; // struct Layer
|
}; // struct Layer
|
||||||
|
|
||||||
}; // namespace uirenderer
|
}; // namespace uirenderer
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
|
|||||||
sk_sp<SkImage> layerImage;
|
sk_sp<SkImage> layerImage;
|
||||||
const int layerWidth = layer->getWidth();
|
const int layerWidth = layer->getWidth();
|
||||||
const int layerHeight = layer->getHeight();
|
const int layerHeight = layer->getHeight();
|
||||||
|
const int bufferWidth = layer->getBufferWidth();
|
||||||
|
const int bufferHeight = layer->getBufferHeight();
|
||||||
|
if (bufferWidth <= 0 || bufferHeight <=0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (layer->getApi() == Layer::Api::OpenGL) {
|
if (layer->getApi() == Layer::Api::OpenGL) {
|
||||||
GlLayer* glLayer = static_cast<GlLayer*>(layer);
|
GlLayer* glLayer = static_cast<GlLayer*>(layer);
|
||||||
GrGLTextureInfo externalTexture;
|
GrGLTextureInfo externalTexture;
|
||||||
@@ -57,7 +62,7 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
|
|||||||
// this is anticipated to have is that for some format types if we are not bound as an OES
|
// 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.
|
// texture we may get invalid results for SKP capture if we read back the texture.
|
||||||
externalTexture.fFormat = GL_RGBA8;
|
externalTexture.fFormat = GL_RGBA8;
|
||||||
GrBackendTexture backendTexture(layerWidth, layerHeight, GrMipMapped::kNo, externalTexture);
|
GrBackendTexture backendTexture(bufferWidth, bufferHeight, GrMipMapped::kNo, externalTexture);
|
||||||
layerImage = SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
|
layerImage = SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
|
||||||
kPremul_SkAlphaType, nullptr);
|
kPremul_SkAlphaType, nullptr);
|
||||||
} else {
|
} else {
|
||||||
@@ -76,7 +81,7 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
|
|||||||
flipV.setAll(1, 0, 0, 0, -1, 1, 0, 0, 1);
|
flipV.setAll(1, 0, 0, 0, -1, 1, 0, 0, 1);
|
||||||
textureMatrixInv.preConcat(flipV);
|
textureMatrixInv.preConcat(flipV);
|
||||||
textureMatrixInv.preScale(1.0f / layerWidth, 1.0f / layerHeight);
|
textureMatrixInv.preScale(1.0f / layerWidth, 1.0f / layerHeight);
|
||||||
textureMatrixInv.postScale(layerWidth, layerHeight);
|
textureMatrixInv.postScale(bufferWidth, bufferHeight);
|
||||||
SkMatrix textureMatrix;
|
SkMatrix textureMatrix;
|
||||||
if (!textureMatrixInv.invert(&textureMatrix)) {
|
if (!textureMatrixInv.invert(&textureMatrix)) {
|
||||||
textureMatrix = textureMatrixInv;
|
textureMatrix = textureMatrixInv;
|
||||||
@@ -95,6 +100,9 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
|
|||||||
paint.setAlpha(layer->getAlpha());
|
paint.setAlpha(layer->getAlpha());
|
||||||
paint.setBlendMode(layer->getMode());
|
paint.setBlendMode(layer->getMode());
|
||||||
paint.setColorFilter(layer->getColorSpaceWithFilter());
|
paint.setColorFilter(layer->getColorSpaceWithFilter());
|
||||||
|
if (layer->getForceFilter()) {
|
||||||
|
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||||
|
}
|
||||||
|
|
||||||
const bool nonIdentityMatrix = !matrix.isIdentity();
|
const bool nonIdentityMatrix = !matrix.isIdentity();
|
||||||
if (nonIdentityMatrix) {
|
if (nonIdentityMatrix) {
|
||||||
|
|||||||
Reference in New Issue
Block a user