[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | d50c686 | 2012-10-23 02:08:31 | [diff] [blame] | 5 | #include "cc/render_surface_impl.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 6 | |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 7 | #include <algorithm> |
| 8 | |
[email protected] | 4456eee2 | 2012-10-19 18:16:38 | [diff] [blame] | 9 | #include "base/logging.h" |
| 10 | #include "base/stringprintf.h" |
[email protected] | aa0a9d3 | 2012-10-24 01:58:10 | [diff] [blame] | 11 | #include "cc/damage_tracker.h" |
| 12 | #include "cc/debug_border_draw_quad.h" |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 13 | #include "cc/debug_colors.h" |
[email protected] | aa0a9d3 | 2012-10-24 01:58:10 | [diff] [blame] | 14 | #include "cc/delegated_renderer_layer_impl.h" |
[email protected] | d50c686 | 2012-10-23 02:08:31 | [diff] [blame] | 15 | #include "cc/layer_impl.h" |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 16 | #include "cc/math_util.h" |
| 17 | #include "cc/quad_sink.h" |
| 18 | #include "cc/render_pass.h" |
| 19 | #include "cc/render_pass_draw_quad.h" |
| 20 | #include "cc/render_pass_sink.h" |
[email protected] | 4456eee2 | 2012-10-19 18:16:38 | [diff] [blame] | 21 | #include "cc/shared_quad_state.h" |
[email protected] | 55761e6 | 2012-11-21 18:55:58 | [diff] [blame] | 22 | #include "third_party/skia/include/core/SkImageFilter.h" |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 23 | #include "ui/gfx/rect_conversions.h" |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 24 | #include "ui/gfx/transform.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 25 | |
[email protected] | 9c88e56 | 2012-09-14 22:21:30 | [diff] [blame] | 26 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 27 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 28 | RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owningLayer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 29 | : m_owningLayer(owningLayer) |
| 30 | , m_surfacePropertyChanged(false) |
| 31 | , m_drawOpacity(1) |
| 32 | , m_drawOpacityIsAnimating(false) |
| 33 | , m_targetSurfaceTransformsAreAnimating(false) |
| 34 | , m_screenSpaceTransformsAreAnimating(false) |
[email protected] | dc462d78 | 2012-11-21 21:43:01 | [diff] [blame] | 35 | , m_isClipped(false) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 36 | , m_nearestAncestorThatMovesPixels(0) |
| 37 | , m_targetRenderSurfaceLayerIndexHistory(0) |
| 38 | , m_currentLayerIndexHistory(0) |
| 39 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 40 | m_damageTracker = DamageTracker::create(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 41 | } |
| 42 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 43 | RenderSurfaceImpl::~RenderSurfaceImpl() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 44 | { |
| 45 | } |
| 46 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 47 | gfx::RectF RenderSurfaceImpl::drawableContentRect() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 48 | { |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 49 | gfx::RectF drawableContentRect = MathUtil::mapClippedRect(m_drawTransform, m_contentRect); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 50 | if (m_owningLayer->hasReplica()) |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 51 | drawableContentRect.Union(MathUtil::mapClippedRect(m_replicaDrawTransform, m_contentRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 52 | |
| 53 | return drawableContentRect; |
| 54 | } |
| 55 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 56 | std::string RenderSurfaceImpl::name() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 57 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 58 | return base::StringPrintf("RenderSurfaceImpl(id=%i,owner=%s)", m_owningLayer->id(), m_owningLayer->debugName().data()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 59 | } |
| 60 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 61 | static std::string indentString(int indent) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 62 | { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 63 | std::string str; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 64 | for (int i = 0; i != indent; ++i) |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 65 | str.append(" "); |
| 66 | return str; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 67 | } |
| 68 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 69 | void RenderSurfaceImpl::dumpSurface(std::string* str, int indent) const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 70 | { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 71 | std::string indentStr = indentString(indent); |
| 72 | str->append(indentStr); |
| 73 | base::StringAppendF(str, "%s\n", name().data()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 74 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 75 | indentStr.append(" "); |
| 76 | str->append(indentStr); |
| 77 | base::StringAppendF(str, "contentRect: (%d, %d, %d, %d)\n", m_contentRect.x(), m_contentRect.y(), m_contentRect.width(), m_contentRect.height()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 78 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 79 | str->append(indentStr); |
| 80 | base::StringAppendF(str, "drawTransform: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 81 | m_drawTransform.matrix().getDouble(0, 0), m_drawTransform.matrix().getDouble(0, 1), m_drawTransform.matrix().getDouble(0, 2), m_drawTransform.matrix().getDouble(0, 3), |
| 82 | m_drawTransform.matrix().getDouble(1, 0), m_drawTransform.matrix().getDouble(1, 1), m_drawTransform.matrix().getDouble(1, 2), m_drawTransform.matrix().getDouble(1, 3), |
| 83 | m_drawTransform.matrix().getDouble(2, 0), m_drawTransform.matrix().getDouble(2, 1), m_drawTransform.matrix().getDouble(2, 2), m_drawTransform.matrix().getDouble(2, 3), |
| 84 | m_drawTransform.matrix().getDouble(3, 0), m_drawTransform.matrix().getDouble(3, 1), m_drawTransform.matrix().getDouble(3, 2), m_drawTransform.matrix().getDouble(3, 3)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 85 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 86 | str->append(indentStr); |
| 87 | base::StringAppendF(str, "damageRect is pos(%f, %f), size(%f, %f)\n", |
| 88 | m_damageTracker->currentDamageRect().x(), m_damageTracker->currentDamageRect().y(), |
| 89 | m_damageTracker->currentDamageRect().width(), m_damageTracker->currentDamageRect().height()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 90 | } |
| 91 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 92 | int RenderSurfaceImpl::owningLayerId() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 93 | { |
| 94 | return m_owningLayer ? m_owningLayer->id() : 0; |
| 95 | } |
| 96 | |
| 97 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 98 | void RenderSurfaceImpl::setClipRect(const gfx::Rect& clipRect) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 99 | { |
| 100 | if (m_clipRect == clipRect) |
| 101 | return; |
| 102 | |
| 103 | m_surfacePropertyChanged = true; |
| 104 | m_clipRect = clipRect; |
| 105 | } |
| 106 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 107 | bool RenderSurfaceImpl::contentsChanged() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 108 | { |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 109 | return !m_damageTracker->currentDamageRect().IsEmpty(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 110 | } |
| 111 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 112 | void RenderSurfaceImpl::setContentRect(const gfx::Rect& contentRect) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 113 | { |
| 114 | if (m_contentRect == contentRect) |
| 115 | return; |
| 116 | |
| 117 | m_surfacePropertyChanged = true; |
| 118 | m_contentRect = contentRect; |
| 119 | } |
| 120 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 121 | bool RenderSurfaceImpl::surfacePropertyChanged() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 122 | { |
| 123 | // Surface property changes are tracked as follows: |
| 124 | // |
| 125 | // - m_surfacePropertyChanged is flagged when the clipRect or contentRect change. As |
| 126 | // of now, these are the only two properties that can be affected by descendant layers. |
| 127 | // |
| 128 | // - all other property changes come from the owning layer (or some ancestor layer |
| 129 | // that propagates its change to the owning layer). |
| 130 | // |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 131 | DCHECK(m_owningLayer); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 132 | return m_surfacePropertyChanged || m_owningLayer->layerPropertyChanged(); |
| 133 | } |
| 134 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 135 | bool RenderSurfaceImpl::surfacePropertyChangedOnlyFromDescendant() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 136 | { |
| 137 | return m_surfacePropertyChanged && !m_owningLayer->layerPropertyChanged(); |
| 138 | } |
| 139 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 140 | void RenderSurfaceImpl::addContributingDelegatedRenderPassLayer(LayerImpl* layer) |
[email protected] | 7d929c0 | 2012-09-20 17:26:57 | [diff] [blame] | 141 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 142 | DCHECK(std::find(m_layerList.begin(), m_layerList.end(), layer) != m_layerList.end()); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 143 | DelegatedRendererLayerImpl* delegatedRendererLayer = static_cast<DelegatedRendererLayerImpl*>(layer); |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 144 | m_contributingDelegatedRenderPassLayerList.push_back(delegatedRendererLayer); |
[email protected] | 7d929c0 | 2012-09-20 17:26:57 | [diff] [blame] | 145 | } |
| 146 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 147 | void RenderSurfaceImpl::clearLayerLists() |
[email protected] | 7d929c0 | 2012-09-20 17:26:57 | [diff] [blame] | 148 | { |
| 149 | m_layerList.clear(); |
| 150 | m_contributingDelegatedRenderPassLayerList.clear(); |
| 151 | } |
| 152 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 153 | static inline gfx::Rect computeClippedRectInTarget(const LayerImpl* owningLayer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 154 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 155 | DCHECK(owningLayer->parent()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 156 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 157 | const LayerImpl* renderTarget = owningLayer->parent()->renderTarget(); |
| 158 | const RenderSurfaceImpl* self = owningLayer->renderSurface(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 159 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 160 | gfx::Rect clippedRectInTarget = self->clipRect(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 161 | if (owningLayer->backgroundFilters().hasFilterThatMovesPixels()) { |
| 162 | // If the layer has background filters that move pixels, we cannot scissor as tightly. |
| 163 | // FIXME: this should be able to be a tighter scissor, perhaps expanded by the filter outsets? |
| 164 | clippedRectInTarget = renderTarget->renderSurface()->contentRect(); |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 165 | } else if (clippedRectInTarget.IsEmpty()) { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 166 | // For surfaces, empty clipRect means that the surface does not clip anything. |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 167 | clippedRectInTarget = renderTarget->renderSurface()->contentRect(); |
| 168 | clippedRectInTarget.Intersect(gfx::ToEnclosingRect(self->drawableContentRect())); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 169 | } else |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 170 | clippedRectInTarget.Intersect(gfx::ToEnclosingRect(self->drawableContentRect())); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 171 | return clippedRectInTarget; |
| 172 | } |
| 173 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 174 | RenderPass::Id RenderSurfaceImpl::renderPassId() |
[email protected] | 0f077a5 | 2012-09-08 01:45:24 | [diff] [blame] | 175 | { |
| 176 | int layerId = m_owningLayer->id(); |
| 177 | int subId = 0; |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 178 | DCHECK(layerId > 0); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 179 | return RenderPass::Id(layerId, subId); |
[email protected] | 0f077a5 | 2012-09-08 01:45:24 | [diff] [blame] | 180 | } |
| 181 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 182 | void RenderSurfaceImpl::appendRenderPasses(RenderPassSink& passSink) |
[email protected] | 467b361 | 2012-08-28 07:41:16 | [diff] [blame] | 183 | { |
[email protected] | 7d929c0 | 2012-09-20 17:26:57 | [diff] [blame] | 184 | for (size_t i = 0; i < m_contributingDelegatedRenderPassLayerList.size(); ++i) |
| 185 | m_contributingDelegatedRenderPassLayerList[i]->appendContributingRenderPasses(passSink); |
| 186 | |
[email protected] | f57bbc0 | 2012-11-21 07:02:15 | [diff] [blame] | 187 | scoped_ptr<RenderPass> pass = RenderPass::Create(); |
| 188 | pass->SetNew(renderPassId(), m_contentRect, m_damageTracker->currentDamageRect(), m_screenSpaceTransform); |
[email protected] | 87cea537 | 2012-09-26 18:59:56 | [diff] [blame] | 189 | passSink.appendRenderPass(pass.Pass()); |
[email protected] | 467b361 | 2012-08-28 07:41:16 | [diff] [blame] | 190 | } |
| 191 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 192 | void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData, bool forReplica, RenderPass::Id renderPassId) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 193 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 194 | DCHECK(!forReplica || m_owningLayer->hasReplica()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 195 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 196 | gfx::Rect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 197 | const gfx::Transform& drawTransform = forReplica ? m_replicaDrawTransform : m_drawTransform; |
[email protected] | cb7af74 | 2012-11-21 04:02:24 | [diff] [blame] | 198 | SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(SharedQuadState::Create()); |
[email protected] | dc462d78 | 2012-11-21 21:43:01 | [diff] [blame] | 199 | sharedQuadState->SetAll(drawTransform, m_contentRect, clippedRectInTarget, m_clipRect, m_isClipped, m_drawOpacity); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 200 | |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 201 | if (m_owningLayer->showDebugBorders()) { |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 202 | SkColor color = forReplica ? DebugColors::SurfaceReplicaBorderColor() : DebugColors::SurfaceBorderColor(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 203 | float width = forReplica ? DebugColors::SurfaceReplicaBorderWidth(m_owningLayer->layerTreeImpl()) : DebugColors::SurfaceBorderWidth(m_owningLayer->layerTreeImpl()); |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 204 | scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = DebugBorderDrawQuad::Create(); |
| 205 | debugBorderQuad->SetNew(sharedQuadState, contentRect(), color, width); |
| 206 | quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 207 | } |
| 208 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 209 | // FIXME: By using the same RenderSurfaceImpl for both the content and its reflection, |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 210 | // it's currently not possible to apply a separate mask to the reflection layer |
| 211 | // or correctly handle opacity in reflections (opacity must be applied after drawing |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 212 | // both the layer and its reflection). The solution is to introduce yet another RenderSurfaceImpl |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 213 | // to draw the layer and its reflection in. For now we only apply a separate reflection |
| 214 | // mask if the contents don't have a mask of their own. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 215 | LayerImpl* maskLayer = m_owningLayer->maskLayer(); |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 216 | if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEmpty())) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 217 | maskLayer = 0; |
| 218 | |
| 219 | if (!maskLayer && forReplica) { |
| 220 | maskLayer = m_owningLayer->replicaLayer()->maskLayer(); |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 221 | if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEmpty())) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 222 | maskLayer = 0; |
| 223 | } |
| 224 | |
[email protected] | 458af1e | 2012-12-13 05:12:18 | [diff] [blame] | 225 | gfx::RectF maskUVRect(0.0f, 0.0f, 1.0f, 1.0f); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 226 | if (maskLayer) { |
[email protected] | 8611f01 | 2013-01-17 03:44:55 | [diff] [blame^] | 227 | gfx::Vector2dF owningLayerDrawScale = MathUtil::computeTransform2dScaleComponents(m_owningLayer->drawTransform(), 1.f); |
| 228 | gfx::SizeF unclippedSurfaceSize = gfx::ScaleSize( |
| 229 | m_owningLayer->contentBounds(), |
| 230 | owningLayerDrawScale.x(), |
| 231 | owningLayerDrawScale.y()); |
| 232 | // This assumes that the owning layer clips its subtree when a mask is |
| 233 | // present. |
| 234 | DCHECK(gfx::RectF(unclippedSurfaceSize).Contains(contentRect())); |
[email protected] | 458af1e | 2012-12-13 05:12:18 | [diff] [blame] | 235 | |
[email protected] | 8611f01 | 2013-01-17 03:44:55 | [diff] [blame^] | 236 | float uvScaleX = contentRect().width() / unclippedSurfaceSize.width(); |
| 237 | float uvScaleY = contentRect().height() / unclippedSurfaceSize.height(); |
| 238 | |
| 239 | maskUVRect = gfx::RectF( |
| 240 | static_cast<float>(contentRect().x()) / contentRect().width() * uvScaleX, |
| 241 | static_cast<float>(contentRect().y()) / contentRect().height() * uvScaleY, |
| 242 | uvScaleX, |
| 243 | uvScaleY); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 246 | ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->contentsResourceId() : 0; |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 247 | gfx::Rect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : gfx::Rect(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 248 | |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 249 | scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 250 | quad->SetNew(sharedQuadState, contentRect(), renderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, maskUVRect, m_owningLayer->filters(), m_owningLayer->filter(), m_owningLayer->backgroundFilters()); |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 251 | quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 252 | } |
| 253 | |
[email protected] | bc5e77c | 2012-11-05 20:00:49 | [diff] [blame] | 254 | } // namespace cc |