| Index: cc/output/renderer_pixeltest.cc
|
| diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
|
| index d7149e5916c11def0b77e1819fa5ede3ebf38e4f..9a14525ea340024b5dd3a1533e9626a5de5d16be 100644
|
| --- a/cc/output/renderer_pixeltest.cc
|
| +++ b/cc/output/renderer_pixeltest.cc
|
| @@ -7,6 +7,7 @@
|
| #include "cc/output/gl_renderer.h"
|
| #include "cc/quads/draw_quad.h"
|
| #include "cc/quads/picture_draw_quad.h"
|
| +#include "cc/quads/texture_draw_quad.h"
|
| #include "cc/resources/platform_color.h"
|
| #include "cc/resources/sync_point_helper.h"
|
| #include "cc/test/fake_picture_pile_impl.h"
|
| @@ -94,6 +95,41 @@ scoped_ptr<DrawQuad> CreateTestRenderPassDrawQuad(
|
| return quad.PassAs<DrawQuad>();
|
| }
|
|
|
| +scoped_ptr<TextureDrawQuad> CreateTestTextureDrawQuad(
|
| + gfx::Rect rect,
|
| + SkColor texel_color,
|
| + SkColor background_color,
|
| + SharedQuadState* shared_state,
|
| + ResourceProvider* resource_provider) {
|
| + SkBitmap image;
|
| + image.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height());
|
| + image.allocPixels();
|
| + image.eraseColor(texel_color);
|
| + ResourceProvider::ResourceId resource = resource_provider->CreateResource(
|
| + rect.size(), GL_RGBA, ResourceProvider::TextureUsageAny);
|
| + resource_provider->SetPixels(
|
| + resource,
|
| + static_cast<uint8_t*>(image.getAddr(0, 0)),
|
| + rect,
|
| + rect,
|
| + gfx::Vector2d());
|
| +
|
| + float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
| +
|
| + scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
|
| + quad->SetNew(shared_state,
|
| + rect,
|
| + gfx::Rect(),
|
| + resource,
|
| + true, // premultiplied_alpha
|
| + gfx::PointF(0.0f, 0.0f), // uv_top_left
|
| + gfx::PointF(1.0f, 1.0f), // uv_bottom_right
|
| + vertex_opacity,
|
| + background_color,
|
| + false); // flipped
|
| + return quad.Pass();
|
| +}
|
| +
|
| typedef ::testing::Types<GLRenderer,
|
| SoftwareRenderer,
|
| GLRendererWithExpandedViewport,
|
| @@ -218,6 +254,69 @@ TYPED_TEST(RendererPixelTest, SimpleGreenRect_NonRootRenderPass) {
|
| ExactPixelComparator(true)));
|
| }
|
|
|
| +TYPED_TEST(RendererPixelTest, TextureWithoutBackground) {
|
| + gfx::Rect rect(this->device_viewport_size_);
|
| +
|
| + RenderPass::Id id(1, 1);
|
| + scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
|
| +
|
| + scoped_ptr<SharedQuadState> shared_state =
|
| + CreateTestSharedQuadState(gfx::Transform(), rect);
|
| +
|
| + scoped_ptr<TextureDrawQuad> texture_quad = CreateTestTextureDrawQuad(
|
| + gfx::Rect(this->device_viewport_size_),
|
| + SkColorSetARGB(128, 0, 255, 0), // Texel color.
|
| + SK_ColorTRANSPARENT, // Background color.
|
| + shared_state.get(),
|
| + this->resource_provider_.get());
|
| + pass->quad_list.push_back(texture_quad.PassAs<DrawQuad>());
|
| +
|
| + scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create();
|
| + color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false);
|
| + pass->quad_list.push_back(color_quad.PassAs<DrawQuad>());
|
| +
|
| + RenderPassList pass_list;
|
| + pass_list.push_back(pass.Pass());
|
| +
|
| + EXPECT_TRUE(this->RunPixelTest(
|
| + &pass_list,
|
| + base::FilePath(FILE_PATH_LITERAL("green_alpha.png")),
|
| + FuzzyPixelOffByOneComparator(true)));
|
| +}
|
| +
|
| +TYPED_TEST(RendererPixelTest, TextureWithBackground) {
|
| + gfx::Rect rect(this->device_viewport_size_);
|
| +
|
| + RenderPass::Id id(1, 1);
|
| + scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
|
| +
|
| + scoped_ptr<SharedQuadState> texture_quad_state =
|
| + CreateTestSharedQuadState(gfx::Transform(), rect);
|
| + texture_quad_state->opacity = 0.5f;
|
| +
|
| + scoped_ptr<TextureDrawQuad> texture_quad = CreateTestTextureDrawQuad(
|
| + gfx::Rect(this->device_viewport_size_),
|
| + SK_ColorTRANSPARENT, // Texel color.
|
| + SK_ColorGREEN, // Background color.
|
| + texture_quad_state.get(),
|
| + this->resource_provider_.get());
|
| + pass->quad_list.push_back(texture_quad.PassAs<DrawQuad>());
|
| +
|
| + scoped_ptr<SharedQuadState> color_quad_state =
|
| + CreateTestSharedQuadState(gfx::Transform(), rect);
|
| + scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create();
|
| + color_quad->SetNew(color_quad_state.get(), rect, SK_ColorWHITE, false);
|
| + pass->quad_list.push_back(color_quad.PassAs<DrawQuad>());
|
| +
|
| + RenderPassList pass_list;
|
| + pass_list.push_back(pass.Pass());
|
| +
|
| + EXPECT_TRUE(this->RunPixelTest(
|
| + &pass_list,
|
| + base::FilePath(FILE_PATH_LITERAL("green_alpha.png")),
|
| + FuzzyPixelOffByOneComparator(true)));
|
| +}
|
| +
|
| class VideoGLRendererPixelTest : public GLRendererPixelTest {
|
| protected:
|
| scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad(
|
|
|