Commit 241d7c77 authored by Sean Gilhuly's avatar Sean Gilhuly Committed by Commit Bot

SkiaRenderer: Disable AA and blending with |force_anti_aliasing_off|

SkiaRenderer is ignoring the flag |force_anti_aliasing_off_| in
RenderPassDrawQuad and SolidColorDrawQuad. Check for this flag and turn
off AA if it is present.

The pixel tests also expect alpha blending to be disabled if this flag
is present, so use blend mode kSrc instead of kSrcOver.

This fixes the tests RenderPassDrawQuadForceAntiAliasingOff and
SolidColorDrawQuadForceAntiAliasingOff for SkiaRenderer, so enable them.
Also enable TileDrawQuadForceAntiAliasingOff and SolidColorDrawQuad,
which are passing after other changes.

Bug: 939442
Change-Id: Ifd4092bbeb9925f0db3a1b25a51785755e06b272
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529296Reviewed-by: default avatarweiliangc <weiliangc@chromium.org>
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644479}
parent 21148739
......@@ -1050,7 +1050,7 @@ TYPED_TEST(RendererPixelTest, PremultipliedTextureWithBackground) {
cc::FuzzyPixelOffByOneComparator(true)));
}
TYPED_TEST(GLOnlyRendererPixelTest, SolidColorBlend) {
TYPED_TEST(GLCapableRendererPixelTest, SolidColorBlend) {
gfx::Rect rect(this->device_viewport_size_);
int id = 1;
......@@ -3131,8 +3131,8 @@ TYPED_TEST(GLOnlyRendererPixelTest, AxisAligned) {
// This test tests that forcing anti-aliasing off works as expected for
// solid color draw quads.
// Anti-aliasing is only supported in the gl renderer.
TYPED_TEST(GLOnlyRendererPixelTest, SolidColorDrawQuadForceAntiAliasingOff) {
// Anti-aliasing is only supported in the gl and skia renderers.
TYPED_TEST(GLCapableRendererPixelTest, SolidColorDrawQuadForceAntiAliasingOff) {
gfx::Rect rect(this->device_viewport_size_);
int id = 1;
......@@ -3168,8 +3168,8 @@ TYPED_TEST(GLOnlyRendererPixelTest, SolidColorDrawQuadForceAntiAliasingOff) {
// This test tests that forcing anti-aliasing off works as expected for
// render pass draw quads.
// Anti-aliasing is only supported in the gl renderer.
TYPED_TEST(GLOnlyRendererPixelTest, RenderPassDrawQuadForceAntiAliasingOff) {
// Anti-aliasing is only supported in the gl and skia renderers.
TYPED_TEST(GLCapableRendererPixelTest, RenderPassDrawQuadForceAntiAliasingOff) {
gfx::Rect rect(this->device_viewport_size_);
int root_pass_id = 1;
......@@ -3226,8 +3226,8 @@ TYPED_TEST(GLOnlyRendererPixelTest, RenderPassDrawQuadForceAntiAliasingOff) {
// This test tests that forcing anti-aliasing off works as expected for
// tile draw quads.
// Anti-aliasing is only supported in the gl renderer.
TYPED_TEST(GLOnlyRendererPixelTest, TileDrawQuadForceAntiAliasingOff) {
// Anti-aliasing is only supported in the gl and skia renderers.
TYPED_TEST(GLCapableRendererPixelTest, TileDrawQuadForceAntiAliasingOff) {
gfx::Rect rect(this->device_viewport_size_);
SkBitmap bitmap;
......
......@@ -1069,7 +1069,15 @@ void SkiaRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
SkPaint* paint) {
DCHECK(paint);
paint->setColor(quad->color);
paint->setAlpha(quad->shared_quad_state->opacity * SkColorGetA(quad->color));
// The flag |force_anti_aliasing_off| is also expected to disable alpha
// blending, so set full opacity.
if (quad->force_anti_aliasing_off) {
paint->setAlpha(255);
paint->setAntiAlias(false);
} else {
paint->setAlpha(quad->shared_quad_state->opacity *
SkColorGetA(quad->color));
}
current_canvas_->drawRect(gfx::RectToSkRect(quad->visible_rect), *paint);
}
......@@ -1279,6 +1287,14 @@ const TileDrawQuad* SkiaRenderer::CanPassBeDrawnDirectly(
void SkiaRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad,
SkPaint* paint) {
DCHECK(paint);
// The flag |force_anti_aliasing_off| is also expected to disable alpha
// blending, so switch from kSrcOver blending to kSrc.
if (quad->force_anti_aliasing_off) {
paint->setAntiAlias(false);
if (paint->isSrcOver()) {
paint->setBlendMode(SkBlendMode::kSrc);
}
}
auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id);
// When Render Pass has a single quad inside we would draw that directly.
if (bypass != render_pass_bypass_quads_.end()) {
......
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