OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #if USE(ACCELERATED_COMPOSITING) | 7 #if USE(ACCELERATED_COMPOSITING) |
8 | 8 |
9 #include "CCTiledLayerImpl.h" | 9 #include "CCTiledLayerImpl.h" |
10 | 10 |
| 11 #include "CCAppendQuadsData.h" |
11 #include "CCCheckerboardDrawQuad.h" | 12 #include "CCCheckerboardDrawQuad.h" |
12 #include "CCDebugBorderDrawQuad.h" | 13 #include "CCDebugBorderDrawQuad.h" |
13 #include "CCLayerTilingData.h" | 14 #include "CCLayerTilingData.h" |
14 #include "CCMathUtil.h" | 15 #include "CCMathUtil.h" |
15 #include "CCQuadSink.h" | 16 #include "CCQuadSink.h" |
16 #include "CCSolidColorDrawQuad.h" | 17 #include "CCSolidColorDrawQuad.h" |
17 #include "CCTileDrawQuad.h" | 18 #include "CCTileDrawQuad.h" |
18 #include "FloatQuad.h" | 19 #include "FloatQuad.h" |
19 #include "GraphicsContext3D.h" | 20 #include "GraphicsContext3D.h" |
20 #include "SkColor.h" | 21 #include "SkColor.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 98 } |
98 | 99 |
99 DrawableTile* CCTiledLayerImpl::createTile(int i, int j) | 100 DrawableTile* CCTiledLayerImpl::createTile(int i, int j) |
100 { | 101 { |
101 OwnPtr<DrawableTile> tile(DrawableTile::create()); | 102 OwnPtr<DrawableTile> tile(DrawableTile::create()); |
102 DrawableTile* addedTile = tile.get(); | 103 DrawableTile* addedTile = tile.get(); |
103 m_tiler->addTile(tile.release(), i, j); | 104 m_tiler->addTile(tile.release(), i, j); |
104 return addedTile; | 105 return addedTile; |
105 } | 106 } |
106 | 107 |
107 void CCTiledLayerImpl::appendQuads(CCQuadSink& quadSink, bool& hadMissingTiles) | 108 void CCTiledLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appe
ndQuadsData) |
108 { | 109 { |
109 const IntRect& contentRect = visibleContentRect(); | 110 const IntRect& contentRect = visibleContentRect(); |
110 | 111 |
111 if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.isEmpty()) | 112 if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.isEmpty()) |
112 return; | 113 return; |
113 | 114 |
114 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); | 115 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); |
115 appendDebugBorderQuad(quadSink, sharedQuadState); | 116 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
116 | 117 |
117 int left, top, right, bottom; | 118 int left, top, right, bottom; |
118 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); | 119 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); |
119 | 120 |
120 if (hasDebugBorders()) { | 121 if (hasDebugBorders()) { |
121 for (int j = top; j <= bottom; ++j) { | 122 for (int j = top; j <= bottom; ++j) { |
122 for (int i = left; i <= right; ++i) { | 123 for (int i = left; i <= right; ++i) { |
123 DrawableTile* tile = tileAt(i, j); | 124 DrawableTile* tile = tileAt(i, j); |
124 IntRect tileRect = m_tiler->tileBounds(i, j); | 125 IntRect tileRect = m_tiler->tileBounds(i, j); |
125 SkColor borderColor; | 126 SkColor borderColor; |
126 | 127 |
127 if (m_skipsDraw || !tile || !tile->resourceId()) | 128 if (m_skipsDraw || !tile || !tile->resourceId()) |
128 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorder
MissingTileColorBlue); | 129 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorder
MissingTileColorBlue); |
129 else | 130 else |
130 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); | 131 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); |
131 quadSink.append(CCDebugBorderDrawQuad::create(sharedQuadState, t
ileRect, borderColor, debugTileBorderWidth)); | 132 quadSink.append(CCDebugBorderDrawQuad::create(sharedQuadState, t
ileRect, borderColor, debugTileBorderWidth), appendQuadsData); |
132 } | 133 } |
133 } | 134 } |
134 } | 135 } |
135 | 136 |
136 if (m_skipsDraw) | 137 if (m_skipsDraw) |
137 return; | 138 return; |
138 | 139 |
139 for (int j = top; j <= bottom; ++j) { | 140 for (int j = top; j <= bottom; ++j) { |
140 for (int i = left; i <= right; ++i) { | 141 for (int i = left; i <= right; ++i) { |
141 DrawableTile* tile = tileAt(i, j); | 142 DrawableTile* tile = tileAt(i, j); |
142 IntRect tileRect = m_tiler->tileBounds(i, j); | 143 IntRect tileRect = m_tiler->tileBounds(i, j); |
143 IntRect displayRect = tileRect; | 144 IntRect displayRect = tileRect; |
144 tileRect.intersect(contentRect); | 145 tileRect.intersect(contentRect); |
145 | 146 |
146 // Skip empty tiles. | 147 // Skip empty tiles. |
147 if (tileRect.isEmpty()) | 148 if (tileRect.isEmpty()) |
148 continue; | 149 continue; |
149 | 150 |
150 if (!tile || !tile->resourceId()) { | 151 if (!tile || !tile->resourceId()) { |
151 if (drawCheckerboardForMissingTiles()) | 152 if (drawCheckerboardForMissingTiles()) |
152 hadMissingTiles |= quadSink.append(CCCheckerboardDrawQuad::c
reate(sharedQuadState, tileRect)); | 153 appendQuadsData.hadMissingTiles |= quadSink.append(CCChecker
boardDrawQuad::create(sharedQuadState, tileRect), appendQuadsData); |
153 else | 154 else |
154 hadMissingTiles |= quadSink.append(CCSolidColorDrawQuad::cre
ate(sharedQuadState, tileRect, backgroundColor())); | 155 appendQuadsData.hadMissingTiles |= quadSink.append(CCSolidCo
lorDrawQuad::create(sharedQuadState, tileRect, backgroundColor()), appendQuadsDa
ta); |
155 continue; | 156 continue; |
156 } | 157 } |
157 | 158 |
158 IntRect tileOpaqueRect = tile->opaqueRect(); | 159 IntRect tileOpaqueRect = tile->opaqueRect(); |
159 tileOpaqueRect.intersect(contentRect); | 160 tileOpaqueRect.intersect(contentRect); |
160 | 161 |
161 // Keep track of how the top left has moved, so the texture can be | 162 // Keep track of how the top left has moved, so the texture can be |
162 // offset the same amount. | 163 // offset the same amount. |
163 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX
MinYCorner(); | 164 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX
MinYCorner(); |
164 IntPoint textureOffset = m_tiler->textureOffset(i, j) + displayOffse
t; | 165 IntPoint textureOffset = m_tiler->textureOffset(i, j) + displayOffse
t; |
165 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); | 166 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); |
166 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); | 167 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); |
167 IntSize textureSize(tileWidth, tileHeight); | 168 IntSize textureSize(tileWidth, tileHeight); |
168 | 169 |
169 bool clipped = false; | 170 bool clipped = false; |
170 FloatQuad visibleContentInTargetQuad = CCMathUtil::mapQuad(drawTrans
form(), FloatQuad(visibleContentRect()), clipped); | 171 FloatQuad visibleContentInTargetQuad = CCMathUtil::mapQuad(drawTrans
form(), FloatQuad(visibleContentRect()), clipped); |
171 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad.
isRectilinear(); | 172 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad.
isRectilinear(); |
172 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget; | 173 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget; |
173 | 174 |
174 bool leftEdgeAA = !i && useAA; | 175 bool leftEdgeAA = !i && useAA; |
175 bool topEdgeAA = !j && useAA; | 176 bool topEdgeAA = !j && useAA; |
176 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA; | 177 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA; |
177 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA; | 178 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA; |
178 | 179 |
179 const GC3Dint textureFilter = m_tiler->hasBorderTexels() ? GraphicsC
ontext3D::LINEAR : GraphicsContext3D::NEAREST; | 180 const GC3Dint textureFilter = m_tiler->hasBorderTexels() ? GraphicsC
ontext3D::LINEAR : GraphicsContext3D::NEAREST; |
180 quadSink.append(CCTileDrawQuad::create(sharedQuadState, tileRect, ti
leOpaqueRect, tile->resourceId(), textureOffset, textureSize, textureFilter, con
tentsSwizzled(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA)); | 181 quadSink.append(CCTileDrawQuad::create(sharedQuadState, tileRect, ti
leOpaqueRect, tile->resourceId(), textureOffset, textureSize, textureFilter, con
tentsSwizzled(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA), appendQuadsD
ata); |
181 } | 182 } |
182 } | 183 } |
183 } | 184 } |
184 | 185 |
185 void CCTiledLayerImpl::setTilingData(const CCLayerTilingData& tiler) | 186 void CCTiledLayerImpl::setTilingData(const CCLayerTilingData& tiler) |
186 { | 187 { |
187 if (m_tiler) | 188 if (m_tiler) |
188 m_tiler->reset(); | 189 m_tiler->reset(); |
189 else | 190 else |
190 m_tiler = CCLayerTilingData::create(tiler.tileSize(), tiler.hasBorderTex
els() ? CCLayerTilingData::HasBorderTexels : CCLayerTilingData::NoBorderTexels); | 191 m_tiler = CCLayerTilingData::create(tiler.tileSize(), tiler.hasBorderTex
els() ? CCLayerTilingData::HasBorderTexels : CCLayerTilingData::NoBorderTexels); |
(...skipping 19 matching lines...) Expand all Loading... |
210 } | 211 } |
211 | 212 |
212 void CCTiledLayerImpl::didLoseContext() | 213 void CCTiledLayerImpl::didLoseContext() |
213 { | 214 { |
214 m_tiler->reset(); | 215 m_tiler->reset(); |
215 } | 216 } |
216 | 217 |
217 } // namespace WebCore | 218 } // namespace WebCore |
218 | 219 |
219 #endif // USE(ACCELERATED_COMPOSITING) | 220 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |