[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); |
| 189 | pass->filters = m_owningLayer->filters(); |
[email protected] | 4c3432b | 2012-11-21 18:47:13 | [diff] [blame] | 190 | SkRefCnt_SafeAssign(pass->filter, m_owningLayer->filter()); |
[email protected] | f57bbc0 | 2012-11-21 07:02:15 | [diff] [blame] | 191 | pass->background_filters = m_owningLayer->backgroundFilters(); |
[email protected] | 87cea537 | 2012-09-26 18:59:56 | [diff] [blame] | 192 | passSink.appendRenderPass(pass.Pass()); |
[email protected] | 467b361 | 2012-08-28 07:41:16 | [diff] [blame] | 193 | } |
| 194 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 195 | void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData, bool forReplica, RenderPass::Id renderPassId) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 196 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 197 | DCHECK(!forReplica || m_owningLayer->hasReplica()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 198 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 199 | gfx::Rect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame^] | 200 | const gfx::Transform& drawTransform = forReplica ? m_replicaDrawTransform : m_drawTransform; |
[email protected] | cb7af74 | 2012-11-21 04:02:24 | [diff] [blame] | 201 | SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(SharedQuadState::Create()); |
[email protected] | dc462d78 | 2012-11-21 21:43:01 | [diff] [blame] | 202 | sharedQuadState->SetAll(drawTransform, m_contentRect, clippedRectInTarget, m_clipRect, m_isClipped, m_drawOpacity); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 203 | |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 204 | if (m_owningLayer->showDebugBorders()) { |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 205 | SkColor color = forReplica ? DebugColors::SurfaceReplicaBorderColor() : DebugColors::SurfaceBorderColor(); |
| 206 | float width = forReplica ? DebugColors::SurfaceReplicaBorderWidth(m_owningLayer->layerTreeHostImpl()) : DebugColors::SurfaceBorderWidth(m_owningLayer->layerTreeHostImpl()); |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 207 | scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = DebugBorderDrawQuad::Create(); |
| 208 | debugBorderQuad->SetNew(sharedQuadState, contentRect(), color, width); |
| 209 | quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 210 | } |
| 211 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 212 | // FIXME: By using the same RenderSurfaceImpl for both the content and its reflection, |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 213 | // it's currently not possible to apply a separate mask to the reflection layer |
| 214 | // or correctly handle opacity in reflections (opacity must be applied after drawing |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 215 | // 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] | 216 | // to draw the layer and its reflection in. For now we only apply a separate reflection |
| 217 | // mask if the contents don't have a mask of their own. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 218 | LayerImpl* maskLayer = m_owningLayer->maskLayer(); |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 219 | if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEmpty())) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 220 | maskLayer = 0; |
| 221 | |
| 222 | if (!maskLayer && forReplica) { |
| 223 | maskLayer = m_owningLayer->replicaLayer()->maskLayer(); |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 224 | if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEmpty())) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 225 | maskLayer = 0; |
| 226 | } |
| 227 | |
| 228 | float maskTexCoordScaleX = 1; |
| 229 | float maskTexCoordScaleY = 1; |
[email protected] | 058a724a | 2012-10-30 18:37:02 | [diff] [blame] | 230 | float maskTexCoordOffsetX = 0; |
| 231 | float maskTexCoordOffsetY = 0; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 232 | if (maskLayer) { |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 233 | maskTexCoordScaleX = contentRect().width() / maskLayer->contentsScaleX() / maskLayer->bounds().width(); |
| 234 | maskTexCoordScaleY = contentRect().height() / maskLayer->contentsScaleY() / maskLayer->bounds().height(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 235 | maskTexCoordOffsetX = static_cast<float>(contentRect().x()) / contentRect().width() * maskTexCoordScaleX; |
| 236 | maskTexCoordOffsetY = static_cast<float>(contentRect().y()) / contentRect().height() * maskTexCoordScaleY; |
| 237 | } |
| 238 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 239 | ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->contentsResourceId() : 0; |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 240 | gfx::Rect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : gfx::Rect(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 241 | |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 242 | scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
| 243 | quad->SetNew(sharedQuadState, contentRect(), renderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, |
| 244 | maskTexCoordScaleX, maskTexCoordScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY); |
| 245 | quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 246 | } |
| 247 | |
[email protected] | bc5e77c | 2012-11-05 20:00:49 | [diff] [blame] | 248 | } // namespace cc |