Merge "Shrink by 0.5 for YUV TextViews" am: 9552a623d6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2239073 Change-Id: I07400c56c424580eedcc4abb91deb8652d479c06 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -169,6 +169,8 @@ void DeferredLayerUpdater::apply() {
|
|||||||
sk_sp<SkImage> layerImage = mImageSlots[slot].createIfNeeded(
|
sk_sp<SkImage> layerImage = mImageSlots[slot].createIfNeeded(
|
||||||
hardwareBuffer, dataspace, newContent,
|
hardwareBuffer, dataspace, newContent,
|
||||||
mRenderState.getRenderThread().getGrContext());
|
mRenderState.getRenderThread().getGrContext());
|
||||||
|
AHardwareBuffer_Desc bufferDesc;
|
||||||
|
AHardwareBuffer_describe(hardwareBuffer, &bufferDesc);
|
||||||
// unref to match the ref added by ASurfaceTexture_dequeueBuffer. eglCreateImageKHR
|
// unref to match the ref added by ASurfaceTexture_dequeueBuffer. eglCreateImageKHR
|
||||||
// (invoked by createIfNeeded) will add a ref to the AHardwareBuffer.
|
// (invoked by createIfNeeded) will add a ref to the AHardwareBuffer.
|
||||||
AHardwareBuffer_release(hardwareBuffer);
|
AHardwareBuffer_release(hardwareBuffer);
|
||||||
@@ -189,6 +191,7 @@ void DeferredLayerUpdater::apply() {
|
|||||||
maxLuminanceNits =
|
maxLuminanceNits =
|
||||||
std::max(cta861_3.maxContentLightLevel, maxLuminanceNits);
|
std::max(cta861_3.maxContentLightLevel, maxLuminanceNits);
|
||||||
}
|
}
|
||||||
|
mLayer->setBufferFormat(bufferDesc.format);
|
||||||
updateLayer(forceFilter, layerImage, outTransform, currentCropRect,
|
updateLayer(forceFilter, layerImage, outTransform, currentCropRect,
|
||||||
maxLuminanceNits);
|
maxLuminanceNits);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ public:
|
|||||||
|
|
||||||
inline float getMaxLuminanceNits() { return mMaxLuminanceNits; }
|
inline float getMaxLuminanceNits() { return mMaxLuminanceNits; }
|
||||||
|
|
||||||
|
void setBufferFormat(uint32_t format) { mBufferFormat = format; }
|
||||||
|
|
||||||
|
uint32_t getBufferFormat() const { return mBufferFormat; }
|
||||||
|
|
||||||
void draw(SkCanvas* canvas);
|
void draw(SkCanvas* canvas);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -169,6 +173,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
float mMaxLuminanceNits = -1;
|
float mMaxLuminanceNits = -1;
|
||||||
|
|
||||||
|
uint32_t mBufferFormat = 0;
|
||||||
|
|
||||||
}; // struct Layer
|
}; // struct Layer
|
||||||
|
|
||||||
} // namespace uirenderer
|
} // namespace uirenderer
|
||||||
|
|||||||
@@ -107,6 +107,32 @@ static bool isHdrDataspace(ui::Dataspace dataspace) {
|
|||||||
return transfer == HAL_DATASPACE_TRANSFER_ST2084 || transfer == HAL_DATASPACE_TRANSFER_HLG;
|
return transfer == HAL_DATASPACE_TRANSFER_ST2084 || transfer == HAL_DATASPACE_TRANSFER_HLG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void adjustCropForYUV(uint32_t format, int bufferWidth, int bufferHeight, SkRect* cropRect) {
|
||||||
|
// Chroma channels of YUV420 images are subsampled we may need to shrink the crop region by
|
||||||
|
// a whole texel on each side. Since skia still adds its own 0.5 inset, we apply an
|
||||||
|
// additional 0.5 inset. See GLConsumer::computeTransformMatrix for details.
|
||||||
|
float shrinkAmount = 0.0f;
|
||||||
|
switch (format) {
|
||||||
|
// Use HAL formats since some AHB formats are only available in vndk
|
||||||
|
case HAL_PIXEL_FORMAT_YCBCR_420_888:
|
||||||
|
case HAL_PIXEL_FORMAT_YV12:
|
||||||
|
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
|
||||||
|
shrinkAmount = 0.5f;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shrink the crop if it has more than 1-px and differs from the buffer size.
|
||||||
|
if (cropRect->width() > 1 && cropRect->width() < bufferWidth) {
|
||||||
|
cropRect->inset(shrinkAmount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cropRect->height() > 1 && cropRect->height() < bufferHeight) {
|
||||||
|
cropRect->inset(0, shrinkAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Context arg probably doesn't belong here – do debug check at callsite instead.
|
// TODO: Context arg probably doesn't belong here – do debug check at callsite instead.
|
||||||
bool LayerDrawable::DrawLayer(GrRecordingContext* context,
|
bool LayerDrawable::DrawLayer(GrRecordingContext* context,
|
||||||
SkCanvas* canvas,
|
SkCanvas* canvas,
|
||||||
@@ -142,6 +168,7 @@ bool LayerDrawable::DrawLayer(GrRecordingContext* context,
|
|||||||
SkRect skiaSrcRect;
|
SkRect skiaSrcRect;
|
||||||
if (srcRect && !srcRect->isEmpty()) {
|
if (srcRect && !srcRect->isEmpty()) {
|
||||||
skiaSrcRect = *srcRect;
|
skiaSrcRect = *srcRect;
|
||||||
|
adjustCropForYUV(layer->getBufferFormat(), imageWidth, imageHeight, &skiaSrcRect);
|
||||||
} else {
|
} else {
|
||||||
skiaSrcRect = SkRect::MakeIWH(imageWidth, imageHeight);
|
skiaSrcRect = SkRect::MakeIWH(imageWidth, imageHeight);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user