Commit c451ecdd authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Fix GPURendererPixelTest.SolidColorBlend viz_unittest

Bug: 953284
Change-Id: Ic638c1ddfbc9dc8d05b30c480ff4b946ee3fb177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1687557
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675725}
parent 878cabde
...@@ -1075,9 +1075,7 @@ TYPED_TEST(RendererPixelTest, PremultipliedTextureWithBackground) { ...@@ -1075,9 +1075,7 @@ TYPED_TEST(RendererPixelTest, PremultipliedTextureWithBackground) {
cc::FuzzyPixelOffByOneComparator(true))); cc::FuzzyPixelOffByOneComparator(true)));
} }
// TODO(backer): Blending is not correct for SkiaRenderer TYPED_TEST(GPURendererPixelTest, SolidColorBlend) {
// (https://crbug.com/953284)
TYPED_TEST(GPURendererPixelTest, DISABLED_SolidColorBlend) {
gfx::Rect rect(this->device_viewport_size_); gfx::Rect rect(this->device_viewport_size_);
int id = 1; int id = 1;
...@@ -2381,7 +2379,7 @@ TYPED_TEST(RendererPixelTest, EnlargedRenderPassTexture) { ...@@ -2381,7 +2379,7 @@ TYPED_TEST(RendererPixelTest, EnlargedRenderPassTexture) {
EXPECT_TRUE(this->RunPixelTest( EXPECT_TRUE(this->RunPixelTest(
&pass_list, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), &pass_list, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")),
cc::ExactPixelComparator(true))); cc::FuzzyPixelOffByOneComparator(true)));
} }
TYPED_TEST(RendererPixelTest, EnlargedRenderPassTextureWithAntiAliasing) { TYPED_TEST(RendererPixelTest, EnlargedRenderPassTextureWithAntiAliasing) {
...@@ -4080,7 +4078,7 @@ TYPED_TEST(RendererPixelTestWithFlippedOutputSurface, ExplicitFlipTest) { ...@@ -4080,7 +4078,7 @@ TYPED_TEST(RendererPixelTestWithFlippedOutputSurface, ExplicitFlipTest) {
// right-side up result regardless (i.e., NOT blue_yellow_flipped.png). // right-side up result regardless (i.e., NOT blue_yellow_flipped.png).
EXPECT_TRUE(this->RunPixelTest( EXPECT_TRUE(this->RunPixelTest(
&pass_list, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), &pass_list, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")),
cc::ExactPixelComparator(true))); cc::FuzzyPixelOffByOneComparator(true)));
} }
TYPED_TEST(RendererPixelTestWithFlippedOutputSurface, CheckChildPassUnflipped) { TYPED_TEST(RendererPixelTestWithFlippedOutputSurface, CheckChildPassUnflipped) {
...@@ -4511,22 +4509,10 @@ TYPED_TEST(RendererPixelTest, RoundedCornerOnRenderPass) { ...@@ -4511,22 +4509,10 @@ TYPED_TEST(RendererPixelTest, RoundedCornerOnRenderPass) {
pass_list.push_back(std::move(child_pass)); pass_list.push_back(std::move(child_pass));
pass_list.push_back(std::move(root_pass)); pass_list.push_back(std::move(root_pass));
if (std::is_same<TypeParam, GLRenderer>() || base::FilePath path(FILE_PATH_LITERAL("rounded_corner_render_pass_.png"));
std::is_same<TypeParam, cc::GLRendererWithExpandedViewport>()) { path = path.InsertBeforeExtensionASCII(this->renderer_type());
// GL Renderer should have an exact match as that is the reference point. EXPECT_TRUE(this->RunPixelTest(&pass_list, path,
EXPECT_TRUE(this->RunPixelTest( cc::FuzzyPixelOffByOneComparator(true)));
&pass_list,
base::FilePath(FILE_PATH_LITERAL("rounded_corner_render_pass.png")),
cc::ExactPixelComparator(true)));
} else {
// Software/skia renderer uses skia rrect to create rounded corner clip.
// This results in a different corner path due to a different anti aliasing
// approach than the fragment shader in gl renderer.
EXPECT_TRUE(this->RunPixelTest(
&pass_list,
base::FilePath(FILE_PATH_LITERAL("rounded_corner_render_pass.png")),
cc::FuzzyPixelComparator(true, 0.6f, 0.f, 255.f, 255, 0)));
}
} }
TYPED_TEST(RendererPixelTest, RoundedCornerMultiRadii) { TYPED_TEST(RendererPixelTest, RoundedCornerMultiRadii) {
......
...@@ -86,6 +86,7 @@ class SkiaOutputDevice { ...@@ -86,6 +86,7 @@ class SkiaOutputDevice {
virtual void DiscardBackbuffer(); virtual void DiscardBackbuffer();
bool need_swap_semaphore() const { return need_swap_semaphore_; } bool need_swap_semaphore() const { return need_swap_semaphore_; }
bool is_emulated_rgbx() const { return is_emulated_rgbx_; }
protected: protected:
// Begin paint the back buffer. // Begin paint the back buffer.
...@@ -113,6 +114,9 @@ class SkiaOutputDevice { ...@@ -113,6 +114,9 @@ class SkiaOutputDevice {
base::Optional<BufferPresentedCallback> feedback_; base::Optional<BufferPresentedCallback> feedback_;
base::Optional<gpu::SwapBuffersCompleteParams> params_; base::Optional<gpu::SwapBuffersCompleteParams> params_;
// RGBX format is emulated with RGBA.
bool is_emulated_rgbx_ = false;
DISALLOW_COPY_AND_ASSIGN(SkiaOutputDevice); DISALLOW_COPY_AND_ASSIGN(SkiaOutputDevice);
}; };
......
...@@ -45,8 +45,9 @@ void SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size, ...@@ -45,8 +45,9 @@ void SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size,
nullptr /* surfaceProps */); nullptr /* surfaceProps */);
DCHECK(!!sk_surface_); DCHECK(!!sk_surface_);
// Initialize alpha channel to opaque.
if (!has_alpha_) { if (!has_alpha_) {
is_emulated_rgbx_ = true;
// Initialize alpha channel to opaque.
auto* canvas = sk_surface_->getCanvas(); auto* canvas = sk_surface_->getCanvas();
canvas->clear(SkColorSetARGB(255, 0, 0, 0)); canvas->clear(SkColorSetARGB(255, 0, 0, 0));
} }
......
...@@ -40,6 +40,7 @@ class SkiaOutputDeviceOffscreen : public SkiaOutputDevice { ...@@ -40,6 +40,7 @@ class SkiaOutputDeviceOffscreen : public SkiaOutputDevice {
GrContext* const gr_context_; GrContext* const gr_context_;
const bool has_alpha_; const bool has_alpha_;
sk_sp<SkSurface> sk_surface_; sk_sp<SkSurface> sk_surface_;
bool supports_rgbx_ = true;
private: private:
SkImageInfo image_info_; SkImageInfo image_info_;
......
...@@ -851,6 +851,23 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput( ...@@ -851,6 +851,23 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput(
auto* surface = auto* surface =
from_fbo0 ? output_sk_surface() : offscreen_surfaces_[id].surface(); from_fbo0 ? output_sk_surface() : offscreen_surfaces_[id].surface();
// If a platform doesn't support RGBX_8888 format, we will use RGBA_8888
// instead. In this case, we need discard alpha channel (modify the alpha
// value to 0xff, but keep other channel not changed).
bool need_discard_alpha = from_fbo0 && (output_device_->is_emulated_rgbx());
if (need_discard_alpha) {
base::Optional<gpu::raster::GrShaderCache::ScopedCacheUse> cache_use;
if (dependency_->GetGrShaderCache()) {
cache_use.emplace(dependency_->GetGrShaderCache(),
gpu::kInProcessCommandBufferClientId);
}
SkPaint paint;
paint.setColor(SK_ColorBLACK);
paint.setBlendMode(SkBlendMode::kDstATop);
surface->getCanvas()->drawPaint(paint);
surface->flush();
}
if (!is_using_vulkan() && !features::IsUsingSkiaForGLReadback()) { if (!is_using_vulkan() && !features::IsUsingSkiaForGLReadback()) {
// Lazy initialize GLRendererCopier. // Lazy initialize GLRendererCopier.
if (!copier_) { if (!copier_) {
...@@ -889,6 +906,7 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput( ...@@ -889,6 +906,7 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput(
gl_id = texture_mapper.value().client_id(); gl_id = texture_mapper.value().client_id();
internal_format = GL_RGBA; internal_format = GL_RGBA;
} }
gfx::Size surface_size(surface->width(), surface->height()); gfx::Size surface_size(surface->width(), surface->height());
ScopedUseContextProvider use_context_provider(this, gl_id); ScopedUseContextProvider use_context_provider(this, gl_id);
copier_->CopyFromTextureOrFramebuffer(std::move(request), geometry, copier_->CopyFromTextureOrFramebuffer(std::move(request), geometry,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment