Merge "Use SkSurfaceProps forcedither" into udc-dev
This commit is contained in:
@@ -104,7 +104,8 @@ IRenderPipeline::DrawResult SkiaOpenGLPipeline::draw(
|
||||
|
||||
GrBackendRenderTarget backendRT(frame.width(), frame.height(), 0, STENCIL_BUFFER_SIZE, fboInfo);
|
||||
|
||||
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
||||
SkSurfaceProps props(mColorMode == ColorMode::Default ? 0 : SkSurfaceProps::kAlwaysDither_Flag,
|
||||
kUnknown_SkPixelGeometry);
|
||||
|
||||
SkASSERT(mRenderThread.getGrContext() != nullptr);
|
||||
sk_sp<SkSurface> surface;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <SkMultiPictureDocument.h>
|
||||
#include <SkOverdrawCanvas.h>
|
||||
#include <SkOverdrawColorFilter.h>
|
||||
#include <SkPaintFilterCanvas.h>
|
||||
#include <SkPicture.h>
|
||||
#include <SkPictureRecorder.h>
|
||||
#include <SkRect.h>
|
||||
@@ -450,23 +449,6 @@ void SkiaPipeline::endCapture(SkSurface* surface) {
|
||||
}
|
||||
}
|
||||
|
||||
class ForceDitherCanvas : public SkPaintFilterCanvas {
|
||||
public:
|
||||
ForceDitherCanvas(SkCanvas* canvas) : SkPaintFilterCanvas(canvas) {}
|
||||
|
||||
protected:
|
||||
bool onFilter(SkPaint& paint) const override {
|
||||
paint.setDither(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override {
|
||||
// We unroll the drawable using "this" canvas, so that draw calls contained inside will
|
||||
// get dithering applied
|
||||
drawable->draw(this, matrix);
|
||||
}
|
||||
};
|
||||
|
||||
void SkiaPipeline::renderFrame(const LayerUpdateQueue& layers, const SkRect& clip,
|
||||
const std::vector<sp<RenderNode>>& nodes, bool opaque,
|
||||
const Rect& contentDrawBounds, sk_sp<SkSurface> surface,
|
||||
@@ -521,12 +503,6 @@ void SkiaPipeline::renderFrameImpl(const SkRect& clip,
|
||||
canvas->clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
std::optional<ForceDitherCanvas> forceDitherCanvas;
|
||||
if (shouldForceDither()) {
|
||||
forceDitherCanvas.emplace(canvas);
|
||||
canvas = &forceDitherCanvas.value();
|
||||
}
|
||||
|
||||
if (1 == nodes.size()) {
|
||||
if (!nodes[0]->nothingToDraw()) {
|
||||
RenderNodeDrawable root(nodes[0].get(), canvas);
|
||||
|
||||
@@ -98,8 +98,6 @@ protected:
|
||||
|
||||
bool isCapturingSkp() const { return mCaptureMode != CaptureMode::None; }
|
||||
|
||||
virtual bool shouldForceDither() const { return mColorMode != ColorMode::Default; }
|
||||
|
||||
private:
|
||||
void renderFrameImpl(const SkRect& clip,
|
||||
const std::vector<sp<RenderNode>>& nodes, bool opaque,
|
||||
|
||||
@@ -203,11 +203,6 @@ sk_sp<Bitmap> SkiaVulkanPipeline::allocateHardwareBitmap(renderthread::RenderThr
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SkiaVulkanPipeline::shouldForceDither() const {
|
||||
if (mVkSurface && mVkSurface->isBeyond8Bit()) return false;
|
||||
return SkiaPipeline::shouldForceDither();
|
||||
}
|
||||
|
||||
void SkiaVulkanPipeline::onContextDestroyed() {
|
||||
if (mVkSurface) {
|
||||
vulkanManager().destroySurface(mVkSurface);
|
||||
|
||||
@@ -63,8 +63,6 @@ public:
|
||||
protected:
|
||||
void onContextDestroyed() override;
|
||||
|
||||
bool shouldForceDither() const override;
|
||||
|
||||
private:
|
||||
renderthread::VulkanManager& vulkanManager();
|
||||
renderthread::VulkanSurface* mVkSurface = nullptr;
|
||||
|
||||
@@ -453,9 +453,15 @@ VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() {
|
||||
VulkanSurface::NativeBufferInfo* bufferInfo = &mNativeBuffers[idx];
|
||||
|
||||
if (bufferInfo->skSurface.get() == nullptr) {
|
||||
SkSurfaceProps surfaceProps;
|
||||
if (mWindowInfo.colorMode != ColorMode::Default) {
|
||||
surfaceProps = SkSurfaceProps(SkSurfaceProps::kAlwaysDither_Flag | surfaceProps.flags(),
|
||||
surfaceProps.pixelGeometry());
|
||||
}
|
||||
bufferInfo->skSurface = SkSurface::MakeFromAHardwareBuffer(
|
||||
mGrContext, ANativeWindowBuffer_getHardwareBuffer(bufferInfo->buffer.get()),
|
||||
kTopLeft_GrSurfaceOrigin, mWindowInfo.colorspace, nullptr, /*from_window=*/true);
|
||||
kTopLeft_GrSurfaceOrigin, mWindowInfo.colorspace, &surfaceProps,
|
||||
/*from_window=*/true);
|
||||
if (bufferInfo->skSurface.get() == nullptr) {
|
||||
ALOGE("SkSurface::MakeFromAHardwareBuffer failed");
|
||||
mNativeWindow->cancelBuffer(mNativeWindow.get(), buffer,
|
||||
@@ -545,16 +551,6 @@ void VulkanSurface::setColorSpace(sk_sp<SkColorSpace> colorSpace) {
|
||||
}
|
||||
}
|
||||
|
||||
bool VulkanSurface::isBeyond8Bit() const {
|
||||
switch (mWindowInfo.bufferFormat) {
|
||||
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
|
||||
case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace renderthread */
|
||||
} /* namespace uirenderer */
|
||||
} /* namespace android */
|
||||
|
||||
@@ -49,8 +49,6 @@ public:
|
||||
void setColorSpace(sk_sp<SkColorSpace> colorSpace);
|
||||
const SkM44& getPixelSnapMatrix() const { return mWindowInfo.pixelSnapMatrix; }
|
||||
|
||||
bool isBeyond8Bit() const;
|
||||
|
||||
private:
|
||||
/*
|
||||
* All structs/methods in this private section are specifically for use by the VulkanManager
|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:startColor="#000000"
|
||||
android:endColor="#181818"
|
||||
android:endColor="#222222"
|
||||
android:angle="0"/>
|
||||
</shape>
|
||||
Reference in New Issue
Block a user