diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-17 19:29:50 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-17 19:29:50 +0000 |
commit | 1bc93f667548c5a5eb9c90c628dea214ebfbed18 (patch) | |
tree | a3447a61157da9c36fa0ad4f0427eb99f3d57174 | |
parent | 84b8e013503568c3955fa0ddf8461002a5bd9e63 (diff) | |
download | chromium_src-1bc93f667548c5a5eb9c90c628dea214ebfbed18.zip chromium_src-1bc93f667548c5a5eb9c90c628dea214ebfbed18.tar.gz chromium_src-1bc93f667548c5a5eb9c90c628dea214ebfbed18.tar.bz2 |
cc: Turn DrawQuad into a struct-like class with public data members.
We add a SetAll() method that sets everything to keep the compile-time guard
that verifies everything gets set from all appropriate callsites. This replaces
the constructor which now takes no arguments at all.
We will replace the constructor with an overriding SetAll() for
each subclass of DrawQuads and make them into structs as well.
Covered by existing tests.
TBR=aelias
BUG=152337
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/11418047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168460 0039d316-1c4b-4281-b951-d872f2087c98
26 files changed, 208 insertions, 209 deletions
diff --git a/cc/checkerboard_draw_quad.cc b/cc/checkerboard_draw_quad.cc index 709bade..892d2bd 100644 --- a/cc/checkerboard_draw_quad.cc +++ b/cc/checkerboard_draw_quad.cc @@ -14,16 +14,17 @@ scoped_ptr<CheckerboardDrawQuad> CheckerboardDrawQuad::create(const SharedQuadSt } CheckerboardDrawQuad::CheckerboardDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, SkColor color) - : DrawQuad(sharedQuadState, DrawQuad::CHECKERBOARD, quadRect, quadRect) - , m_color(color) + : m_color(color) { - if (SkColorGetA(m_color) < 255) - opaque_rect_ = gfx::Rect(); + gfx::Rect opaqueRect = SkColorGetA(m_color) == 255 ? quadRect : gfx::Rect(); + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::CHECKERBOARD, quadRect, opaqueRect, visibleRect, needsBlending); } const CheckerboardDrawQuad* CheckerboardDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::CHECKERBOARD); + DCHECK(quad->material == DrawQuad::CHECKERBOARD); return static_cast<const CheckerboardDrawQuad*>(quad); } diff --git a/cc/debug_border_draw_quad.cc b/cc/debug_border_draw_quad.cc index 6d95818..8009128 100644 --- a/cc/debug_border_draw_quad.cc +++ b/cc/debug_border_draw_quad.cc @@ -14,17 +14,18 @@ scoped_ptr<DebugBorderDrawQuad> DebugBorderDrawQuad::create(const SharedQuadStat } DebugBorderDrawQuad::DebugBorderDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, SkColor color, int width) - : DrawQuad(sharedQuadState, DrawQuad::DEBUG_BORDER, quadRect, gfx::Rect()) - , m_color(color) + : m_color(color) , m_width(width) { - if (SkColorGetA(m_color) < 255) - needs_blending_ = true; + gfx::Rect opaqueRect; + gfx::Rect visibleRect = quadRect; + bool needsBlending = SkColorGetA(m_color) < 255; + DrawQuad::SetAll(sharedQuadState, DrawQuad::DEBUG_BORDER, quadRect, opaqueRect, visibleRect, needsBlending); } const DebugBorderDrawQuad* DebugBorderDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::DEBUG_BORDER); + DCHECK(quad->material == DrawQuad::DEBUG_BORDER); return static_cast<const DebugBorderDrawQuad*>(quad); } diff --git a/cc/delegated_renderer_layer_impl.cc b/cc/delegated_renderer_layer_impl.cc index 6d63961..e8d3b06 100644 --- a/cc/delegated_renderer_layer_impl.cc +++ b/cc/delegated_renderer_layer_impl.cc @@ -140,10 +140,10 @@ void DelegatedRendererLayerImpl::appendRenderPassQuads(QuadSink& quadSink, Appen const SharedQuadState* currentSharedQuadState = 0; SharedQuadState* copiedSharedQuadState = 0; for (size_t i = 0; i < delegatedRenderPass->quadList().size(); ++i) { - DrawQuad* quad = delegatedRenderPass->quadList()[i]; + const DrawQuad* quad = delegatedRenderPass->quadList()[i]; - if (quad->shared_quad_state() != currentSharedQuadState) { - currentSharedQuadState = quad->shared_quad_state(); + if (quad->shared_quad_state != currentSharedQuadState) { + currentSharedQuadState = quad->shared_quad_state; copiedSharedQuadState = quadSink.useSharedQuadState(currentSharedQuadState->copy()); bool targetIsFromDelegatedRendererLayer = appendQuadsData.renderPassId.layerId == id(); if (!targetIsFromDelegatedRendererLayer) { @@ -160,7 +160,7 @@ void DelegatedRendererLayerImpl::appendRenderPassQuads(QuadSink& quadSink, Appen DCHECK(copiedSharedQuadState); scoped_ptr<DrawQuad> copyQuad; - if (quad->material() != DrawQuad::RENDER_PASS) + if (quad->material != DrawQuad::RENDER_PASS) copyQuad = quad->Copy(copiedSharedQuadState); else { RenderPass::Id contributingDelegatedRenderPassId = RenderPassDrawQuad::materialCast(quad)->renderPassId(); diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc index f580cee..3240101 100644 --- a/cc/delegated_renderer_layer_impl_unittest.cc +++ b/cc/delegated_renderer_layer_impl_unittest.cc @@ -209,14 +209,14 @@ TEST_F(DelegatedRendererLayerImplTestSimple, AddsQuadsToContributingRenderPasses // The DelegatedRendererLayer should have added copies of its quads to contributing RenderPasses. ASSERT_EQ(1u, frame.renderPasses[1]->quadList().size()); - EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect); // Verify it added the right quads. ASSERT_EQ(2u, frame.renderPasses[2]->quadList().size()); - EXPECT_RECT_EQ(gfx::Rect(0, 0, 7, 7), frame.renderPasses[2]->quadList()[0]->rect()); - EXPECT_RECT_EQ(gfx::Rect(6, 6, 6, 6), frame.renderPasses[2]->quadList()[1]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 7, 7), frame.renderPasses[2]->quadList()[0]->rect); + EXPECT_RECT_EQ(gfx::Rect(6, 6, 6, 6), frame.renderPasses[2]->quadList()[1]->rect); ASSERT_EQ(1u, frame.renderPasses[1]->quadList().size()); - EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect); } TEST_F(DelegatedRendererLayerImplTestSimple, AddsQuadsToTargetRenderPass) @@ -237,10 +237,10 @@ TEST_F(DelegatedRendererLayerImplTestSimple, AddsQuadsToTargetRenderPass) ASSERT_EQ(2u, frame.renderPasses[3]->quadList().size()); // Verify it added the right quads. - EXPECT_RECT_EQ(gfx::Rect(7, 7, 7, 7), frame.renderPasses[3]->quadList()[0]->rect()); + EXPECT_RECT_EQ(gfx::Rect(7, 7, 7, 7), frame.renderPasses[3]->quadList()[0]->rect); // Its target layer should have a quad as well. - EXPECT_RECT_EQ(gfx::Rect(0, 0, 15, 15), frame.renderPasses[3]->quadList()[1]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 15, 15), frame.renderPasses[3]->quadList()[1]->rect); } TEST_F(DelegatedRendererLayerImplTestSimple, QuadsFromRootRenderPassAreModifiedForTheTarget) @@ -325,14 +325,14 @@ TEST_F(DelegatedRendererLayerImplTestOwnSurface, AddsQuadsToContributingRenderPa // The DelegatedRendererLayer should have added copies of its quads to contributing RenderPasses. ASSERT_EQ(1u, frame.renderPasses[1]->quadList().size()); - EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect); // Verify it added the right quads. ASSERT_EQ(2u, frame.renderPasses[2]->quadList().size()); - EXPECT_RECT_EQ(gfx::Rect(0, 0, 7, 7), frame.renderPasses[2]->quadList()[0]->rect()); - EXPECT_RECT_EQ(gfx::Rect(6, 6, 6, 6), frame.renderPasses[2]->quadList()[1]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 7, 7), frame.renderPasses[2]->quadList()[0]->rect); + EXPECT_RECT_EQ(gfx::Rect(6, 6, 6, 6), frame.renderPasses[2]->quadList()[1]->rect); ASSERT_EQ(1u, frame.renderPasses[1]->quadList().size()); - EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect()); + EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 6), frame.renderPasses[1]->quadList()[0]->rect); } TEST_F(DelegatedRendererLayerImplTestOwnSurface, AddsQuadsToTargetRenderPass) @@ -353,7 +353,7 @@ TEST_F(DelegatedRendererLayerImplTestOwnSurface, AddsQuadsToTargetRenderPass) ASSERT_EQ(1u, frame.renderPasses[3]->quadList().size()); // Verify it added the right quads. - EXPECT_RECT_EQ(gfx::Rect(7, 7, 7, 7), frame.renderPasses[3]->quadList()[0]->rect()); + EXPECT_RECT_EQ(gfx::Rect(7, 7, 7, 7), frame.renderPasses[3]->quadList()[0]->rect); } TEST_F(DelegatedRendererLayerImplTestOwnSurface, QuadsFromRootRenderPassAreNotModifiedForTheTarget) @@ -440,10 +440,10 @@ TEST_F(DelegatedRendererLayerImplTestSharedData, SharedData) ASSERT_EQ(4u, quadList.size()); // All quads should share the same state. - const SharedQuadState* sharedState = quadList[0]->shared_quad_state(); - EXPECT_EQ(sharedState, quadList[1]->shared_quad_state()); - EXPECT_EQ(sharedState, quadList[2]->shared_quad_state()); - EXPECT_EQ(sharedState, quadList[3]->shared_quad_state()); + const SharedQuadState* sharedState = quadList[0]->shared_quad_state; + EXPECT_EQ(sharedState, quadList[1]->shared_quad_state); + EXPECT_EQ(sharedState, quadList[2]->shared_quad_state); + EXPECT_EQ(sharedState, quadList[3]->shared_quad_state); // The state should be transformed only once. EXPECT_RECT_EQ(gfx::Rect(30, 30, 50, 50), sharedState->clippedRectInTarget); diff --git a/cc/draw_quad.cc b/cc/draw_quad.cc index 495cfb7..c052748 100644 --- a/cc/draw_quad.cc +++ b/cc/draw_quad.cc @@ -25,18 +25,27 @@ template<typename T> T* TypedCopy(const cc::DrawQuad* other) { namespace cc { -DrawQuad::DrawQuad(const SharedQuadState* shared_quad_state, - Material material, - gfx::Rect rect, - gfx::Rect opaque_rect) - : shared_quad_state_(shared_quad_state), - material_(material), - rect_(rect), - visible_rect_(rect), - needs_blending_(false), - opaque_rect_(opaque_rect) { - DCHECK(shared_quad_state_); - DCHECK(material_ != INVALID); +DrawQuad::DrawQuad() + : shared_quad_state(), + material(INVALID), + needs_blending(false) { +} + +void DrawQuad::SetAll(const SharedQuadState* shared_quad_state, + Material material, + gfx::Rect rect, + gfx::Rect opaque_rect, + gfx::Rect visible_rect, + bool needs_blending) { + this->material = material; + this->rect = rect; + this->opaque_rect = opaque_rect; + this->visible_rect = visible_rect; + this->needs_blending = needs_blending; + this->shared_quad_state = shared_quad_state; + + DCHECK(shared_quad_state); + DCHECK(material != INVALID); } DrawQuad::~DrawQuad() { @@ -46,7 +55,7 @@ scoped_ptr<DrawQuad> DrawQuad::Copy( const SharedQuadState* copied_shared_quad_state) const { scoped_ptr<DrawQuad> copy_quad; - switch (material()) { + switch (material) { case CHECKERBOARD: copy_quad.reset(TypedCopy<CheckerboardDrawQuad>(this)); break; @@ -73,10 +82,10 @@ scoped_ptr<DrawQuad> DrawQuad::Copy( break; case RENDER_PASS: // RenderPass quads have their own copy() method. case INVALID: - LOG(FATAL) << "Invalid DrawQuad material " << material(); + LOG(FATAL) << "Invalid DrawQuad material " << material; break; } - copy_quad->set_shared_quad_state(copied_shared_quad_state); + copy_quad->shared_quad_state = copied_shared_quad_state; return copy_quad.Pass(); } diff --git a/cc/draw_quad.h b/cc/draw_quad.h index 898bde8..255d354 100644 --- a/cc/draw_quad.h +++ b/cc/draw_quad.h @@ -35,75 +35,49 @@ class CC_EXPORT DrawQuad { const SharedQuadState* copied_shared_quad_state) const; // TODO(danakj): Chromify or remove these SharedQuadState helpers. - const WebKit::WebTransformationMatrix& quadTransform() const { return shared_quad_state_->quadTransform; } - gfx::Rect visibleContentRect() const { return shared_quad_state_->visibleContentRect; } - gfx::Rect clippedRectInTarget() const { return shared_quad_state_->clippedRectInTarget; } - float opacity() const { return shared_quad_state_->opacity; } + const WebKit::WebTransformationMatrix& quadTransform() const { return shared_quad_state->quadTransform; } + gfx::Rect visibleContentRect() const { return shared_quad_state->visibleContentRect; } + gfx::Rect clippedRectInTarget() const { return shared_quad_state->clippedRectInTarget; } + float opacity() const { return shared_quad_state->opacity; } - Material material() const { return material_; } + Material material; // This rect, after applying the quad_transform(), gives the geometry that // this quad should draw to. - gfx::Rect rect() const { return rect_; } + gfx::Rect rect; // This specifies the region of the quad that is opaque. - gfx::Rect opaque_rect() const { return opaque_rect_; } + gfx::Rect opaque_rect; // Allows changing the rect that gets drawn to make it smaller. This value // should be clipped to quadRect. - gfx::Rect visible_rect() const { return visible_rect_; } - - // Allows changing the rect that gets drawn to make it smaller. Parameter - // passed in will be clipped to quadRect(). - void set_visible_rect(gfx::Rect rect) { visible_rect_ = rect; } + gfx::Rect visible_rect; // By default blending is used when some part of the quad is not opaque. // With this setting, it is possible to force blending on regardless of the // opaque area. - bool needs_blending() const { return needs_blending_; } + bool needs_blending; // Stores state common to a large bundle of quads; kept separate for memory // efficiency. There is special treatment to reconstruct these pointers // during serialization. - const SharedQuadState* shared_quad_state() const { - return shared_quad_state_; - } - - // Allows changing the rect that gets drawn to make it smaller. Parameter - // passed in will be clipped to quadRect(). - void set_shared_quad_state(const SharedQuadState* shared_quad_state) { - shared_quad_state_ = shared_quad_state; - } + const SharedQuadState* shared_quad_state; - bool IsDebugQuad() const { return material_ == DEBUG_BORDER; } + bool IsDebugQuad() const { return material == DEBUG_BORDER; } bool ShouldDrawWithBlending() const { - return needs_blending_ || opacity() < 1.0f || - !opaque_rect_.Contains(visible_rect_); + return needs_blending || shared_quad_state->opacity < 1.0f || + !opaque_rect.Contains(visible_rect); } protected: - DrawQuad(const SharedQuadState* shared_quad_state, - Material material, - gfx::Rect rect, - gfx::Rect opaque_rect); - - // Stores state common to a large bundle of quads; kept separate for memory - // efficiency. There is special treatment to reconstruct these pointers - // during serialization. - const SharedQuadState* shared_quad_state_; - - Material material_; - gfx::Rect rect_; - gfx::Rect visible_rect_; - - // By default blending is used when some part of the quad is not opaque. With - // this setting, it is possible to force blending on regardless of the opaque - // area. - bool needs_blending_; - - // Be default, this rect is empty. It is used when the shared quad state and above - // variables determine that the quad is not fully opaque but may be partially opaque. - gfx::Rect opaque_rect_; + DrawQuad(); + + void SetAll(const SharedQuadState* shared_quad_state, + Material material, + gfx::Rect rect, + gfx::Rect opaque_rect, + gfx::Rect visible_rect, + bool needs_blending); }; } diff --git a/cc/draw_quad_unittest.cc b/cc/draw_quad_unittest.cc index 7b4093e..90f35fd 100644 --- a/cc/draw_quad_unittest.cc +++ b/cc/draw_quad_unittest.cc @@ -56,12 +56,12 @@ scoped_ptr<SharedQuadState> createSharedQuadState() void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copySharedState) { - EXPECT_EQ(quad->material(), copy->material()); - EXPECT_RECT_EQ(quad->rect(), copy->rect()); - EXPECT_RECT_EQ(quad->visible_rect(), copy->visible_rect()); - EXPECT_RECT_EQ(quad->opaque_rect(), copy->opaque_rect()); - EXPECT_EQ(quad->needs_blending(), copy->needs_blending()); - EXPECT_EQ(copySharedState, copy->shared_quad_state()); + EXPECT_EQ(quad->material, copy->material); + EXPECT_RECT_EQ(quad->rect, copy->rect); + EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); + EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); + EXPECT_EQ(quad->needs_blending, copy->needs_blending); + EXPECT_EQ(copySharedState, copy->shared_quad_state); } #define CREATE_SHARED_STATE() \ @@ -74,13 +74,13 @@ void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared gfx::Rect quadVisibleRect(40, 50, 30, 20); #define SETUP_AND_COPY_QUAD(Type, quad) \ - quad->set_visible_rect(quadVisibleRect); \ + quad->visible_rect = quadVisibleRect; \ scoped_ptr<DrawQuad> copy(quad->Copy(copySharedState.get())); \ compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ const Type* copyQuad = Type::materialCast(copy.get()); #define SETUP_AND_COPY_QUAD_1(Type, quad, a) \ - quad->set_visible_rect(quadVisibleRect); \ + quad->visible_rect = quadVisibleRect; \ scoped_ptr<DrawQuad> copy(quad->copy(copySharedState.get(), a)); \ compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ const Type* copyQuad = Type::materialCast(copy.get()); @@ -168,7 +168,7 @@ TEST(DrawQuadTest, copyIOSurfaceDrawQuad) CREATE_SHARED_STATE(); CREATE_QUAD_4(IOSurfaceDrawQuad, opaqueRect, size, textureId, orientation); - EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); + EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); EXPECT_EQ(size, copyQuad->ioSurfaceSize()); EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); EXPECT_EQ(orientation, copyQuad->orientation()); @@ -216,7 +216,7 @@ TEST(DrawQuadTest, copyStreamVideoDrawQuad) CREATE_SHARED_STATE(); CREATE_QUAD_3(StreamVideoDrawQuad, opaqueRect, textureId, matrix); - EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); + EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); EXPECT_EQ(textureId, copyQuad->textureId()); EXPECT_EQ(matrix, copyQuad->matrix()); } @@ -231,7 +231,7 @@ TEST(DrawQuadTest, copyTextureDrawQuad) CREATE_SHARED_STATE(); CREATE_QUAD_5(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlpha, uvRect, flipped); - EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); + EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); EXPECT_EQ(resourceId, copyQuad->resourceId()); EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect()); @@ -252,7 +252,7 @@ TEST(DrawQuadTest, copyTileDrawQuad) CREATE_SHARED_STATE(); CREATE_QUAD_9(TileDrawQuad, opaqueRect, resourceId, textureOffset, textureSize, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); - EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); + EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); EXPECT_EQ(resourceId, copyQuad->resourceId()); EXPECT_EQ(textureOffset, copyQuad->textureOffset()); EXPECT_EQ(textureSize, copyQuad->textureSize()); @@ -282,7 +282,7 @@ TEST(DrawQuadTest, copyYUVVideoDrawQuad) CREATE_SHARED_STATE(); CREATE_QUAD_5(YUVVideoDrawQuad, opaqueRect, texScale, yPlane, uPlane, vPlane); - EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); + EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); EXPECT_EQ(texScale, copyQuad->texScale()); EXPECT_EQ(yPlane.resourceId, copyQuad->yPlane().resourceId); EXPECT_EQ(yPlane.size, copyQuad->yPlane().size); diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index 44a135b..e43b8ec 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -250,14 +250,14 @@ void GLRenderer::doNoOp() void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) { - DCHECK(quad->rect().Contains(quad->visible_rect())); + DCHECK(quad->rect.Contains(quad->visible_rect)); if (quad->ShouldDrawWithBlending()) GLC(m_context, m_context->enable(GL_BLEND)); else GLC(m_context, m_context->disable(GL_BLEND)); - switch (quad->material()) { + switch (quad->material) { case DrawQuad::INVALID: NOTREACHED(); break; @@ -303,7 +303,7 @@ void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo const int checkerboardWidth = 16; float frequency = 1.0 / checkerboardWidth; - gfx::Rect tileRect = quad->rect(); + gfx::Rect tileRect = quad->rect; float texOffsetX = tileRect.x() % checkerboardWidth; float texOffsetY = tileRect.y() % checkerboardWidth; float texScaleX = tileRect.width(); @@ -313,7 +313,7 @@ void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocation(), frequency)); setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), program->vertexShader().matrixLocation()); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexShader().matrixLocation()); } void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorderDrawQuad* quad) @@ -324,7 +324,7 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde GLC(context(), context()->useProgram(program->program())); // Use the full quadRect for debug quads to not move the edges based on partial swaps. - const gfx::Rect& layerRect = quad->rect(); + const gfx::Rect& layerRect = quad->rect; WebTransformationMatrix renderMatrix = quad->quadTransform(); renderMatrix.translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y()); renderMatrix.scaleNonUniform(layerRect.width(), layerRect.height()); @@ -480,17 +480,17 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters( int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); scoped_ptr<ScopedResource> backgroundTexture = ScopedResource::create(m_resourceProvider); - if (!backgroundTexture->Allocate(Renderer::ImplPool, quad->rect().size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) + if (!backgroundTexture->Allocate(Renderer::ImplPool, quad->rect.size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) return scoped_ptr<ScopedResource>(); const RenderPass* targetRenderPass = frame.currentRenderPass; - bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(), quad->rect()); + bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(), quad->rect); if (usingBackgroundTexture) { // Copy the readback pixels from device to the background texture for the surface. WebTransformationMatrix deviceToFramebufferTransform; - deviceToFramebufferTransform.translate(quad->rect().width() / 2.0, quad->rect().height() / 2.0); - deviceToFramebufferTransform.scale3d(quad->rect().width(), quad->rect().height(), 1); + deviceToFramebufferTransform.translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0); + deviceToFramebufferTransform.scale3d(quad->rect.width(), quad->rect.height(), 1); deviceToFramebufferTransform.multiply(contentsDeviceTransformInverse); copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform); } @@ -514,7 +514,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua return; WebTransformationMatrix quadRectMatrix; - quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect()); + quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform(); // Can only draw surface if device matrix is invertible. @@ -546,9 +546,9 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua // Draw the background texture if there is one. if (backgroundTexture) { - DCHECK(backgroundTexture->size() == quad->rect().size()); + DCHECK(backgroundTexture->size() == quad->rect.size()); ResourceProvider::ScopedReadLockGL lock(m_resourceProvider, backgroundTexture->id()); - copyTextureToFramebuffer(frame, lock.textureId(), quad->rect(), quad->quadTransform()); + copyTextureToFramebuffer(frame, lock.textureId(), quad->rect, quad->quadTransform()); } bool clipped = false; @@ -646,7 +646,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua setShaderOpacity(quad->opacity(), shaderAlphaLocation); setShaderQuadF(surfaceQuad, shaderQuadLocation); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), shaderMatrixLocation); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocation); // Flush the compositor context before the filter bitmap goes out of // scope, so the draw gets processed before the filter texture gets deleted. @@ -665,7 +665,7 @@ void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation(), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, (SkColorGetB(color) / 255.0) * alpha, alpha)); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), program->vertexShader().matrixLocation()); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexShader().matrixLocation()); } struct TileProgramUniforms { @@ -695,7 +695,7 @@ static void tileUniformLocation(T program, TileProgramUniforms& uniforms) void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* quad) { - gfx::Rect tileRect = quad->visible_rect(); + gfx::Rect tileRect = quad->visible_rect; gfx::RectF clampRect(tileRect); // Clamp texture coordinates to avoid sampling outside the layer @@ -709,7 +709,7 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua float clampY = min(0.5, clampRect.height() / 2.0 - epsilon); clampRect.Inset(clampX, clampY, clampX, clampY); - gfx::Vector2dF textureOffset = quad->textureOffset() + (clampRect.origin() - quad->rect().origin()); + gfx::Vector2dF textureOffset = quad->textureOffset() + (clampRect.origin() - quad->rect.origin()); // Map clamping rectangle to unit square. float vertexTexTranslateX = -clampRect.x() / clampRect.width(); @@ -798,13 +798,13 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua LayerQuad::Edge rightEdge(topRight, bottomRight); // Only apply anti-aliasing to edges not clipped by culling or scissoring. - if (quad->topEdgeAA() && tileRect.y() == quad->rect().y()) + if (quad->topEdgeAA() && tileRect.y() == quad->rect.y()) topEdge = deviceLayerEdges.top(); - if (quad->leftEdgeAA() && tileRect.x() == quad->rect().x()) + if (quad->leftEdgeAA() && tileRect.x() == quad->rect.x()) leftEdge = deviceLayerEdges.left(); - if (quad->rightEdgeAA() && tileRect.right() == quad->rect().right()) + if (quad->rightEdgeAA() && tileRect.right() == quad->rect.right()) rightEdge = deviceLayerEdges.right(); - if (quad->bottomEdgeAA() && tileRect.bottom() == quad->rect().bottom()) + if (quad->bottomEdgeAA() && tileRect.bottom() == quad->rect.bottom()) bottomEdge = deviceLayerEdges.bottom(); float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; @@ -903,7 +903,7 @@ void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQ GLC(context(), context()->uniform3fv(program->fragmentShader().yuvAdjLocation(), 1, yuvAdjust)); setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), program->vertexShader().matrixLocation()); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexShader().matrixLocation()); // Reset active texture back to texture 0. GLC(context(), context()->activeTexture(GL_TEXTURE0)); @@ -926,7 +926,7 @@ void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVide GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocation(), 0)); setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), program->vertexShader().matrixLocation()); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexShader().matrixLocation()); } struct TextureProgramBinding { @@ -981,7 +981,7 @@ void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua } setShaderOpacity(quad->opacity(), binding.alphaLocation); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), binding.matrixLocation); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, binding.matrixLocation); if (!quad->premultipliedAlpha()) GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); @@ -1002,7 +1002,7 @@ void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra GLC(context(), context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, quad->ioSurfaceTextureId())); setShaderOpacity(quad->opacity(), binding.alphaLocation); - drawQuadGeometry(frame, quad->quadTransform(), quad->rect(), binding.matrixLocation); + drawQuadGeometry(frame, quad->quadTransform(), quad->rect, binding.matrixLocation); GLC(context(), context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); } diff --git a/cc/io_surface_draw_quad.cc b/cc/io_surface_draw_quad.cc index 5c465f2..35ab66e 100644 --- a/cc/io_surface_draw_quad.cc +++ b/cc/io_surface_draw_quad.cc @@ -14,16 +14,18 @@ scoped_ptr<IOSurfaceDrawQuad> IOSurfaceDrawQuad::create(const SharedQuadState* s } IOSurfaceDrawQuad::IOSurfaceDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, const gfx::Rect& opaqueRect, const gfx::Size& ioSurfaceSize, unsigned ioSurfaceTextureId, Orientation orientation) - : DrawQuad(sharedQuadState, DrawQuad::IO_SURFACE_CONTENT, quadRect, opaqueRect) - , m_ioSurfaceSize(ioSurfaceSize) + : m_ioSurfaceSize(ioSurfaceSize) , m_ioSurfaceTextureId(ioSurfaceTextureId) , m_orientation(orientation) { + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::IO_SURFACE_CONTENT, quadRect, opaqueRect, visibleRect, needsBlending); } const IOSurfaceDrawQuad* IOSurfaceDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::IO_SURFACE_CONTENT); + DCHECK(quad->material == DrawQuad::IO_SURFACE_CONTENT); return static_cast<const IOSurfaceDrawQuad*>(quad); } diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 24f7a8e..8c2df3c 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -468,8 +468,8 @@ bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) #ifndef NDEBUG for (size_t i = 0; i < frame.renderPasses.size(); ++i) { for (size_t j = 0; j < frame.renderPasses[i]->quadList().size(); ++j) { - DCHECK(frame.renderPasses[i]->quadList()[j]->shared_quad_state()); - DCHECK_GE(frame.renderPasses[i]->quadList()[j]->shared_quad_state()->id, 0); + DCHECK(frame.renderPasses[i]->quadList()[j]->shared_quad_state); + DCHECK_GE(frame.renderPasses[i]->quadList()[j]->shared_quad_state->id, 0); } DCHECK(frame.renderPassesById.contains(frame.renderPasses[i]->id())); } @@ -562,7 +562,7 @@ static void removeRenderPassesRecursive(RenderPass::Id removeRenderPassId, Layer QuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin(); for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) { DrawQuad* currentQuad = (*quadListIterator); - if (currentQuad->material() != DrawQuad::RENDER_PASS) + if (currentQuad->material != DrawQuad::RENDER_PASS) continue; RenderPass::Id nextRemoveRenderPassId = RenderPassDrawQuad::materialCast(currentQuad)->renderPassId(); @@ -590,7 +590,7 @@ bool LayerTreeHostImpl::CullRenderPassesWithNoQuads::shouldRemoveRenderPass(cons for (QuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin(); quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) { DrawQuad* currentQuad = *quadListIterator; - if (currentQuad->material() != DrawQuad::RENDER_PASS) + if (currentQuad->material != DrawQuad::RENDER_PASS) return false; const RenderPass* contributingPass = findRenderPassById(RenderPassDrawQuad::materialCast(currentQuad)->renderPassId(), frame); @@ -617,7 +617,7 @@ void LayerTreeHostImpl::removeRenderPasses(RenderPassCuller culler, FrameData& f for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) { DrawQuad* currentQuad = *quadListIterator; - if (currentQuad->material() != DrawQuad::RENDER_PASS) + if (currentQuad->material != DrawQuad::RENDER_PASS) continue; RenderPassDrawQuad* renderPassQuad = static_cast<RenderPassDrawQuad*>(currentQuad); diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index 546c1c1..278f467 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -1583,7 +1583,7 @@ public: SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState()); scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::create(sharedQuadState, m_quadRect, opaqueRect, m_resourceId, gfx::Vector2d(), gfx::Size(1, 1), false, false, false, false, false); - testBlendingDrawQuad->set_visible_rect(m_quadVisibleRect); + testBlendingDrawQuad->visible_rect = m_quadVisibleRect; EXPECT_EQ(m_blend, testBlendingDrawQuad->ShouldDrawWithBlending()); EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); quadSink.append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsData); @@ -1848,7 +1848,7 @@ TEST_P(LayerTreeHostImplTest, viewportCovered) size_t numGutterQuads = 0; for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) - numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SOLID_COLOR) ? 1 : 0; + numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material == DrawQuad::SOLID_COLOR) ? 1 : 0; EXPECT_EQ(0u, numGutterQuads); EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); @@ -1872,7 +1872,7 @@ TEST_P(LayerTreeHostImplTest, viewportCovered) size_t numGutterQuads = 0; for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) - numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SOLID_COLOR) ? 1 : 0; + numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material == DrawQuad::SOLID_COLOR) ? 1 : 0; EXPECT_EQ(1u, numGutterQuads); EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); @@ -1895,7 +1895,7 @@ TEST_P(LayerTreeHostImplTest, viewportCovered) size_t numGutterQuads = 0; for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) - numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SOLID_COLOR) ? 1 : 0; + numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material == DrawQuad::SOLID_COLOR) ? 1 : 0; EXPECT_EQ(4u, numGutterQuads); EXPECT_EQ(5u, frame.renderPasses[0]->quadList().size()); @@ -2346,8 +2346,8 @@ TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) ASSERT_EQ(2U, frame.renderPasses.size()); ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); - EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); } } @@ -2367,8 +2367,8 @@ TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) ASSERT_EQ(2U, frame.renderPasses.size()); ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); - EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); } } @@ -3128,16 +3128,16 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); // Verify that the child layers are being clipped. - gfx::Rect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->visible_rect(); + gfx::Rect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->visible_rect; EXPECT_LT(quadVisibleRect.width(), 100); - quadVisibleRect = frame.renderPasses[0]->quadList()[1]->visible_rect(); + quadVisibleRect = frame.renderPasses[0]->quadList()[1]->visible_rect; EXPECT_LT(quadVisibleRect.width(), 100); // Verify that the render surface texture is *not* clipped. EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), frame.renderPasses[0]->outputRect()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); EXPECT_FALSE(quad->contentsChangedSinceLastFrame().IsEmpty()); @@ -3795,7 +3795,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_FALSE(targetPass->damageRect().IsEmpty()); @@ -3813,7 +3813,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) ASSERT_EQ(1U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[0]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -3832,7 +3832,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) ASSERT_EQ(1U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[0]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -3851,9 +3851,9 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) ASSERT_EQ(2U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_FALSE(targetPass->damageRect().IsEmpty()); @@ -3880,7 +3880,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -3901,7 +3901,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) ASSERT_EQ(1U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[0]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -3922,7 +3922,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) ASSERT_EQ(1U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[0]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -3954,7 +3954,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_FALSE(targetPass->damageRect().IsEmpty()); @@ -3996,7 +3996,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) ASSERT_EQ(1U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[0]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -4015,9 +4015,9 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) ASSERT_EQ(2U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quadList()[0]->material); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_FALSE(targetPass->damageRect().IsEmpty()); @@ -4044,7 +4044,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[1]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -4083,7 +4083,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) ASSERT_EQ(1U, frame.renderPasses.size()); EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); - EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material()); + EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quadList()[0]->material); const RenderPassDrawQuad* quad = RenderPassDrawQuad::materialCast(frame.renderPasses[0]->quadList()[0]); RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()); EXPECT_TRUE(targetPass->damageRect().IsEmpty()); @@ -4258,7 +4258,7 @@ void dumpRenderPassTestData(const RenderPassRemovalTestData& testData, char* buf QuadList::const_iterator quadListIterator = currentPass->quadList().begin(); while (quadListIterator != currentPass->quadList().end()) { DrawQuad* currentQuad = *quadListIterator; - switch (currentQuad->material()) { + switch (currentQuad->material) { case DrawQuad::SOLID_COLOR: *pos = 's'; pos++; diff --git a/cc/nine_patch_layer_impl_unittest.cc b/cc/nine_patch_layer_impl_unittest.cc index 39112b7..b24f569 100644 --- a/cc/nine_patch_layer_impl_unittest.cc +++ b/cc/nine_patch_layer_impl_unittest.cc @@ -59,7 +59,7 @@ TEST(NinePatchLayerImplTest, verifyDrawQuads) Region remaining(visibleContentRect); for (size_t i = 0; i < quads.size(); ++i) { DrawQuad* quad = quads[i]; - gfx::Rect quadRect = quad->rect(); + gfx::Rect quadRect = quad->rect; EXPECT_TRUE(visibleContentRect.Contains(quadRect)) << i; EXPECT_TRUE(remaining.Contains(quadRect)) << i; @@ -75,7 +75,6 @@ TEST(NinePatchLayerImplTest, verifyDrawQuads) Region texRemaining(bitmapRect); for (size_t i = 0; i < quads.size(); ++i) { DrawQuad* quad = quads[i]; - ASSERT_EQ(quad->material(), DrawQuad::TEXTURE_CONTENT); const TextureDrawQuad* texQuad = TextureDrawQuad::materialCast(quad); gfx::RectF texRect = texQuad->uvRect(); texRect.Scale(bitmapSize.width(), bitmapSize.height()); diff --git a/cc/quad_culler.cc b/cc/quad_culler.cc index b06f90b..5ac52ae 100644 --- a/cc/quad_culler.cc +++ b/cc/quad_culler.cc @@ -43,17 +43,17 @@ static inline bool appendQuadInternal(scoped_ptr<DrawQuad> drawQuad, const gfx:: { bool keepQuad = !culledRect.IsEmpty(); if (keepQuad) - drawQuad->set_visible_rect(culledRect); + drawQuad->visible_rect = culledRect; - occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform(), drawQuad->rect(), culledRect); - gfx::Rect opaqueDrawRect = drawQuad->opacity() == 1.0f ? drawQuad->opaque_rect() : gfx::Rect(); + occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform(), drawQuad->rect, culledRect); + gfx::Rect opaqueDrawRect = drawQuad->opacity() == 1.0f ? drawQuad->opaque_rect : gfx::Rect(); occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culledRect, opaqueDrawRect); if (keepQuad) { - if (createDebugBorderQuads && !drawQuad->IsDebugQuad() && drawQuad->visible_rect() != drawQuad->rect()) { + if (createDebugBorderQuads && !drawQuad->IsDebugQuad() && drawQuad->visible_rect != drawQuad->rect) { SkColor color = DebugColors::CulledTileBorderColor(); float width = DebugColors::CulledTileBorderWidth(layer ? layer->layerTreeHostImpl() : NULL); - quadList.append(DebugBorderDrawQuad::create(drawQuad->shared_quad_state(), drawQuad->visible_rect(), color, width).PassAs<DrawQuad>()); + quadList.append(DebugBorderDrawQuad::create(drawQuad->shared_quad_state, drawQuad->visible_rect, color, width).PassAs<DrawQuad>()); } // Pass the quad after we're done using it. @@ -64,7 +64,7 @@ static inline bool appendQuadInternal(scoped_ptr<DrawQuad> drawQuad, const gfx:: bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQuadsData) { - DCHECK(drawQuad->shared_quad_state() == m_currentSharedQuadState); + DCHECK(drawQuad->shared_quad_state == m_currentSharedQuadState); DCHECK(!m_sharedQuadStateList.isEmpty()); DCHECK(m_sharedQuadStateList.last() == m_currentSharedQuadState); @@ -73,9 +73,9 @@ bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQu bool implDrawTransformIsUnknown = false; if (m_forSurface) - culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRect(m_layer, false, drawQuad->rect(), &hasOcclusionFromOutsideTargetSurface); + culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRect(m_layer, false, drawQuad->rect, &hasOcclusionFromOutsideTargetSurface); else - culledRect = m_occlusionTracker->unoccludedContentRect(m_layer->renderTarget(), drawQuad->rect(), drawQuad->quadTransform(), implDrawTransformIsUnknown, drawQuad->clippedRectInTarget(), &hasOcclusionFromOutsideTargetSurface); + culledRect = m_occlusionTracker->unoccludedContentRect(m_layer->renderTarget(), drawQuad->rect, drawQuad->quadTransform(), implDrawTransformIsUnknown, drawQuad->clippedRectInTarget(), &hasOcclusionFromOutsideTargetSurface); appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOutsideTargetSurface; diff --git a/cc/quad_culler_unittest.cc b/cc/quad_culler_unittest.cc index 6bc2998..c94aadb 100644 --- a/cc/quad_culler_unittest.cc +++ b/cc/quad_culler_unittest.cc @@ -178,18 +178,18 @@ TEST(QuadCullerTest, verifyCullCenterTileOnly) appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker); ASSERT_EQ(quadList.size(), 12u); - gfx::Rect quadVisibleRect1 = quadList[5]->visible_rect(); + gfx::Rect quadVisibleRect1 = quadList[5]->visible_rect; EXPECT_EQ(quadVisibleRect1.height(), 50); - gfx::Rect quadVisibleRect3 = quadList[7]->visible_rect(); + gfx::Rect quadVisibleRect3 = quadList[7]->visible_rect; EXPECT_EQ(quadVisibleRect3.width(), 50); // Next index is 8, not 9, since centre quad culled. - gfx::Rect quadVisibleRect4 = quadList[8]->visible_rect(); + gfx::Rect quadVisibleRect4 = quadList[8]->visible_rect; EXPECT_EQ(quadVisibleRect4.width(), 50); EXPECT_EQ(quadVisibleRect4.x(), 250); - gfx::Rect quadVisibleRect6 = quadList[10]->visible_rect(); + gfx::Rect quadVisibleRect6 = quadList[10]->visible_rect; EXPECT_EQ(quadVisibleRect6.height(), 50); EXPECT_EQ(quadVisibleRect6.y(), 250); diff --git a/cc/render_pass_draw_quad.cc b/cc/render_pass_draw_quad.cc index c70b3b4..6a06825 100644 --- a/cc/render_pass_draw_quad.cc +++ b/cc/render_pass_draw_quad.cc @@ -12,8 +12,7 @@ scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::create(const SharedQuadState* } RenderPassDrawQuad::RenderPassDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, RenderPass::Id renderPassId, bool isReplica, ResourceProvider::ResourceId maskResourceId, const gfx::Rect& contentsChangedSinceLastFrame, float maskTexCoordScaleX, float maskTexCoordScaleY, float maskTexCoordOffsetX, float maskTexCoordOffsetY) - : DrawQuad(sharedQuadState, DrawQuad::RENDER_PASS, quadRect, gfx::Rect()) - , m_renderPassId(renderPassId) + : m_renderPassId(renderPassId) , m_isReplica(isReplica) , m_maskResourceId(maskResourceId) , m_contentsChangedSinceLastFrame(contentsChangedSinceLastFrame) @@ -24,18 +23,23 @@ RenderPassDrawQuad::RenderPassDrawQuad(const SharedQuadState* sharedQuadState, c { DCHECK(m_renderPassId.layerId > 0); DCHECK(m_renderPassId.index >= 0); + + gfx::Rect opaqueRect; + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::RENDER_PASS, quadRect, opaqueRect, visibleRect, needsBlending); } const RenderPassDrawQuad* RenderPassDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::RENDER_PASS); + DCHECK(quad->material == DrawQuad::RENDER_PASS); return static_cast<const RenderPassDrawQuad*>(quad); } scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::copy(const SharedQuadState* copiedSharedQuadState, RenderPass::Id copiedRenderPassId) const { scoped_ptr<RenderPassDrawQuad> copyQuad(new RenderPassDrawQuad(*materialCast(this))); - copyQuad->set_shared_quad_state(copiedSharedQuadState); + copyQuad->shared_quad_state = copiedSharedQuadState; copyQuad->m_renderPassId = copiedRenderPassId; return copyQuad.Pass(); } diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc index 2ec35d0..37467aa 100644 --- a/cc/software_renderer.cc +++ b/cc/software_renderer.cc @@ -168,7 +168,7 @@ void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) { TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); WebTransformationMatrix quadRectMatrix; - quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect()); + quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform(); SkMatrix skDeviceMatrix; toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); @@ -187,7 +187,7 @@ void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrc_Mode); } - switch (quad->material()) { + switch (quad->material) { case DrawQuad::DEBUG_BORDER: drawDebugBorderQuad(frame, DebugBorderDrawQuad::materialCast(quad)); break; @@ -260,7 +260,7 @@ void SoftwareRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQua SkRect uvRect = SkRect::MakeXYWH( quad->textureOffset().x(), quad->textureOffset().y(), - quad->rect().width(), quad->rect().height()); + quad->rect.width(), quad->rect.height()); m_skCurrentPaint.setFilterBitmap(true); m_skCurrentCanvas->drawBitmapRectToRect(*lock.skBitmap(), &uvRect, gfx::RectFToSkRect(quadVertexRect()), diff --git a/cc/solid_color_draw_quad.cc b/cc/solid_color_draw_quad.cc index f8c1614..d6daad2 100644 --- a/cc/solid_color_draw_quad.cc +++ b/cc/solid_color_draw_quad.cc @@ -14,16 +14,17 @@ scoped_ptr<SolidColorDrawQuad> SolidColorDrawQuad::create(const SharedQuadState* } SolidColorDrawQuad::SolidColorDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, SkColor color) - : DrawQuad(sharedQuadState, DrawQuad::SOLID_COLOR, quadRect, quadRect) - , m_color(color) + : m_color(color) { - if (SkColorGetA(m_color) < 255) - opaque_rect_ = gfx::Rect(); + gfx::Rect opaqueRect = SkColorGetA(m_color) == 255 ? quadRect : gfx::Rect(); + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::SOLID_COLOR, quadRect, opaqueRect, visibleRect, needsBlending); } const SolidColorDrawQuad* SolidColorDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::SOLID_COLOR); + DCHECK(quad->material == DrawQuad::SOLID_COLOR); return static_cast<const SolidColorDrawQuad*>(quad); } diff --git a/cc/solid_color_layer_impl_unittest.cc b/cc/solid_color_layer_impl_unittest.cc index cd37ab0..bf289e5 100644 --- a/cc/solid_color_layer_impl_unittest.cc +++ b/cc/solid_color_layer_impl_unittest.cc @@ -113,7 +113,7 @@ TEST(SolidColorLayerImplTest, verifyOpaqueRect) layerImpl->appendQuads(quadCuller, data); ASSERT_EQ(quadCuller.quadList().size(), 1U); - EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaque_rect().ToString()); + EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaque_rect.ToString()); } EXPECT_TRUE(layer->contentsOpaque()); @@ -135,7 +135,7 @@ TEST(SolidColorLayerImplTest, verifyOpaqueRect) layerImpl->appendQuads(quadCuller, data); ASSERT_EQ(quadCuller.quadList().size(), 1U); - EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect().ToString()); + EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect.ToString()); } } diff --git a/cc/stream_video_draw_quad.cc b/cc/stream_video_draw_quad.cc index 5ab4134..24ef430 100644 --- a/cc/stream_video_draw_quad.cc +++ b/cc/stream_video_draw_quad.cc @@ -14,15 +14,17 @@ scoped_ptr<StreamVideoDrawQuad> StreamVideoDrawQuad::create(const SharedQuadStat } StreamVideoDrawQuad::StreamVideoDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, const gfx::Rect& opaqueRect, unsigned textureId, const WebKit::WebTransformationMatrix& matrix) - : DrawQuad(sharedQuadState, DrawQuad::STREAM_VIDEO_CONTENT, quadRect, opaqueRect) - , m_textureId(textureId) + : m_textureId(textureId) , m_matrix(matrix) { + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::STREAM_VIDEO_CONTENT, quadRect, opaqueRect, visibleRect, needsBlending); } const StreamVideoDrawQuad* StreamVideoDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::STREAM_VIDEO_CONTENT); + DCHECK(quad->material == DrawQuad::STREAM_VIDEO_CONTENT); return static_cast<const StreamVideoDrawQuad*>(quad); } diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc index 601e834..2156dc8 100644 --- a/cc/test/layer_test_common.cc +++ b/cc/test/layer_test_common.cc @@ -38,7 +38,7 @@ void verifyQuadsExactlyCoverRect(const cc::QuadList& quads, for (size_t i = 0; i < quads.size(); ++i) { cc::DrawQuad* quad = quads[i]; - gfx::RectF quadRectF = cc::MathUtil::mapClippedRect(quad->shared_quad_state()->quadTransform, gfx::RectF(quad->rect())); + gfx::RectF quadRectF = cc::MathUtil::mapClippedRect(quad->shared_quad_state->quadTransform, gfx::RectF(quad->rect)); // Before testing for exact coverage in the integer world, assert that rounding // will not round the rect incorrectly. diff --git a/cc/test/mock_quad_culler.cc b/cc/test/mock_quad_culler.cc index b2d760c..9afb7bc 100644 --- a/cc/test/mock_quad_culler.cc +++ b/cc/test/mock_quad_culler.cc @@ -24,7 +24,7 @@ MockQuadCuller::~MockQuadCuller() bool MockQuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData&) { - if (!drawQuad->rect().IsEmpty()) { + if (!drawQuad->rect.IsEmpty()) { m_activeQuadList.append(drawQuad.Pass()); return true; } diff --git a/cc/texture_draw_quad.cc b/cc/texture_draw_quad.cc index 1bed6be..65ea410 100644 --- a/cc/texture_draw_quad.cc +++ b/cc/texture_draw_quad.cc @@ -14,17 +14,19 @@ scoped_ptr<TextureDrawQuad> TextureDrawQuad::create(const SharedQuadState* share } TextureDrawQuad::TextureDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, const gfx::Rect& opaqueRect, unsigned resourceId, bool premultipliedAlpha, const gfx::RectF& uvRect, bool flipped) - : DrawQuad(sharedQuadState, DrawQuad::TEXTURE_CONTENT, quadRect, opaqueRect) - , m_resourceId(resourceId) + : m_resourceId(resourceId) , m_premultipliedAlpha(premultipliedAlpha) , m_uvRect(uvRect) , m_flipped(flipped) { + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::TEXTURE_CONTENT, quadRect, opaqueRect, visibleRect, needsBlending); } const TextureDrawQuad* TextureDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::TEXTURE_CONTENT); + DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); return static_cast<const TextureDrawQuad*>(quad); } diff --git a/cc/tile_draw_quad.cc b/cc/tile_draw_quad.cc index e5c3e40..fa8b9e1 100644 --- a/cc/tile_draw_quad.cc +++ b/cc/tile_draw_quad.cc @@ -15,8 +15,7 @@ scoped_ptr<TileDrawQuad> TileDrawQuad::create(const SharedQuadState* sharedQuadS } TileDrawQuad::TileDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, const gfx::Rect& opaqueRect, unsigned resourceId, const gfx::Vector2d& textureOffset, const gfx::Size& textureSize, bool swizzleContents, bool leftEdgeAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA) - : DrawQuad(sharedQuadState, DrawQuad::TILED_CONTENT, quadRect, opaqueRect) - , m_resourceId(resourceId) + : m_resourceId(resourceId) , m_textureOffset(textureOffset) , m_textureSize(textureSize) , m_swizzleContents(swizzleContents) @@ -25,13 +24,14 @@ TileDrawQuad::TileDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Re , m_rightEdgeAA(rightEdgeAA) , m_bottomEdgeAA(bottomEdgeAA) { - if (isAntialiased()) - needs_blending_ = true; + gfx::Rect visibleRect = quadRect; + bool needsBlending = isAntialiased(); + DrawQuad::SetAll(sharedQuadState, DrawQuad::TILED_CONTENT, quadRect, opaqueRect, visibleRect, needsBlending); } const TileDrawQuad* TileDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::TILED_CONTENT); + DCHECK(quad->material == DrawQuad::TILED_CONTENT); return static_cast<const TileDrawQuad*>(quad); } diff --git a/cc/tile_draw_quad.h b/cc/tile_draw_quad.h index 56fb925..dd5776e 100644 --- a/cc/tile_draw_quad.h +++ b/cc/tile_draw_quad.h @@ -23,6 +23,8 @@ public: gfx::Size textureSize() const { return m_textureSize; } bool swizzleContents() const { return m_swizzleContents; } + // TODO(danakj): Stick the data used to compute these things in the quad + // instead so the parent compositor can decide to use AA on its own. bool leftEdgeAA() const { return m_leftEdgeAA; } bool topEdgeAA() const { return m_topEdgeAA; } bool rightEdgeAA() const { return m_rightEdgeAA; } diff --git a/cc/tiled_layer_impl_unittest.cc b/cc/tiled_layer_impl_unittest.cc index 13e0c05..6b6e8c9 100644 --- a/cc/tiled_layer_impl_unittest.cc +++ b/cc/tiled_layer_impl_unittest.cc @@ -113,7 +113,7 @@ TEST(TiledLayerImplTest, checkerboarding) EXPECT_FALSE(data.hadMissingTiles); for (size_t i = 0; i < quadCuller.quadList().size(); ++i) - EXPECT_EQ(quadCuller.quadList()[i]->material(), DrawQuad::TILED_CONTENT); + EXPECT_EQ(quadCuller.quadList()[i]->material, DrawQuad::TILED_CONTENT); } for (int i = 0; i < numTilesX; ++i) @@ -128,7 +128,7 @@ TEST(TiledLayerImplTest, checkerboarding) EXPECT_TRUE(data.hadMissingTiles); EXPECT_EQ(quadCuller.quadList().size(), 4u); for (size_t i = 0; i < quadCuller.quadList().size(); ++i) - EXPECT_NE(quadCuller.quadList()[i]->material(), DrawQuad::TILED_CONTENT); + EXPECT_NE(quadCuller.quadList()[i]->material, DrawQuad::TILED_CONTENT); } } @@ -204,7 +204,7 @@ TEST(TiledLayerImplTest, textureInfoForLayerNoBorders) EXPECT_NE(quad->resourceId(), 0u) << quadString << i; EXPECT_EQ(quad->textureOffset(), gfx::Vector2d()) << quadString << i; EXPECT_EQ(quad->textureSize(), tileSize) << quadString << i; - EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaque_rect()) << quadString << i; + EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaque_rect) << quadString << i; } } diff --git a/cc/yuv_video_draw_quad.cc b/cc/yuv_video_draw_quad.cc index 2bff6c2..5e3bb6f 100644 --- a/cc/yuv_video_draw_quad.cc +++ b/cc/yuv_video_draw_quad.cc @@ -30,12 +30,14 @@ YUVVideoDrawQuad::YUVVideoDrawQuad( const VideoLayerImpl::FramePlane& yPlane, const VideoLayerImpl::FramePlane& uPlane, const VideoLayerImpl::FramePlane& vPlane) - : DrawQuad(sharedQuadState, DrawQuad::YUV_VIDEO_CONTENT, quadRect, opaqueRect) - , m_texScale(texScale) + : m_texScale(texScale) , m_yPlane(yPlane) , m_uPlane(uPlane) , m_vPlane(vPlane) { + gfx::Rect visibleRect = quadRect; + bool needsBlending = false; + DrawQuad::SetAll(sharedQuadState, DrawQuad::YUV_VIDEO_CONTENT, quadRect, opaqueRect, visibleRect, needsBlending); } YUVVideoDrawQuad::~YUVVideoDrawQuad() @@ -44,7 +46,7 @@ YUVVideoDrawQuad::~YUVVideoDrawQuad() const YUVVideoDrawQuad* YUVVideoDrawQuad::materialCast(const DrawQuad* quad) { - DCHECK(quad->material() == DrawQuad::YUV_VIDEO_CONTENT); + DCHECK(quad->material == DrawQuad::YUV_VIDEO_CONTENT); return static_cast<const YUVVideoDrawQuad*>(quad); } |