Changeset 93424 in webkit
- Timestamp:
- Aug 19, 2011 11:07:37 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 2 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93421 r93424 1 2011-08-17 Adrienne Walker <enne@google.com> 2 3 [chromium] Split tiler into main thread / compositor thread versions 4 https://bugs.webkit.org/show_bug.cgi?id=66065 5 6 Reviewed by James Robinson. 7 8 Covered by existing tests. 9 10 LayerTilerChromium is renamed to be CCLayerTilingData. Invalidation 11 and paint functionality is pushed into TiledLayerChromium and drawing 12 with GL is pushed into CCTiledLayerImpl. During tree synchronization, 13 the tiler properties and texture IDs are synchronized into 14 CCTiledLayerImpl. 15 16 * WebCore.gypi: 17 * platform/graphics/chromium/ContentLayerChromium.cpp: 18 (WebCore::ContentLayerChromium::paintContentsIfDirty): 19 (WebCore::ContentLayerChromium::createTextureUpdaterIfNeeded): 20 * platform/graphics/chromium/ContentLayerChromium.h: 21 * platform/graphics/chromium/ImageLayerChromium.cpp: 22 (WebCore::ImageLayerChromium::paintContentsIfDirty): 23 * platform/graphics/chromium/LayerRendererChromium.cpp: 24 (WebCore::LayerRendererChromium::bestTextureFormat): 25 (WebCore::LayerRendererChromium::initializeSharedObjects): 26 (WebCore::LayerRendererChromium::tilerProgram): 27 (WebCore::LayerRendererChromium::tilerProgramSwizzle): 28 (WebCore::LayerRendererChromium::tilerProgramAA): 29 (WebCore::LayerRendererChromium::tilerProgramSwizzleAA): 30 * platform/graphics/chromium/LayerRendererChromium.h: 31 * platform/graphics/chromium/LayerTextureUpdater.h: 32 * platform/graphics/chromium/LayerTilerChromium.cpp: Removed. 33 * platform/graphics/chromium/ManagedTexture.h: 34 (WebCore::ManagedTexture::textureId): 35 * platform/graphics/chromium/TiledLayerChromium.cpp: 36 (WebCore::UpdatableTile::UpdatableTile): 37 (WebCore::UpdatableTile::texture): 38 (WebCore::UpdatableTile::dirty): 39 (WebCore::UpdatableTile::clearDirty): 40 (WebCore::TiledLayerChromium::TiledLayerChromium): 41 (WebCore::TiledLayerChromium::cleanupResources): 42 (WebCore::TiledLayerChromium::drawsContent): 43 (WebCore::TiledLayerChromium::createTilerIfNeeded): 44 (WebCore::TiledLayerChromium::updateCompositorResources): 45 (WebCore::TiledLayerChromium::pushPropertiesTo): 46 (WebCore::TiledLayerChromium::dumpLayerProperties): 47 (WebCore::TiledLayerChromium::textureManager): 48 (WebCore::TiledLayerChromium::tileAt): 49 (WebCore::TiledLayerChromium::createTile): 50 (WebCore::TiledLayerChromium::invalidateTiles): 51 (WebCore::TiledLayerChromium::invalidateRect): 52 (WebCore::TiledLayerChromium::protectVisibleTileTextures): 53 (WebCore::TiledLayerChromium::protectTileTextures): 54 (WebCore::TiledLayerChromium::prepareToUpdate): 55 * platform/graphics/chromium/TiledLayerChromium.h: 56 * platform/graphics/chromium/cc/CCLayerTilingData.cpp: Added. 57 (WebCore::CCLayerTilingData::create): 58 (WebCore::CCLayerTilingData::CCLayerTilingData): 59 (WebCore::CCLayerTilingData::setTileSize): 60 (WebCore::CCLayerTilingData::operator=): 61 (WebCore::CCLayerTilingData::addTile): 62 (WebCore::CCLayerTilingData::takeTile): 63 (WebCore::CCLayerTilingData::tileAt): 64 (WebCore::CCLayerTilingData::reset): 65 (WebCore::CCLayerTilingData::contentRectToTileIndices): 66 (WebCore::CCLayerTilingData::contentRectToLayerRect): 67 (WebCore::CCLayerTilingData::layerRectToContentRect): 68 (WebCore::CCLayerTilingData::tileContentRect): 69 (WebCore::CCLayerTilingData::tileLayerRect): 70 (WebCore::CCLayerTilingData::setLayerPosition): 71 (WebCore::CCLayerTilingData::growLayerToContain): 72 * platform/graphics/chromium/cc/CCLayerTilingData.h: Renamed from Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h. 73 (WebCore::CCLayerTilingData::numTiles): 74 (WebCore::CCLayerTilingData::numTilesX): 75 (WebCore::CCLayerTilingData::numTilesY): 76 (WebCore::CCLayerTilingData::tileBounds): 77 (WebCore::CCLayerTilingData::textureOffset): 78 (WebCore::CCLayerTilingData::tileSize): 79 (WebCore::CCLayerTilingData::hasBorderTexels): 80 (WebCore::CCLayerTilingData::isEmpty): 81 (WebCore::CCLayerTilingData::Tile::Tile): 82 (WebCore::CCLayerTilingData::Tile::i): 83 (WebCore::CCLayerTilingData::Tile::j): 84 (WebCore::CCLayerTilingData::Tile::moveTo): 85 (WebCore::CCLayerTilingData::TileMapKeyTraits::emptyValue): 86 (WebCore::CCLayerTilingData::TileMapKeyTraits::constructDeletedValue): 87 (WebCore::CCLayerTilingData::TileMapKeyTraits::isDeletedValue): 88 (WebCore::CCLayerTilingData::tiles): 89 * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: 90 (WebCore::DrawableTile::DrawableTile): 91 (WebCore::DrawableTile::textureId): 92 (WebCore::DrawableTile::setTextureId): 93 (WebCore::CCTiledLayerImpl::CCTiledLayerImpl): 94 (WebCore::CCTiledLayerImpl::bindContentsTexture): 95 (WebCore::CCTiledLayerImpl::tileAt): 96 (WebCore::CCTiledLayerImpl::createTile): 97 (WebCore::CCTiledLayerImpl::draw): 98 (WebCore::CCTiledLayerImpl::setTilingData): 99 (WebCore::CCTiledLayerImpl::syncTextureId): 100 (WebCore::isCCW): 101 (WebCore::computeEdge): 102 (WebCore::intersect): 103 (WebCore::CCTiledLayerImpl::drawTiles): 104 * platform/graphics/chromium/cc/CCTiledLayerImpl.h: 105 (WebCore::CCTiledLayerImpl::setSkipsDraw): 106 (WebCore::CCTiledLayerImpl::setTextureOrientation): 107 (WebCore::CCTiledLayerImpl::setSampledTexelFormat): 108 * platform/graphics/gpu/TilingData.h: 109 1 110 2011-08-19 Dan Bernstein <mitz@apple.com> 2 111 -
trunk/Source/WebCore/WebCore.gypi
r93415 r93424 3511 3511 'platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp', 3512 3512 'platform/graphics/chromium/LayerTextureUpdaterCanvas.h', 3513 'platform/graphics/chromium/LayerTilerChromium.cpp',3514 'platform/graphics/chromium/LayerTilerChromium.h',3515 3513 'platform/graphics/chromium/NonCompositedContentHost.cpp', 3516 3514 'platform/graphics/chromium/NonCompositedContentHost.h', … … 3561 3559 'platform/graphics/chromium/cc/CCLayerSorter.cpp', 3562 3560 'platform/graphics/chromium/cc/CCLayerSorter.h', 3561 'platform/graphics/chromium/cc/CCLayerTilingData.cpp', 3562 'platform/graphics/chromium/cc/CCLayerTilingData.h', 3563 3563 'platform/graphics/chromium/cc/CCLayerTreeHost.cpp', 3564 3564 'platform/graphics/chromium/cc/CCLayerTreeHost.h', -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r93360 r93424 105 105 IntRect dirty = enclosingIntRect(m_dirtyRect); 106 106 dirty.intersect(IntRect(IntPoint(), contentBounds())); 107 m_tiler->invalidateRect(dirty);107 invalidateRect(dirty); 108 108 109 109 if (!drawsContent()) 110 110 return; 111 111 112 m_tiler->prepareToUpdate(layerRect, textureUpdater());112 prepareToUpdate(layerRect); 113 113 m_dirtyRect = FloatRect(); 114 114 } … … 123 123 if (m_textureUpdater) 124 124 return; 125 125 126 #if USE(SKIA) 126 127 if (layerRenderer()->settings().acceleratePainting) { … … 132 133 } 133 134 134 void ContentLayerChromium::protectVisibleTileTextures()135 {136 m_tiler->protectTileTextures(IntRect(IntPoint::zero(), contentBounds()));137 }138 139 135 } 140 136 #endif // USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r93360 r93424 61 61 virtual void createTextureUpdaterIfNeeded(); 62 62 virtual LayerTextureUpdater* textureUpdater() const { return m_textureUpdater.get(); } 63 virtual void protectVisibleTileTextures();64 63 65 64 OwnPtr<LayerTextureUpdater> m_textureUpdater; -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r93360 r93424 155 155 IntRect paintRect(IntPoint(), contentBounds()); 156 156 if (!m_dirtyRect.isEmpty()) { 157 m_tiler->invalidateRect(paintRect);157 invalidateRect(paintRect); 158 158 m_dirtyRect = IntRect(); 159 159 } … … 163 163 return; 164 164 165 m_tiler->prepareToUpdate(visibleLayerRect(), m_textureUpdater.get());165 prepareToUpdate(visibleLayerRect()); 166 166 } 167 167 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r93387 r93424 46 46 #include "NonCompositedContentHost.h" 47 47 #include "NotImplemented.h" 48 #include "PlatformColor.h" 48 49 #include "RenderSurfaceChromium.h" 49 50 #include "TextStream.h" … … 538 539 } 539 540 541 GC3Denum LayerRendererChromium::bestTextureFormat() 542 { 543 return PlatformColor::bestTextureFormat(context()); 544 } 545 540 546 void LayerRendererChromium::viewportChanged() 541 547 { … … 1115 1121 m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get())); 1116 1122 m_renderSurfaceProgram = adoptPtr(new CCRenderSurface::Program(m_context.get())); 1117 m_tilerProgram = adoptPtr(new LayerTilerChromium::Program(m_context.get()));1123 m_tilerProgram = adoptPtr(new CCTiledLayerImpl::Program(m_context.get())); 1118 1124 1119 1125 GLC(m_context.get(), m_context->flush()); … … 1171 1177 } 1172 1178 1173 const LayerTilerChromium::Program* LayerRendererChromium::tilerProgram()1179 const CCTiledLayerImpl::Program* LayerRendererChromium::tilerProgram() 1174 1180 { 1175 1181 ASSERT(m_tilerProgram); … … 1181 1187 } 1182 1188 1183 const LayerTilerChromium::ProgramSwizzle* LayerRendererChromium::tilerProgramSwizzle()1189 const CCTiledLayerImpl::ProgramSwizzle* LayerRendererChromium::tilerProgramSwizzle() 1184 1190 { 1185 1191 if (!m_tilerProgramSwizzle) 1186 m_tilerProgramSwizzle = adoptPtr(new LayerTilerChromium::ProgramSwizzle(m_context.get()));1192 m_tilerProgramSwizzle = adoptPtr(new CCTiledLayerImpl::ProgramSwizzle(m_context.get())); 1187 1193 if (!m_tilerProgramSwizzle->initialized()) { 1188 1194 TRACE_EVENT("LayerRendererChromium::tilerProgramSwizzle::initialize", this, 0); … … 1192 1198 } 1193 1199 1194 const LayerTilerChromium::ProgramAA* LayerRendererChromium::tilerProgramAA()1200 const CCTiledLayerImpl::ProgramAA* LayerRendererChromium::tilerProgramAA() 1195 1201 { 1196 1202 if (!m_tilerProgramAA) 1197 m_tilerProgramAA = adoptPtr(new LayerTilerChromium::ProgramAA(m_context.get()));1203 m_tilerProgramAA = adoptPtr(new CCTiledLayerImpl::ProgramAA(m_context.get())); 1198 1204 if (!m_tilerProgramAA->initialized()) { 1199 1205 TRACE_EVENT("LayerRendererChromium::tilerProgramAA::initialize", this, 0); … … 1203 1209 } 1204 1210 1205 const LayerTilerChromium::ProgramSwizzleAA* LayerRendererChromium::tilerProgramSwizzleAA()1211 const CCTiledLayerImpl::ProgramSwizzleAA* LayerRendererChromium::tilerProgramSwizzleAA() 1206 1212 { 1207 1213 if (!m_tilerProgramSwizzleAA) 1208 m_tilerProgramSwizzleAA = adoptPtr(new LayerTilerChromium::ProgramSwizzleAA(m_context.get()));1214 m_tilerProgramSwizzleAA = adoptPtr(new CCTiledLayerImpl::ProgramSwizzleAA(m_context.get())); 1209 1215 if (!m_tilerProgramSwizzleAA->initialized()) { 1210 1216 TRACE_EVENT("LayerRendererChromium::tilerProgramSwizzleAA::initialize", this, 0); -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r93360 r93424 38 38 #include "IntRect.h" 39 39 #include "LayerChromium.h" 40 #include "LayerTilerChromium.h"41 40 #include "VideoLayerChromium.h" 42 41 #include "cc/CCCanvasLayerImpl.h" … … 125 124 const CCRenderSurface::Program* renderSurfaceProgram(); 126 125 const CCRenderSurface::MaskProgram* renderSurfaceMaskProgram(); 127 const LayerTilerChromium::Program* tilerProgram();128 const LayerTilerChromium::ProgramSwizzle* tilerProgramSwizzle();129 const LayerTilerChromium::ProgramAA* tilerProgramAA();130 const LayerTilerChromium::ProgramSwizzleAA* tilerProgramSwizzleAA();126 const CCTiledLayerImpl::Program* tilerProgram(); 127 const CCTiledLayerImpl::ProgramSwizzle* tilerProgramSwizzle(); 128 const CCTiledLayerImpl::ProgramAA* tilerProgramAA(); 129 const CCTiledLayerImpl::ProgramSwizzleAA* tilerProgramSwizzleAA(); 131 130 const CCCanvasLayerImpl::Program* canvasLayerProgram(); 132 131 const CCPluginLayerImpl::Program* pluginLayerProgram(); … … 154 153 155 154 void setLayerRendererRecursive(LayerChromium*); 155 156 GC3Denum bestTextureFormat(); 156 157 157 158 #ifndef NDEBUG … … 219 220 OwnPtr<LayerChromium::BorderProgram> m_borderProgram; 220 221 OwnPtr<CCHeadsUpDisplay::Program> m_headsUpDisplayProgram; 221 OwnPtr< LayerTilerChromium::Program> m_tilerProgram;222 OwnPtr< LayerTilerChromium::ProgramSwizzle> m_tilerProgramSwizzle;223 OwnPtr< LayerTilerChromium::ProgramAA> m_tilerProgramAA;224 OwnPtr< LayerTilerChromium::ProgramSwizzleAA> m_tilerProgramSwizzleAA;222 OwnPtr<CCTiledLayerImpl::Program> m_tilerProgram; 223 OwnPtr<CCTiledLayerImpl::ProgramSwizzle> m_tilerProgramSwizzle; 224 OwnPtr<CCTiledLayerImpl::ProgramAA> m_tilerProgramAA; 225 OwnPtr<CCTiledLayerImpl::ProgramSwizzleAA> m_tilerProgramSwizzleAA; 225 226 OwnPtr<CCCanvasLayerImpl::Program> m_canvasLayerProgram; 226 227 OwnPtr<CCPluginLayerImpl::Program> m_pluginLayerProgram; -
trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h
r92900 r93424 31 31 32 32 #include "GraphicsTypes3D.h" 33 #include <wtf/Noncopyable.h> 33 34 34 35 namespace WebCore { … … 79 80 #endif // USE(ACCELERATED_COMPOSITING) 80 81 #endif // LayerTextureUpdater_h 81 -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h
r92900 r93424 61 61 void framebufferTexture2D(GraphicsContext3D*); 62 62 63 unsigned textureId() const { return m_textureId; } 64 63 65 private: 64 66 explicit ManagedTexture(TextureManager*); … … 74 76 75 77 #endif // ManagedTexture_h 76 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r93360 r93424 32 32 #include "GraphicsContext3D.h" 33 33 #include "LayerRendererChromium.h" 34 #include " LayerTilerChromium.h"34 #include "ManagedTexture.h" 35 35 #include "TextStream.h" 36 36 #include "cc/CCLayerImpl.h" … … 48 48 namespace WebCore { 49 49 50 class UpdatableTile : public CCLayerTilingData::Tile { 51 WTF_MAKE_NONCOPYABLE(UpdatableTile); 52 public: 53 explicit UpdatableTile(PassOwnPtr<ManagedTexture> tex) : m_tex(tex) { } 54 55 ManagedTexture* texture() { return m_tex.get(); } 56 57 bool dirty() const { return !m_dirtyLayerRect.isEmpty(); } 58 void clearDirty() { m_dirtyLayerRect = IntRect(); } 59 60 // Layer-space dirty rectangle that needs to be repainted. 61 IntRect m_dirtyLayerRect; 62 private: 63 OwnPtr<ManagedTexture> m_tex; 64 }; 65 50 66 TiledLayerChromium::TiledLayerChromium(GraphicsLayerChromium* owner) 51 67 : LayerChromium(owner) 52 68 , m_tilingOption(AutoTile) 69 , m_textureFormat(GraphicsContext3D::INVALID_ENUM) 70 , m_skipsDraw(false) 71 , m_textureOrientation(LayerTextureUpdater::InvalidOrientation) 72 , m_sampledTexelFormat(LayerTextureUpdater::SampledTexelFormatInvalid) 53 73 { 54 74 } … … 65 85 void TiledLayerChromium::cleanupResources() 66 86 { 87 LayerChromium::cleanupResources(); 88 67 89 m_tiler.clear(); 68 LayerChromium::cleanupResources(); 90 m_unusedTiles.clear(); 91 m_paintRect = IntRect(); 92 m_updateRect = IntRect(); 69 93 } 70 94 … … 114 138 return false; 115 139 116 return !m_ tiler->skipsDraw();140 return !m_skipsDraw; 117 141 } 118 142 … … 124 148 createTextureUpdaterIfNeeded(); 125 149 126 m_tiler = LayerTilerChromium::create( 127 layerRenderer(), 150 m_textureFormat = layerRenderer()->bestTextureFormat(); 151 m_textureOrientation = textureUpdater()->orientation(); 152 m_sampledTexelFormat = textureUpdater()->sampledTexelFormat(m_textureFormat); 153 154 m_tiler = CCLayerTilingData::create( 128 155 IntSize(defaultTileSize, defaultTileSize), 129 isRootLayer() ? LayerTilerChromium::NoBorderTexels : LayerTilerChromium::HasBorderTexels);156 isRootLayer() ? CCLayerTilingData::NoBorderTexels : CCLayerTilingData::HasBorderTexels); 130 157 } 131 158 132 159 void TiledLayerChromium::updateCompositorResources() 133 160 { 134 m_tiler->updateRect(textureUpdater()); 161 // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. 162 if (m_skipsDraw || m_updateRect.isEmpty() || !m_tiler->numTiles()) 163 return; 164 165 GraphicsContext3D* context = layerRenderer()->context(); 166 int left, top, right, bottom; 167 m_tiler->contentRectToTileIndices(m_updateRect, left, top, right, bottom); 168 for (int j = top; j <= bottom; ++j) { 169 for (int i = left; i <= right; ++i) { 170 UpdatableTile* tile = tileAt(i, j); 171 if (!tile) 172 tile = createTile(i, j); 173 else if (!tile->dirty()) 174 continue; 175 176 // Calculate page-space rectangle to copy from. 177 IntRect sourceRect = m_tiler->tileContentRect(tile); 178 const IntPoint anchor = sourceRect.location(); 179 sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect)); 180 // Paint rect not guaranteed to line up on tile boundaries, so 181 // make sure that sourceRect doesn't extend outside of it. 182 sourceRect.intersect(m_paintRect); 183 if (sourceRect.isEmpty()) 184 continue; 185 186 ASSERT(tile->texture()->isReserved()); 187 188 // Calculate tile-space rectangle to upload into. 189 IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size()); 190 if (destRect.x() < 0) 191 CRASH(); 192 if (destRect.y() < 0) 193 CRASH(); 194 195 // Offset from paint rectangle to this tile's dirty rectangle. 196 IntPoint paintOffset(sourceRect.x() - m_paintRect.x(), sourceRect.y() - m_paintRect.y()); 197 if (paintOffset.x() < 0) 198 CRASH(); 199 if (paintOffset.y() < 0) 200 CRASH(); 201 if (paintOffset.x() + destRect.width() > m_paintRect.width()) 202 CRASH(); 203 if (paintOffset.y() + destRect.height() > m_paintRect.height()) 204 CRASH(); 205 206 tile->texture()->bindTexture(context); 207 const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; 208 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); 209 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); 210 GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); 211 212 textureUpdater()->updateTextureRect(tile->texture(), sourceRect, destRect); 213 tile->clearDirty(); 214 } 215 } 135 216 } 136 217 … … 170 251 CCTiledLayerImpl* tiledLayer = static_cast<CCTiledLayerImpl*>(layer); 171 252 tiledLayer->setTilingTransform(tilingTransform()); 172 tiledLayer->setTiler(m_tiler.get()); 253 tiledLayer->setSkipsDraw(m_skipsDraw); 254 tiledLayer->setTextureOrientation(m_textureOrientation); 255 tiledLayer->setSampledTexelFormat(m_sampledTexelFormat); 256 tiledLayer->setTilingData(*m_tiler); 257 258 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { 259 int i = iter->first.first; 260 int j = iter->first.second; 261 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); 262 if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) 263 continue; 264 265 tiledLayer->syncTextureId(i, j, tile->texture()->textureId()); 266 } 173 267 } 174 268 … … 183 277 LayerChromium::dumpLayerProperties(ts, indent); 184 278 writeIndent(ts, indent); 185 ts << "skipsDraw: " << (!m_tiler || m_tiler->skipsDraw()) << "\n"; 279 ts << "skipsDraw: " << (!m_tiler || m_skipsDraw) << "\n"; 280 } 281 282 TextureManager* TiledLayerChromium::textureManager() const 283 { 284 if (!layerRenderer()) 285 return 0; 286 return layerRenderer()->contentsTextureManager(); 287 } 288 289 UpdatableTile* TiledLayerChromium::tileAt(int i, int j) const 290 { 291 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j)); 292 } 293 294 UpdatableTile* TiledLayerChromium::createTile(int i, int j) 295 { 296 RefPtr<UpdatableTile> tile; 297 if (m_unusedTiles.size() > 0) { 298 tile = m_unusedTiles.last().release(); 299 m_unusedTiles.removeLast(); 300 ASSERT(tile->refCount() == 1); 301 } else { 302 TextureManager* manager = textureManager(); 303 tile = adoptRef(new UpdatableTile(ManagedTexture::create(manager))); 304 } 305 m_tiler->addTile(tile, i, j); 306 tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile.get()); 307 308 return tile.get(); 309 } 310 311 void TiledLayerChromium::invalidateTiles(const IntRect& contentRect) 312 { 313 if (!m_tiler->numTiles()) 314 return; 315 316 Vector<CCLayerTilingData::TileMapKey> removeKeys; 317 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { 318 CCLayerTilingData::Tile* tile = iter->second.get(); 319 IntRect tileRect = m_tiler->tileContentRect(tile); 320 if (tileRect.intersects(contentRect)) 321 continue; 322 removeKeys.append(iter->first); 323 } 324 325 for (size_t i = 0; i < removeKeys.size(); ++i) 326 m_unusedTiles.append(static_pointer_cast<UpdatableTile>(m_tiler->takeTile(removeKeys[i].first, removeKeys[i].second))); 327 } 328 329 void TiledLayerChromium::invalidateRect(const IntRect& contentRect) 330 { 331 if (contentRect.isEmpty() || m_skipsDraw) 332 return; 333 334 m_tiler->growLayerToContain(contentRect); 335 336 // Dirty rects are always in layer space, as the layer could be repositioned 337 // after invalidation. 338 const IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect); 339 340 int left, top, right, bottom; 341 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); 342 for (int j = top; j <= bottom; ++j) { 343 for (int i = left; i <= right; ++i) { 344 UpdatableTile* tile = tileAt(i, j); 345 if (!tile) 346 continue; 347 IntRect bound = m_tiler->tileLayerRect(tile); 348 bound.intersect(layerRect); 349 tile->m_dirtyLayerRect.unite(bound); 350 } 351 } 352 } 353 354 void TiledLayerChromium::protectVisibleTileTextures() 355 { 356 protectTileTextures(IntRect(IntPoint::zero(), contentBounds())); 357 } 358 359 void TiledLayerChromium::protectTileTextures(const IntRect& contentRect) 360 { 361 if (contentRect.isEmpty()) 362 return; 363 364 int left, top, right, bottom; 365 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); 366 367 for (int j = top; j <= bottom; ++j) { 368 for (int i = left; i <= right; ++i) { 369 UpdatableTile* tile = tileAt(i, j); 370 if (!tile || !tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) 371 continue; 372 373 tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat); 374 } 375 } 376 } 377 378 void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) 379 { 380 m_skipsDraw = false; 381 382 if (contentRect.isEmpty()) { 383 m_updateRect = IntRect(); 384 return; 385 } 386 387 // Invalidate old tiles that were previously used but aren't in use this 388 // frame so that they can get reused for new tiles. 389 invalidateTiles(contentRect); 390 m_tiler->growLayerToContain(contentRect); 391 392 if (!m_tiler->numTiles()) { 393 m_updateRect = IntRect(); 394 return; 395 } 396 397 // Create tiles as needed, expanding a dirty rect to contain all 398 // the dirty regions currently being drawn. 399 IntRect dirtyLayerRect; 400 int left, top, right, bottom; 401 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); 402 for (int j = top; j <= bottom; ++j) { 403 for (int i = left; i <= right; ++i) { 404 UpdatableTile* tile = tileAt(i, j); 405 if (!tile) 406 tile = createTile(i, j); 407 408 if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) 409 tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile); 410 411 if (!tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat)) { 412 m_skipsDraw = true; 413 cleanupResources(); 414 return; 415 } 416 417 dirtyLayerRect.unite(tile->m_dirtyLayerRect); 418 } 419 } 420 421 // Due to borders, when the paint rect is extended to tile boundaries, it 422 // may end up overlapping more tiles than the original content rect. Record 423 // that original rect so we don't upload more tiles than necessary. 424 m_updateRect = contentRect; 425 426 m_paintRect = m_tiler->layerRectToContentRect(dirtyLayerRect); 427 if (dirtyLayerRect.isEmpty()) 428 return; 429 430 textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels()); 186 431 } 187 432 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r92900 r93424 30 30 31 31 #include "LayerChromium.h" 32 #include "cc/CCLayerTilingData.h" 32 33 #include "cc/CCTiledLayerImpl.h" 33 34 34 35 namespace WebCore { 35 36 36 class LayerTilerChromium;37 37 class LayerTextureUpdater; 38 class UpdatableTile; 38 39 39 40 class TiledLayerChromium : public LayerChromium { … … 50 51 virtual bool drawsContent() const; 51 52 53 // Reserves all existing and valid tile textures to protect them from being 54 // recycled by the texture manager. 55 void protectTileTextures(const IntRect& contentRect); 56 52 57 protected: 53 58 explicit TiledLayerChromium(GraphicsLayerChromium*); … … 59 64 virtual LayerTextureUpdater* textureUpdater() const = 0; 60 65 61 OwnPtr<LayerTilerChromium> m_tiler; 66 // Set invalidations to be potentially repainted during update(). 67 void invalidateRect(const IntRect& contentRect); 68 // Prepare data needed to update textures that intersect with contentRect. 69 void prepareToUpdate(const IntRect& contentRect); 70 // Update invalid textures that intersect with contentRect provided in prepareToUpdate(). 71 void updateRect(GraphicsContext3D*, LayerTextureUpdater*); 72 virtual void protectVisibleTileTextures(); 62 73 63 74 private: … … 72 83 TransformationMatrix tilingTransform() const; 73 84 85 UpdatableTile* tileAt(int, int) const; 86 UpdatableTile* createTile(int, int); 87 void invalidateTiles(const IntRect& contentRect); 88 89 TextureManager* textureManager() const; 90 91 // State held between update and upload. 92 IntRect m_paintRect; 93 IntRect m_updateRect; 94 95 // Tightly packed set of unused tiles. 96 Vector<RefPtr<UpdatableTile> > m_unusedTiles; 97 74 98 TilingOption m_tilingOption; 99 GC3Denum m_textureFormat; 100 bool m_skipsDraw; 101 LayerTextureUpdater::Orientation m_textureOrientation; 102 LayerTextureUpdater::SampledTexelFormat m_sampledTexelFormat; 103 104 OwnPtr<CCLayerTilingData> m_tiler; 75 105 }; 76 106 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r93360 r93424 30 30 #include "cc/CCTiledLayerImpl.h" 31 31 32 #include "FloatQuad.h" 32 33 #include "LayerRendererChromium.h" 33 34 #include "cc/CCLayerTreeHostImplProxy.h" 34 35 #include <wtf/text/WTFString.h> 35 36 37 using namespace std; 38 36 39 namespace WebCore { 37 40 41 typedef FloatPoint3D Edge; 38 42 class ManagedTexture; 43 44 class DrawableTile : public CCLayerTilingData::Tile { 45 WTF_MAKE_NONCOPYABLE(DrawableTile); 46 public: 47 DrawableTile() : m_textureId(0) { } 48 49 Platform3DObject textureId() const { return m_textureId; } 50 void setTextureId(Platform3DObject textureId) { m_textureId = textureId; } 51 private: 52 Platform3DObject m_textureId; 53 }; 39 54 40 55 CCTiledLayerImpl::CCTiledLayerImpl(int id) 41 56 : CCLayerImpl(id) 42 , m_tiler(0)43 57 { 44 58 } … … 46 60 CCTiledLayerImpl::~CCTiledLayerImpl() 47 61 { 48 }49 50 void CCTiledLayerImpl::draw()51 {52 ASSERT(CCLayerTreeHostImplProxy::isImplThread());53 const IntRect& layerRect = visibleLayerRect();54 if (!layerRect.isEmpty()) {55 GraphicsContext3D* context = layerRenderer()->context();56 // Mask out writes to the alpha channel and disable blending for the root layer,57 // subpixel antialiasing on windows results in invalid zero alpha values on text58 // glyphs. The root layer is always opaque so the alpha channel isn't meaningful anyway.59 if (isRootLayer()) {60 GLC(context, context->colorMask(true, true, true, false));61 GLC(context, context->disable(GraphicsContext3D::BLEND));62 }63 m_tiler->draw(layerRect, m_tilingTransform, drawOpacity());64 if (isRootLayer()) {65 context->colorMask(true, true, true, true);66 GLC(context, context->enable(GraphicsContext3D::BLEND));67 }68 }69 62 } 70 63 … … 73 66 // This function is only valid for single texture layers, e.g. masks. 74 67 ASSERT(m_tiler); 75 76 ManagedTexture* texture = m_tiler->getSingleTexture(); 77 ASSERT(texture); 78 79 texture->bindTexture(layerRenderer()->context()); 68 ASSERT(m_tiler->numTiles() == 1); 69 70 DrawableTile* tile = tileAt(0, 0); 71 Platform3DObject textureId = tile ? tile->textureId() : 0; 72 ASSERT(textureId); 73 74 layerRenderer()->context()->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId); 80 75 } 81 76 … … 86 81 } 87 82 83 DrawableTile* CCTiledLayerImpl::tileAt(int i, int j) const 84 { 85 return static_cast<DrawableTile*>(m_tiler->tileAt(i, j)); 86 } 87 88 DrawableTile* CCTiledLayerImpl::createTile(int i, int j) 89 { 90 RefPtr<DrawableTile> tile = adoptRef(new DrawableTile()); 91 m_tiler->addTile(tile, i, j); 92 return tile.get(); 93 } 94 95 void CCTiledLayerImpl::draw() 96 { 97 const IntRect& layerRect = visibleLayerRect(); 98 99 if (m_skipsDraw || m_tiler->isEmpty() || layerRect.isEmpty() || !layerRenderer()) 100 return; 101 102 #if defined(OS_CHROMEOS) 103 // FIXME: Disable anti-aliasing to workaround broken driver. 104 bool useAA = false; 105 #else 106 // Use anti-aliasing programs when border texels are preset and transform 107 // is not an integer translation. 108 bool useAA = (m_tiler->hasBorderTexels() && !m_tilingTransform.isIntegerTranslation()); 109 #endif 110 111 GraphicsContext3D* context = layerRenderer()->context(); 112 if (isRootLayer()) { 113 context->colorMask(true, true, true, false); 114 GLC(context, context->disable(GraphicsContext3D::BLEND)); 115 } 116 117 switch (m_sampledTexelFormat) { 118 case LayerTextureUpdater::SampledTexelFormatRGBA: 119 if (useAA) 120 drawTiles(layerRenderer(), layerRect, m_tilingTransform, drawOpacity(), layerRenderer()->tilerProgramAA(), layerRenderer()->tilerProgramAA()->fragmentShader().fragmentTexTransformLocation(), layerRenderer()->tilerProgramAA()->fragmentShader().edgeLocation()); 121 else 122 drawTiles(layerRenderer(), layerRect, m_tilingTransform, drawOpacity(), layerRenderer()->tilerProgram(), -1, -1); 123 break; 124 case LayerTextureUpdater::SampledTexelFormatBGRA: 125 if (useAA) 126 drawTiles(layerRenderer(), layerRect, m_tilingTransform, drawOpacity(), layerRenderer()->tilerProgramSwizzleAA(), layerRenderer()->tilerProgramSwizzleAA()->fragmentShader().fragmentTexTransformLocation(), layerRenderer()->tilerProgramSwizzleAA()->fragmentShader().edgeLocation()); 127 else 128 drawTiles(layerRenderer(), layerRect, m_tilingTransform, drawOpacity(), layerRenderer()->tilerProgramSwizzle(), -1, -1); 129 break; 130 default: 131 ASSERT_NOT_REACHED(); 132 } 133 134 if (isRootLayer()) { 135 context->colorMask(true, true, true, true); 136 GLC(context, context->enable(GraphicsContext3D::BLEND)); 137 } 138 } 139 140 void CCTiledLayerImpl::setTilingData(const CCLayerTilingData& tiler) 141 { 142 if (m_tiler) 143 m_tiler->reset(); 144 else 145 m_tiler = CCLayerTilingData::create(tiler.tileSize(), tiler.hasBorderTexels() ? CCLayerTilingData::HasBorderTexels : CCLayerTilingData::NoBorderTexels); 146 *m_tiler = tiler; 147 } 148 149 void CCTiledLayerImpl::syncTextureId(int i, int j, Platform3DObject textureId) 150 { 151 DrawableTile* tile = tileAt(i, j); 152 if (!tile) 153 tile = createTile(i, j); 154 tile->setTextureId(textureId); 155 } 156 157 static bool isCCW(const FloatQuad& quad) 158 { 159 FloatPoint v1 = FloatPoint(quad.p2().x() - quad.p1().x(), 160 quad.p2().y() - quad.p1().y()); 161 FloatPoint v2 = FloatPoint(quad.p3().x() - quad.p2().x(), 162 quad.p3().y() - quad.p2().y()); 163 return (v1.x() * v2.y() - v1.y() * v2.x()) < 0; 164 } 165 166 static Edge computeEdge(const FloatPoint& p, const FloatPoint& q, float sign) 167 { 168 ASSERT(p != q); 169 170 FloatPoint tangent(p.y() - q.y(), q.x() - p.x()); 171 float scale = sign / tangent.length(); 172 float cross2 = p.x() * q.y() - q.x() * p.y(); 173 174 return Edge(tangent.x() * scale, 175 tangent.y() * scale, 176 cross2 * scale); 177 } 178 179 static FloatPoint intersect(const Edge& a, const Edge& b) 180 { 181 return FloatPoint( 182 (a.y() * b.z() - b.y() * a.z()) / (a.x() * b.y() - b.x() * a.y()), 183 (a.x() * b.z() - b.x() * a.z()) / (b.x() * a.y() - a.x() * b.y())); 184 } 185 186 template <class T> 187 void CCTiledLayerImpl::drawTiles(LayerRendererChromium* layerRenderer, const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity, const T* program, int fragmentTexTransformLocation, int edgeLocation) 188 { 189 TransformationMatrix matrix(layerRenderer->windowMatrix() * layerRenderer->projectionMatrix() * globalTransform); 190 191 // We don't care about Z component. 192 TransformationMatrix matrixXYW = 193 TransformationMatrix(matrix.m11(), matrix.m12(), 0, matrix.m14(), 194 matrix.m21(), matrix.m22(), 0, matrix.m24(), 195 matrix.m31(), matrix.m32(), 1, matrix.m34(), 196 matrix.m41(), matrix.m42(), 0, matrix.m44()); 197 198 // Don't draw any tiles when matrix is not invertible. 199 if (!matrixXYW.isInvertible()) 200 return; 201 202 TransformationMatrix inverse = matrixXYW.inverse(); 203 204 GraphicsContext3D* context = layerRenderer->context(); 205 GLC(context, context->useProgram(program->program())); 206 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 207 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); 208 209 // Map content rectangle to device space. 210 FloatQuad deviceQuad = matrix.mapQuad(FloatQuad(contentRect)); 211 212 // Counter-clockwise? 213 float sign = isCCW(deviceQuad) ? -1 : 1; 214 215 // Compute outer edges. 216 Edge leftEdge = computeEdge(deviceQuad.p4(), deviceQuad.p1(), sign); 217 Edge rightEdge = computeEdge(deviceQuad.p2(), deviceQuad.p3(), sign); 218 Edge topEdge = computeEdge(deviceQuad.p1(), deviceQuad.p2(), sign); 219 Edge bottomEdge = computeEdge(deviceQuad.p3(), deviceQuad.p4(), sign); 220 221 if (edgeLocation != -1) { 222 // Move outer edges to ensure that all partially covered pixels are 223 // processed. 224 leftEdge.move(0, 0, 0.5f); 225 rightEdge.move(0, 0, 0.5f); 226 topEdge.move(0, 0, 0.5f); 227 bottomEdge.move(0, 0, 0.5f); 228 229 float edge[12]; 230 edge[0] = leftEdge.x(); 231 edge[1] = leftEdge.y(); 232 edge[2] = leftEdge.z(); 233 edge[3] = topEdge.x(); 234 edge[4] = topEdge.y(); 235 edge[5] = topEdge.z(); 236 edge[6] = rightEdge.x(); 237 edge[7] = rightEdge.y(); 238 edge[8] = rightEdge.z(); 239 edge[9] = bottomEdge.x(); 240 edge[10] = bottomEdge.y(); 241 edge[11] = bottomEdge.z(); 242 GLC(context, context->uniform3fv(edgeLocation, edge, 4)); 243 } 244 245 Edge prevEdgeY = topEdge; 246 247 int left, top, right, bottom; 248 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); 249 IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect); 250 for (int j = top; j <= bottom; ++j) { 251 Edge prevEdgeX = leftEdge; 252 253 Edge edgeY = bottomEdge; 254 if (j < (m_tiler->numTilesY() - 1)) { 255 IntRect tileRect = unionRect(m_tiler->tileBounds(0, j), m_tiler->tileBounds(m_tiler->numTilesX() - 1, j)); 256 tileRect.intersect(layerRect); 257 258 // Skip empty rows. 259 if (tileRect.isEmpty()) 260 continue; 261 262 tileRect = m_tiler->layerRectToContentRect(tileRect); 263 264 FloatPoint p1(tileRect.maxX(), tileRect.maxY()); 265 FloatPoint p2(tileRect.x(), tileRect.maxY()); 266 267 // Map points to device space. 268 p1 = matrix.mapPoint(p1); 269 p2 = matrix.mapPoint(p2); 270 271 // Compute horizontal edge. 272 edgeY = computeEdge(p1, p2, sign); 273 } 274 275 for (int i = left; i <= right; ++i) { 276 DrawableTile* tile = tileAt(i, j); 277 if (!tile || !tile->textureId()) 278 continue; 279 280 context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId()); 281 282 // Don't use tileContentRect here, as that contains the full 283 // rect with border texels which shouldn't be drawn. 284 IntRect tileRect = m_tiler->tileBounds(tile->i(), tile->j()); 285 IntRect displayRect = tileRect; 286 tileRect.intersect(layerRect); 287 288 // Keep track of how the top left has moved, so the texture can be 289 // offset the same amount. 290 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minXMinYCorner(); 291 292 // Skip empty tiles. 293 if (tileRect.isEmpty()) 294 continue; 295 296 tileRect = m_tiler->layerRectToContentRect(tileRect); 297 298 FloatRect clampRect(tileRect); 299 // Clamp texture coordinates to avoid sampling outside the layer 300 // by deflating the tile region half a texel or half a texel 301 // minus epsilon for one pixel layers. The resulting clamp region 302 // is mapped to the unit square by the vertex shader and mapped 303 // back to normalized texture coordinates by the fragment shader 304 // after being clamped to 0-1 range. 305 const float epsilon = 1 / 1024.0f; 306 float clampX = min(0.5, clampRect.width() / 2.0 - epsilon); 307 float clampY = min(0.5, clampRect.height() / 2.0 - epsilon); 308 clampRect.inflateX(-clampX); 309 clampRect.inflateY(-clampY); 310 FloatSize clampOffset = clampRect.minXMinYCorner() - FloatRect(tileRect).minXMinYCorner(); 311 312 FloatPoint texOffset = m_tiler->textureOffset(tile->i(), tile->j()) + clampOffset + FloatSize(displayOffset); 313 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); 314 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); 315 316 // Map clamping rectangle to unit square. 317 float vertexTexTranslateX = -clampRect.x() / clampRect.width(); 318 float vertexTexTranslateY = -clampRect.y() / clampRect.height(); 319 float vertexTexScaleX = tileRect.width() / clampRect.width(); 320 float vertexTexScaleY = tileRect.height() / clampRect.height(); 321 322 // Map to normalized texture coordinates. 323 float fragmentTexTranslateX = texOffset.x() / tileWidth; 324 float fragmentTexTranslateY = texOffset.y() / tileHeight; 325 float fragmentTexScaleX = clampRect.width() / tileWidth; 326 float fragmentTexScaleY = clampRect.height() / tileHeight; 327 328 // OpenGL coordinate system is bottom-up. 329 // If tile texture is top-down, we need to flip the texture coordinates. 330 if (m_textureOrientation == LayerTextureUpdater::TopDownOrientation) { 331 fragmentTexTranslateY = 1.0 - fragmentTexTranslateY; 332 fragmentTexScaleY *= -1.0; 333 } 334 335 Edge edgeX = rightEdge; 336 if (i < (m_tiler->numTilesX() - 1)) { 337 FloatPoint p1(tileRect.maxX(), tileRect.y()); 338 FloatPoint p2(tileRect.maxX(), tileRect.maxY()); 339 340 // Map points to device space. 341 p1 = matrix.mapPoint(p1); 342 p2 = matrix.mapPoint(p2); 343 344 // Compute vertical edge. 345 edgeX = computeEdge(p1, p2, sign); 346 } 347 348 // Create device space quad. 349 FloatQuad deviceQuad(intersect(edgeY, prevEdgeX), 350 intersect(prevEdgeX, prevEdgeY), 351 intersect(prevEdgeY, edgeX), 352 intersect(edgeX, edgeY)); 353 354 // Map quad to layer space. 355 FloatQuad quad = inverse.mapQuad(deviceQuad); 356 357 // Normalize to tileRect. 358 quad.scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); 359 360 if (fragmentTexTransformLocation == -1) { 361 // Move fragment shader transform to vertex shader. We can do 362 // this while still producing correct results as 363 // fragmentTexTransformLocation should always be non-negative 364 // when tiles are transformed in a way that could result in 365 // sampling outside the layer. 366 vertexTexScaleX *= fragmentTexScaleX; 367 vertexTexScaleY *= fragmentTexScaleY; 368 vertexTexTranslateX *= fragmentTexScaleX; 369 vertexTexTranslateY *= fragmentTexScaleY; 370 vertexTexTranslateX += fragmentTexTranslateX; 371 vertexTexTranslateY += fragmentTexTranslateY; 372 } else 373 GLC(context, context->uniform4f(fragmentTexTransformLocation, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexScaleY)); 374 375 GLC(context, context->uniform4f(program->vertexShader().vertexTexTransformLocation(), vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); 376 377 float point[8]; 378 point[0] = quad.p1().x(); 379 point[1] = quad.p1().y(); 380 point[2] = quad.p2().x(); 381 point[3] = quad.p2().y(); 382 point[4] = quad.p3().x(); 383 point[5] = quad.p3().y(); 384 point[6] = quad.p4().x(); 385 point[7] = quad.p4().y(); 386 GLC(context, context->uniform2fv(program->vertexShader().pointLocation(), point, 4)); 387 388 LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), globalTransform, 389 tileRect.width(), tileRect.height(), opacity, 390 program->vertexShader().matrixLocation(), 391 program->fragmentShader().alphaLocation()); 392 393 prevEdgeX = edgeX; 394 // Reverse direction. 395 prevEdgeX.scale(-1, -1, -1); 396 } 397 398 prevEdgeY = edgeY; 399 // Reverse direction. 400 prevEdgeY.scale(-1, -1, -1); 401 } 402 } 403 88 404 } 89 405 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h
r92245 r93424 27 27 #define CCTiledLayerImpl_h 28 28 29 #include "LayerTilerChromium.h" 29 #include "LayerTextureUpdater.h" 30 #include "TransformationMatrix.h" 30 31 #include "cc/CCLayerImpl.h" 32 #include "cc/CCLayerTilingData.h" 31 33 32 34 namespace WebCore { 35 36 class DrawableTile; 33 37 34 38 class CCTiledLayerImpl : public CCLayerImpl { … … 46 50 47 51 void setTilingTransform(const TransformationMatrix& tilingTransform) { m_tilingTransform = tilingTransform; } 48 void setTiler(LayerTilerChromium* tiler) { m_tiler = tiler; } 52 void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; } 53 void setTextureOrientation(LayerTextureUpdater::Orientation textureOrientation) { m_textureOrientation = textureOrientation; } 54 void setSampledTexelFormat(LayerTextureUpdater::SampledTexelFormat sampledTexelFormat) { m_sampledTexelFormat = sampledTexelFormat; } 55 void setTilingData(const CCLayerTilingData& tiler); 56 void syncTextureId(int, int, Platform3DObject textureId); 57 58 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> Program; 59 // Shader program that swaps red and blue components of texture. 60 // Used when texture format does not match native color format. 61 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexSwizzleAlpha> ProgramSwizzle; 62 63 // Shader program that produces anti-aliased layer edges. 64 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlphaAA> ProgramAA; 65 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexSwizzleAlphaAA> ProgramSwizzleAA; 49 66 50 67 private: 51 68 explicit CCTiledLayerImpl(int id); 52 69 70 // Draw all tiles that intersect with the content rect. 71 void draw(LayerRendererChromium*, const IntRect& contentRect, const TransformationMatrix&, float opacity); 72 73 DrawableTile* tileAt(int, int) const; 74 DrawableTile* createTile(int, int); 75 76 // Draw all tiles that intersect with contentRect. 77 template <class T> 78 void drawTiles(LayerRendererChromium*, const IntRect& contentRect, const TransformationMatrix&, float opacity, const T* program, int fragmentTexTransformLocation, int edgeLocation); 79 53 80 TransformationMatrix m_tilingTransform; 54 LayerTilerChromium* m_tiler; 81 bool m_skipsDraw; 82 LayerTextureUpdater::Orientation m_textureOrientation; 83 LayerTextureUpdater::SampledTexelFormat m_sampledTexelFormat; 84 85 OwnPtr<CCLayerTilingData> m_tiler; 55 86 }; 56 87 -
trunk/Source/WebCore/platform/graphics/gpu/TilingData.h
r92255 r93424 41 41 42 42 class TilingData { 43 WTF_MAKE_NONCOPYABLE(TilingData);44 43 public: 45 44 TilingData(int maxTextureSize, int totalSizeX, int totalSizeY, bool hasBorderTexels); -
trunk/Source/WebKit/chromium/ChangeLog
r93400 r93424 1 2011-08-17 Adrienne Walker <enne@google.com> 2 3 [chromium] Split tiler into main thread / compositor thread versions 4 https://bugs.webkit.org/show_bug.cgi?id=66065 5 6 Reviewed by James Robinson. 7 8 Add a test for assignment and copy constructor for TilingData. 9 10 * tests/TilingDataTest.cpp: 11 (WebCore::TEST): 12 1 13 2011-08-19 Andrey Kosyakov <caseq@chromium.org> 2 14 -
trunk/Source/WebKit/chromium/tests/TilingDataTest.cpp
r92255 r93424 489 489 } 490 490 491 TEST(TilingDataTest, assignment) 492 { 493 { 494 TilingData source(8, 16, 32, true); 495 TilingData dest = source; 496 EXPECT_EQ(source.borderTexels(), dest.borderTexels()); 497 EXPECT_EQ(source.maxTextureSize(), dest.maxTextureSize()); 498 EXPECT_EQ(source.numTilesX(), dest.numTilesX()); 499 EXPECT_EQ(source.numTilesY(), dest.numTilesY()); 500 EXPECT_EQ(source.totalSizeX(), dest.totalSizeX()); 501 EXPECT_EQ(source.totalSizeY(), dest.totalSizeY()); 502 } 503 { 504 TilingData source(3, 6, 100, false); 505 TilingData dest(source); 506 EXPECT_EQ(source.borderTexels(), dest.borderTexels()); 507 EXPECT_EQ(source.maxTextureSize(), dest.maxTextureSize()); 508 EXPECT_EQ(source.numTilesX(), dest.numTilesX()); 509 EXPECT_EQ(source.numTilesY(), dest.numTilesY()); 510 EXPECT_EQ(source.totalSizeX(), dest.totalSizeX()); 511 EXPECT_EQ(source.totalSizeY(), dest.totalSizeY()); 512 } 513 } 514 491 515 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.