Changeset 122160 in webkit
- Timestamp:
- Jul 9, 2012 3:31:25 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r122159 r122160 1 2012-07-09 Dana Jansens <danakj@chromium.org> 2 3 [chromium] Decouple RenderPass drawing from CCRenderSurface 4 https://bugs.webkit.org/show_bug.cgi?id=90573 5 6 Reviewed by Adrienne Walker. 7 8 Removes the managed textures from CCRenderSurface and stores them in a 9 HashMap in LayerRendererChromium. 10 11 At the start of a frame, all textures for the frame are reserved, and 12 unneeded textures are deleted. After each quad is drawn, evicted textures 13 (ie temporary textures used for background filters) are deleted to keep 14 within memory limits. At the end of the frame, all surface contents 15 textures are kept reserved and thus not deleted. 16 17 We add a numeric identifier to CCRenderPass which can be used to 18 identify the pass across serialization in the future, and is used 19 in the interface to LayerRendererChromium. Also we add to the 20 CCRenderPass a contentsChangedSinceLastFrame() flag so that the 21 value does not need to be retrieved from the CCRenderSurface. 22 23 The pointer from CCRenderPass to CCRenderSurface remains for some 24 code in the CCLayerTreeHostImpl, and will be addressed in the future, but 25 the pointer is no longer used at all while drawing a frame inside 26 LayerRendererChromium. 27 28 Covered by existing tests, no intended change in behaviour. 29 30 * platform/graphics/chromium/LayerRendererChromium.cpp: 31 (WebCore::LayerRendererChromium::releaseRenderPassTextures): 32 (WebCore::LayerRendererChromium::decideRenderPassAllocationsForFrame): 33 (WebCore): 34 (WebCore::LayerRendererChromium::haveCachedResourcesForRenderPassId): 35 (WebCore::LayerRendererChromium::drawQuad): 36 (WebCore::LayerRendererChromium::drawBackgroundFilters): 37 (WebCore::LayerRendererChromium::drawRenderPassQuad): 38 (WebCore::LayerRendererChromium::finishDrawingFrame): 39 (WebCore::LayerRendererChromium::useRenderPass): 40 (WebCore::LayerRendererChromium::initializeSharedObjects): 41 * platform/graphics/chromium/LayerRendererChromium.h: 42 (LayerRendererChromium): 43 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: 44 (WebCore::CCLayerTreeHostImpl::calculateRenderPasses): 45 (WebCore::CCLayerTreeHostImpl::removePassesWithCachedTextures): 46 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: 47 (CCLayerTreeHostImpl): 48 * platform/graphics/chromium/cc/CCRenderPass.cpp: 49 (WebCore::CCRenderPass::create): 50 (WebCore::CCRenderPass::CCRenderPass): 51 * platform/graphics/chromium/cc/CCRenderPass.h: 52 (CCRenderPass): 53 (WebCore::CCRenderPass::id): 54 (WebCore::CCRenderPass::setFramebufferOutputRect): 55 * platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp: 56 (WebCore::CCRenderPassDrawQuad::create): 57 (WebCore::CCRenderPassDrawQuad::CCRenderPassDrawQuad): 58 * platform/graphics/chromium/cc/CCRenderPassDrawQuad.h: 59 (CCRenderPassDrawQuad): 60 (WebCore::CCRenderPassDrawQuad::renderPassId): 61 (WebCore::CCRenderPassDrawQuad::contentsChangedSinceLastFrame): 62 * platform/graphics/chromium/cc/CCRenderSurface.cpp: 63 (WebCore::CCRenderSurface::appendQuads): 64 * platform/graphics/chromium/cc/CCRenderSurface.h: 65 (WebCore): 66 (CCRenderSurface): 67 * platform/graphics/chromium/cc/CCRenderer.h: 68 (CCRenderer): 69 * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: 70 (WebCore::CCTiledLayerImpl::pushTileProperties): 71 * platform/graphics/chromium/cc/CCTiledLayerImpl.h: 72 (CCTiledLayerImpl): 73 1 74 2012-07-09 Adam Klein <adamk@chromium.org> 2 75 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r121870 r122160 275 275 void LayerRendererChromium::releaseRenderPassTextures() 276 276 { 277 if (m_implTextureManager) 278 m_implTextureManager->evictAndDeleteAllTextures(m_implTextureAllocator.get()); 277 if (!m_implTextureManager) 278 return; 279 m_renderPassTextures.clear(); 280 m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get()); 279 281 } 280 282 … … 316 318 void LayerRendererChromium::decideRenderPassAllocationsForFrame(const CCRenderPassList& renderPassesInDrawOrder) 317 319 { 318 // FIXME: Get this memory limit from GPU Memory Manager 319 size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes(); 320 size_t maxLimitBytes = TextureManager::highLimitBytes(viewportSize()); 321 size_t memoryLimitBytes = maxLimitBytes - contentsMemoryUseBytes > 0u ? maxLimitBytes - contentsMemoryUseBytes : 0u; 322 323 m_implTextureManager->setMaxMemoryLimitBytes(memoryLimitBytes); 320 HashMap<int, const CCRenderPass*> passesInFrame; 321 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) 322 passesInFrame.set(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i].get()); 323 324 Vector<int> passesToDelete; 325 HashMap<int, OwnPtr<ManagedTexture> >::const_iterator passIterator; 326 for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) { 327 const CCRenderPass* renderPassInFrame = passesInFrame.get(passIterator->first); 328 if (!renderPassInFrame) { 329 passesToDelete.append(passIterator->first); 330 continue; 331 } 332 333 const IntSize& requiredSize = renderPassInFrame->framebufferOutputRect().size(); 334 GC3Denum requiredFormat = GraphicsContext3D::RGBA; 335 ManagedTexture* texture = passIterator->second.get(); 336 if (!texture || !texture->isValid(requiredSize, requiredFormat)) { 337 passesToDelete.append(passIterator->first); 338 continue; 339 } 340 } 341 342 // Delete RenderPass textures from the previous frame that will not be used again. 343 for (size_t i = 0; i < passesToDelete.size(); ++i) 344 m_renderPassTextures.remove(passesToDelete[i]); 345 m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get()); 346 347 // All RenderPass textures should be reserved for the current frame. Every RenderPass texture 348 // is kept reserved until it is removed and deleted. 349 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { 350 ManagedTexture* texture = m_renderPassTextures.get(renderPassesInDrawOrder[i]->id()); 351 if (!texture) { 352 OwnPtr<ManagedTexture> ownTexture = ManagedTexture::create(m_implTextureManager.get()); 353 texture = ownTexture.get(); 354 m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), ownTexture.release()); 355 } 356 357 const IntSize& requiredSize = renderPassesInDrawOrder[i]->framebufferOutputRect().size(); 358 GC3Denum requiredFormat = GraphicsContext3D::RGBA; 359 bool reserved = texture->reserve(requiredSize, requiredFormat); 360 ASSERT_UNUSED(reserved, reserved); 361 } 362 } 363 364 bool LayerRendererChromium::haveCachedResourcesForRenderPassId(int id) const 365 { 366 ManagedTexture* texture = m_renderPassTextures.get(id); 367 return texture && texture->textureId(); 324 368 } 325 369 … … 420 464 break; 421 465 } 466 467 m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get()); 422 468 } 423 469 … … 489 535 } 490 536 491 voidLayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)537 PassOwnPtr<ManagedTexture> LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform) 492 538 { 493 539 // This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background. … … 507 553 // FIXME: When this algorithm changes, update CCLayerTreeHost::prioritizeTextures() accordingly. 508 554 509 CCRenderSurface* drawingSurface = quad->renderPass()->targetSurface();510 555 if (quad->backgroundFilters().isEmpty()) 511 return ;556 return nullptr; 512 557 513 558 // FIXME: We only allow background filters on an opaque render surface because other surfaces may contain 514 559 // translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied. 515 560 if (m_currentRenderPass->hasTransparentBackground()) 516 return ;561 return nullptr; 517 562 ASSERT(!m_currentManagedTexture); 518 563 … … 529 574 OwnPtr<ManagedTexture> deviceBackgroundTexture = ManagedTexture::create(m_implTextureManager.get()); 530 575 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) 531 return ;576 return nullptr; 532 577 533 578 SkBitmap filteredDeviceBackground = applyFilters(this, quad->backgroundFilters(), deviceBackgroundTexture.get()); 534 579 if (!filteredDeviceBackground.getTexture()) 535 return ;580 return nullptr; 536 581 537 582 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.getTexture()); 538 583 int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); 539 584 540 if (!drawingSurface->prepareBackgroundTexture(this)) 541 return; 585 OwnPtr<ManagedTexture> backgroundTexture = ManagedTexture::create(m_implTextureManager.get()); 586 if (!backgroundTexture->reserve(quad->quadRect().size(), GraphicsContext3D::RGBA)) 587 return nullptr; 542 588 543 589 const CCRenderPass* targetRenderPass = m_currentRenderPass; 544 if (useManagedTexture(drawingSurface->backgroundTexture(), quad->quadRect())) { 590 bool usingBackgroundTexture = useManagedTexture(backgroundTexture.get(), quad->quadRect()); 591 592 if (usingBackgroundTexture) { 545 593 // Copy the readback pixels from device to the background texture for the surface. 546 594 WebTransformationMatrix deviceToFramebufferTransform; … … 552 600 553 601 copyTextureToFramebuffer(filteredDeviceBackgroundTextureId, deviceRect.size(), deviceToFramebufferTransform); 554 555 useRenderPass(targetRenderPass); 556 } 602 } 603 604 useRenderPass(targetRenderPass); 605 606 if (!usingBackgroundTexture) 607 return nullptr; 608 return backgroundTexture.release(); 557 609 } 558 610 559 611 void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad) 560 612 { 561 // The replica is always drawn first, so free after drawing the contents.562 bool shouldReleaseTextures = !quad->isReplica();563 564 CCRenderSurface* drawingSurface = quad->renderPass()->targetSurface();565 566 613 WebTransformationMatrix renderTransform = quad->layerTransform(); 567 614 // Apply a scaling factor to size the quad from 1x1 to its intended size. … … 570 617 571 618 // Can only draw surface if device matrix is invertible. 572 if (!contentsDeviceTransform.isInvertible() || !drawingSurface->hasValidContentsTexture()) { 573 if (shouldReleaseTextures) { 574 drawingSurface->releaseBackgroundTexture(); 575 drawingSurface->releaseContentsTexture(); 576 } 619 if (!contentsDeviceTransform.isInvertible()) 577 620 return; 578 } 579 580 drawBackgroundFilters(quad, contentsDeviceTransform); 621 622 ManagedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId()); 623 ASSERT(contentsTexture && contentsTexture->textureId()); 624 625 OwnPtr<ManagedTexture> backgroundTexture = drawBackgroundFilters(quad, contentsDeviceTransform); 581 626 582 627 // FIXME: Cache this value so that we don't have to do it for both the surface and its replica. 583 628 // Apply filters to the contents texture. 584 SkBitmap filterBitmap = applyFilters(this, quad->filters(), drawingSurface->contentsTexture());585 int contentsTextureId = drawingSurface->contentsTexture()->textureId();629 SkBitmap filterBitmap = applyFilters(this, quad->filters(), contentsTexture); 630 int contentsTextureId = contentsTexture->textureId(); 586 631 if (filterBitmap.getTexture()) { 587 632 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTexture()); … … 590 635 591 636 // Draw the background texture if there is one. 592 if (drawingSurface->hasValidBackgroundTexture()) 593 copyTextureToFramebuffer(drawingSurface->backgroundTexture()->textureId(), quad->quadRect().size(), quad->layerTransform()); 637 if (backgroundTexture) { 638 ASSERT(backgroundTexture->size() == quad->quadRect().size()); 639 copyTextureToFramebuffer(backgroundTexture->textureId(), quad->quadRect().size(), quad->layerTransform()); 640 } 594 641 595 642 bool clipped = false; … … 674 721 drawTexturedQuad(quad->layerTransform(), quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad, 675 722 shaderMatrixLocation, shaderAlphaLocation, shaderQuadLocation); 676 677 if (shouldReleaseTextures) {678 drawingSurface->releaseBackgroundTexture();679 drawingSurface->releaseContentsTexture();680 }681 723 } 682 724 … … 1080 1122 GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST)); 1081 1123 GLC(m_context, m_context->disable(GraphicsContext3D::BLEND)); 1082 1083 m_implTextureManager->unprotectAllTextures();1084 m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());1085 1124 } 1086 1125 … … 1340 1379 } 1341 1380 1342 if (!renderPass->targetSurface()->prepareContentsTexture(this))1343 return false;1344 1345 return bindFramebufferToTexture( renderPass->targetSurface()->contentsTexture(), renderPass->framebufferOutputRect());1381 ManagedTexture* texture = m_renderPassTextures.get(renderPass->id()); 1382 ASSERT(texture); 1383 1384 return bindFramebufferToTexture(texture, renderPass->framebufferOutputRect()); 1346 1385 } 1347 1386 … … 1432 1471 GLC(m_context, m_context->flush()); 1433 1472 1434 m_implTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()), 1435 TextureManager::reclaimLimitBytes(viewportSize()), 1436 m_capabilities.maxTextureSize); 1473 m_implTextureManager = TextureManager::create(std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max(), m_capabilities.maxTextureSize); 1437 1474 m_textureCopier = AcceleratedTextureCopier::create(m_context, m_isUsingBindUniform); 1438 1475 if (m_textureUploaderSetting == ThrottledUploader) -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r121823 r122160 81 81 82 82 virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) OVERRIDE; 83 virtual bool haveCachedResourcesForRenderPassId(int id) const OVERRIDE; 84 83 85 virtual void beginDrawingFrame(const CCRenderPass* defaultRenderPass) OVERRIDE; 84 86 virtual void drawRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect) OVERRIDE; … … 124 126 bool initialize(); 125 127 128 void releaseRenderPassTextures(); 129 126 130 private: 127 131 static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&); … … 130 134 void drawCheckerboardQuad(const CCCheckerboardDrawQuad*); 131 135 void drawDebugBorderQuad(const CCDebugBorderDrawQuad*); 132 voiddrawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);136 PassOwnPtr<ManagedTexture> drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform); 133 137 void drawRenderPassQuad(const CCRenderPassDrawQuad*); 134 138 void drawSolidColorQuad(const CCSolidColorDrawQuad*); … … 149 153 150 154 void clearRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect); 151 152 void releaseRenderPassTextures();153 155 154 156 bool makeContextCurrent(); … … 264 266 OwnPtr<TrackingTextureAllocator> m_implTextureAllocator; 265 267 268 HashMap<int, OwnPtr<ManagedTexture> > m_renderPassTextures; 269 266 270 WebKit::WebGraphicsContext3D* m_context; 267 271 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
r121583 r122160 86 86 { 87 87 ASSERT(CCProxy::isImplThread()); 88 ASSERT(m_layerId > =0);88 ASSERT(m_layerId > 0); 89 89 } 90 90 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
r121450 r122160 296 296 CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface(); 297 297 298 OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface); 298 // FIXME: Make this unique across all CCLayerTreeHostImpls. 299 int globalRenderPassId = renderSurfaceLayer->id(); 300 301 OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface, globalRenderPassId); 299 302 surfacePassMap.add(renderSurface, pass.get()); 300 303 frame.renderPasses.append(pass.release()); … … 352 355 353 356 m_layerRenderer->decideRenderPassAllocationsForFrame(frame.renderPasses); 354 removePassesWithCachedTextures(frame.renderPasses, frame.skippedPasses );357 removePassesWithCachedTextures(frame.renderPasses, frame.skippedPasses, m_layerRenderer.get()); 355 358 356 359 return drawFrame; … … 432 435 } 433 436 434 void CCLayerTreeHostImpl::removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses )437 void CCLayerTreeHostImpl::removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses, const CCRenderer* renderer) 435 438 { 436 439 for (int passIndex = passes.size() - 1; passIndex >= 0; --passIndex) { … … 446 449 447 450 CCRenderPassDrawQuad* renderPassQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad); 448 CCRenderSurface* targetSurface = renderPassQuad->renderPass()->targetSurface(); 449 450 if (targetSurface->contentsChanged() || !targetSurface->hasCachedContentsTexture()) 451 if (!renderPassQuad->contentsChangedSinceLastFrame().isEmpty()) 451 452 continue; 452 453 // Reserve the texture immediately. We do not need to pass in layer renderer 454 // since the texture already exists, just needs to be reserved. 455 if (!targetSurface->prepareContentsTexture(0)) 453 if (!renderer->haveCachedResourcesForRenderPassId(renderPassQuad->renderPassId())) 456 454 continue; 457 455 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
r121396 r122160 179 179 180 180 // Removes all render passes for which we have cached textures, and which did not change their content. 181 static void removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses );181 static void removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses, const CCRenderer*); 182 182 183 183 protected: -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp
r121583 r122160 38 38 namespace WebCore { 39 39 40 PassOwnPtr<CCRenderPass> CCRenderPass::create(CCRenderSurface* targetSurface )40 PassOwnPtr<CCRenderPass> CCRenderPass::create(CCRenderSurface* targetSurface, int id) 41 41 { 42 return adoptPtr(new CCRenderPass(targetSurface ));42 return adoptPtr(new CCRenderPass(targetSurface, id)); 43 43 } 44 44 45 CCRenderPass::CCRenderPass(CCRenderSurface* targetSurface) 46 : m_targetSurface(targetSurface) 45 CCRenderPass::CCRenderPass(CCRenderSurface* targetSurface, int id) 46 : m_id(id) 47 , m_targetSurface(targetSurface) 47 48 , m_framebufferOutputRect(targetSurface->contentRect()) 48 49 , m_hasTransparentBackground(true) 49 50 { 50 ASSERT(m_targetSurface); 51 ASSERT(targetSurface); 52 ASSERT(id > 0); 51 53 } 52 54 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h
r121396 r122160 54 54 WTF_MAKE_NONCOPYABLE(CCRenderPass); 55 55 public: 56 static PassOwnPtr<CCRenderPass> create(CCRenderSurface* );56 static PassOwnPtr<CCRenderPass> create(CCRenderSurface*, int id); 57 57 58 58 void appendQuadsForLayer(CCLayerImpl*, CCOcclusionTrackerImpl*, bool& hadMissingTiles); … … 61 61 62 62 const CCQuadList& quadList() const { return m_quadList; } 63 64 int id() const { return m_id; } 63 65 CCRenderSurface* targetSurface() const { return m_targetSurface; } 66 64 67 // This denotes the bounds in physical pixels of the output generated by this RenderPass. 65 68 const IntRect& framebufferOutputRect() const { return m_framebufferOutputRect; } … … 69 72 70 73 protected: 71 explicit CCRenderPass(CCRenderSurface*);74 CCRenderPass(CCRenderSurface*, int id); 72 75 76 int m_id; 73 77 CCRenderSurface* m_targetSurface; 74 78 CCQuadList m_quadList; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp
r119419 r122160 28 28 #include "cc/CCRenderPassDrawQuad.h" 29 29 30 #include "cc/CCRenderPass.h" 31 30 32 namespace WebCore { 31 33 32 PassOwnPtr<CCRenderPassDrawQuad> CCRenderPassDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId )34 PassOwnPtr<CCRenderPassDrawQuad> CCRenderPassDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame) 33 35 { 34 return adoptPtr(new CCRenderPassDrawQuad(sharedQuadState, quadRect, renderPass, isReplica, filters, backgroundFilters, maskTextureId ));36 return adoptPtr(new CCRenderPassDrawQuad(sharedQuadState, quadRect, renderPass, isReplica, filters, backgroundFilters, maskTextureId, contentsChangedSinceLastFrame)); 35 37 } 36 38 37 CCRenderPassDrawQuad::CCRenderPassDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId )39 CCRenderPassDrawQuad::CCRenderPassDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame) 38 40 : CCDrawQuad(sharedQuadState, CCDrawQuad::RenderPass, quadRect) 39 41 , m_renderPass(renderPass) 42 , m_renderPassId(renderPass->id()) 40 43 , m_isReplica(isReplica) 41 44 , m_filters(filters) 42 45 , m_backgroundFilters(backgroundFilters) 43 46 , m_maskTextureId(maskTextureId) 47 , m_contentsChangedSinceLastFrame(contentsChangedSinceLastFrame) 44 48 { 45 49 ASSERT(m_renderPass); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.h
r119419 r122160 38 38 WTF_MAKE_NONCOPYABLE(CCRenderPassDrawQuad); 39 39 public: 40 static PassOwnPtr<CCRenderPassDrawQuad> create(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId );40 static PassOwnPtr<CCRenderPassDrawQuad> create(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame); 41 41 42 42 const CCRenderPass* renderPass() const { return m_renderPass; } 43 int renderPassId() const { return m_renderPassId; } 43 44 bool isReplica() const { return m_isReplica; } 44 45 unsigned maskTextureId() const { return m_maskTextureId; } 46 const IntRect& contentsChangedSinceLastFrame() const { return m_contentsChangedSinceLastFrame; } 45 47 46 48 const WebKit::WebFilterOperations& filters() const { return m_filters; } … … 48 50 49 51 private: 50 CCRenderPassDrawQuad(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId );52 CCRenderPassDrawQuad(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame); 51 53 52 54 const CCRenderPass* m_renderPass; 55 int m_renderPassId; 53 56 bool m_isReplica; 54 57 WebKit::WebFilterOperations m_filters; 55 58 WebKit::WebFilterOperations m_backgroundFilters; 56 59 unsigned m_maskTextureId; 60 IntRect m_contentsChangedSinceLastFrame; 57 61 }; 58 62 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp
r121583 r122160 32 32 #include "GraphicsContext3D.h" 33 33 #include "LayerRendererChromium.h" 34 #include "ManagedTexture.h"35 34 #include "TextStream.h" 36 35 #include "cc/CCDamageTracker.h" … … 86 85 } 87 86 88 bool CCRenderSurface::prepareContentsTexture(LayerRendererChromium* layerRenderer)89 {90 // FIXME: This method should be separated into two: one to reserve an91 // existing surface, and one to create a new one. That way we will not92 // need to pass null layerRenderer.93 if (layerRenderer) {94 TextureManager* textureManager = layerRenderer->implTextureManager();95 96 if (!m_contentsTexture)97 m_contentsTexture = ManagedTexture::create(textureManager);98 }99 100 if (!m_contentsTexture)101 return false;102 103 if (m_contentsTexture->isReserved())104 return true;105 106 if (!m_contentsTexture->reserve(m_contentRect.size(), GraphicsContext3D::RGBA))107 return false;108 109 return true;110 }111 112 void CCRenderSurface::releaseContentsTexture()113 {114 if (!m_contentsTexture || !m_contentsTexture->isReserved())115 return;116 m_contentsTexture->unreserve();117 }118 119 bool CCRenderSurface::hasValidContentsTexture() const120 {121 return m_contentsTexture && m_contentsTexture->isReserved() && m_contentsTexture->isValid(m_contentRect.size(), GraphicsContext3D::RGBA);122 }123 124 bool CCRenderSurface::hasCachedContentsTexture() const125 {126 return m_contentsTexture && m_contentsTexture->isValid(m_contentRect.size(), GraphicsContext3D::RGBA);127 }128 129 bool CCRenderSurface::prepareBackgroundTexture(LayerRendererChromium* layerRenderer)130 {131 TextureManager* textureManager = layerRenderer->implTextureManager();132 133 if (!m_backgroundTexture)134 m_backgroundTexture = ManagedTexture::create(textureManager);135 136 if (m_backgroundTexture->isReserved())137 return true;138 139 if (!m_backgroundTexture->reserve(m_contentRect.size(), GraphicsContext3D::RGBA))140 return false;141 142 return true;143 }144 145 void CCRenderSurface::releaseBackgroundTexture()146 {147 if (!m_backgroundTexture || !m_backgroundTexture->isReserved())148 return;149 m_backgroundTexture->unreserve();150 }151 152 bool CCRenderSurface::hasValidBackgroundTexture() const153 {154 return m_backgroundTexture && m_backgroundTexture->isReserved() && m_backgroundTexture->isValid(m_contentRect.size(), GraphicsContext3D::RGBA);155 }156 157 87 String CCRenderSurface::name() const 158 88 { … … 303 233 304 234 int maskTextureId = maskLayer ? maskLayer->contentsTextureId() : 0; 305 306 quadList.appendSurface(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPass, forReplica, filters(), backgroundFilters(), maskTextureId)); 235 IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : IntRect(); 236 237 quadList.appendSurface(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPass, forReplica, filters(), backgroundFilters(), maskTextureId, contentsChangedSinceLastFrame)); 307 238 } 308 239 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h
r121458 r122160 32 32 #include "FloatRect.h" 33 33 #include "IntRect.h" 34 #include "TextureManager.h"35 34 #include <public/WebFilterOperations.h> 36 35 #include <public/WebTransformationMatrix.h> … … 46 45 class CCLayerImpl; 47 46 class LayerRendererChromium; 48 class ManagedTexture;49 47 class TextStream; 50 48 … … 54 52 explicit CCRenderSurface(CCLayerImpl*); 55 53 virtual ~CCRenderSurface(); 56 57 virtual bool prepareContentsTexture(LayerRendererChromium*);58 void releaseContentsTexture();59 bool hasValidContentsTexture() const;60 virtual bool hasCachedContentsTexture() const;61 62 bool prepareBackgroundTexture(LayerRendererChromium*);63 void releaseBackgroundTexture();64 bool hasValidBackgroundTexture() const;65 54 66 55 String name() const; … … 117 106 const IntRect& scissorRect() const { return m_scissorRect; } 118 107 119 virtualbool contentsChanged() const;108 bool contentsChanged() const; 120 109 121 110 void setContentRect(const IntRect&); … … 124 113 void clearLayerList() { m_layerList.clear(); } 125 114 Vector<CCLayerImpl*>& layerList() { return m_layerList; } 126 127 ManagedTexture* contentsTexture() const { return m_contentsTexture.get(); }128 ManagedTexture* backgroundTexture() const { return m_backgroundTexture.get(); }129 115 130 116 int owningLayerId() const; … … 155 141 IntRect m_contentRect; 156 142 bool m_surfacePropertyChanged; 157 158 OwnPtr<ManagedTexture> m_contentsTexture;159 OwnPtr<ManagedTexture> m_backgroundTexture;160 143 161 144 float m_drawOpacity; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h
r121076 r122160 73 73 74 74 virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) = 0; 75 virtual bool haveCachedResourcesForRenderPassId(int) const = 0; 76 75 77 virtual void beginDrawingFrame(const CCRenderPass* defaultRenderPass) = 0; 76 78 virtual void drawRenderPass(const CCRenderPass*, const FloatRect& rootScissorRectInCurrentPass) = 0; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r121396 r122160 30 30 #include "cc/CCTiledLayerImpl.h" 31 31 32 #include "GraphicsContext3D.h" 32 33 #include "SkColor.h" 33 34 #include "TextStream.h" … … 221 222 } 222 223 223 void CCTiledLayerImpl::pushTileProperties(int i, int j, Platform3DObjecttextureId, const IntRect& opaqueRect)224 void CCTiledLayerImpl::pushTileProperties(int i, int j, unsigned textureId, const IntRect& opaqueRect) 224 225 { 225 226 DrawableTile* tile = tileAt(i, j); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h
r120820 r122160 51 51 void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; } 52 52 void setTilingData(const CCLayerTilingData& tiler); 53 void pushTileProperties(int, int, Platform3DObjecttextureId, const IntRect& opaqueRect);53 void pushTileProperties(int, int, unsigned textureId, const IntRect& opaqueRect); 54 54 55 55 void setContentsSwizzled(bool contentsSwizzled) { m_contentsSwizzled = contentsSwizzled; } -
trunk/Source/WebKit/chromium/ChangeLog
r122159 r122160 1 2012-07-09 Dana Jansens <danakj@chromium.org> 2 3 [chromium] Decouple RenderPass drawing from CCRenderSurface 4 https://bugs.webkit.org/show_bug.cgi?id=90573 5 6 Reviewed by Adrienne Walker. 7 8 * tests/CCLayerTreeHostImplTest.cpp: 9 * tests/LayerRendererChromiumTest.cpp: 10 (FakeCCRendererClient::FakeCCRendererClient): 11 1 12 2012-07-09 Adam Klein <adamk@chromium.org> 2 13 -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
r121450 r122160 128 128 void setupScrollAndContentsLayers(const IntSize& contentSize) 129 129 { 130 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);130 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 131 131 root->setScrollable(true); 132 132 root->setScrollPosition(IntPoint(0, 0)); 133 133 root->setMaxScrollPosition(contentSize); 134 OwnPtr<CCLayerImpl> contents = CCLayerImpl::create( 1);134 OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(2); 135 135 contents->setDrawsContent(true); 136 136 contents->setBounds(contentSize); … … 187 187 { 188 188 { 189 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); 190 root->addChild(CCLayerImpl::create(1)); 189 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 191 190 root->addChild(CCLayerImpl::create(2)); 192 root-> children()[1]->addChild(CCLayerImpl::create(3));191 root->addChild(CCLayerImpl::create(3)); 193 192 root->children()[1]->addChild(CCLayerImpl::create(4)); 194 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(5)); 193 root->children()[1]->addChild(CCLayerImpl::create(5)); 194 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); 195 195 m_hostImpl->setRootLayer(root.release()); 196 196 } … … 215 215 IntSize scrollDelta(11, -15); 216 216 { 217 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1 0);217 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 218 218 root->setScrollPosition(scrollPosition); 219 219 root->setScrollable(true); … … 264 264 TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling) 265 265 { 266 const int scrollLayerId = 0;266 const int scrollLayerId = 1; 267 267 268 268 setupScrollAndContentsLayers(IntSize(100, 100)); … … 626 626 setDrawsContent(true); 627 627 setSkipsDraw(false); 628 setVisibleLayerRect(IntRect(0, 0, 10, 10)); 628 629 629 630 OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::HasBorderTexels); 631 tiler->setBounds(contentBounds()); 630 632 setTilingData(*tiler.get()); 631 633 } … … 640 642 // The root layer is always drawn, so run this test on a child layer that 641 643 // will be masked out by the root layer's bounds. 642 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));644 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 643 645 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 644 646 root->setMasksToBounds(true); 645 647 646 root->addChild(DidDrawCheckLayer::create( 1));648 root->addChild(DidDrawCheckLayer::create(2)); 647 649 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 648 650 // Ensure visibleLayerRect for layer is empty … … 687 689 m_hostImpl->setViewportSize(bigSize); 688 690 689 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));691 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 690 692 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 691 693 692 root->addChild(DidDrawCheckLayer::create( 1));694 root->addChild(DidDrawCheckLayer::create(2)); 693 695 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 694 696 695 root->addChild(DidDrawCheckLayer::create( 2));697 root->addChild(DidDrawCheckLayer::create(3)); 696 698 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children()[1].get()); 697 699 // This layer covers the occludedLayer above. Make this layer large so it can occlude. … … 719 721 TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) 720 722 { 721 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));723 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 722 724 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 723 725 724 root->addChild(DidDrawCheckLayer::create( 1));726 root->addChild(DidDrawCheckLayer::create(2)); 725 727 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 726 728 727 layer1->addChild(DidDrawCheckLayer::create( 2));729 layer1->addChild(DidDrawCheckLayer::create(3)); 728 730 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children()[0].get()); 729 731 … … 770 772 { 771 773 // When the texture is not missing, we draw as usual. 772 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));774 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 773 775 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 774 root->addChild(MissingTextureAnimatingLayer::create( 1, false, false, true));776 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true)); 775 777 776 778 CCLayerTreeHostImpl::FrameData frame; … … 781 783 782 784 // When a texture is missing and we're not animating, we draw as usual with checkerboarding. 783 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));785 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 784 786 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 785 root->addChild(MissingTextureAnimatingLayer::create( 1, true, false, false));787 root->addChild(MissingTextureAnimatingLayer::create(2, true, false, false)); 786 788 787 789 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); … … 790 792 791 793 // When a texture is missing and we're animating, we don't want to draw anything. 792 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));794 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 793 795 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 794 root->addChild(MissingTextureAnimatingLayer::create( 1, true, false, true));796 root->addChild(MissingTextureAnimatingLayer::create(2, true, false, true)); 795 797 796 798 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); … … 799 801 800 802 // When the layer skips draw and we're animating, we still draw the frame. 801 m_hostImpl->setRootLayer(DidDrawCheckLayer::create( 0));803 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 802 804 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 803 root->addChild(MissingTextureAnimatingLayer::create( 1, false, true, true));805 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true)); 804 806 805 807 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); … … 810 812 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored) 811 813 { 812 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);814 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 813 815 root->setScrollable(false); 814 816 m_hostImpl->setRootLayer(root.release()); … … 834 836 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize.height() * 2)); 835 837 836 OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create( 0);838 OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2); 837 839 scrollLayer->setScrollable(true); 838 840 scrollLayer->setMaxScrollPosition(surfaceSize); … … 853 855 { 854 856 IntSize surfaceSize(10, 10); 855 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);856 root->addChild(createScrollableLayer( 1, FloatPoint(5, 5), surfaceSize));857 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 858 root->addChild(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize)); 857 859 m_hostImpl->setRootLayer(root.release()); 858 860 m_hostImpl->setViewportSize(surfaceSize); … … 869 871 { 870 872 IntSize surfaceSize(10, 10); 871 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);872 root->addChild(createScrollableLayer( 1, FloatPoint(5, 5), surfaceSize));873 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 874 root->addChild(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize)); 873 875 m_hostImpl->setRootLayer(root.release()); 874 876 m_hostImpl->setViewportSize(surfaceSize); … … 884 886 { 885 887 IntSize surfaceSize(10, 10); 886 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);887 OwnPtr<CCLayerImpl> child = createScrollableLayer( 1, FloatPoint(5, 5), surfaceSize);888 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 889 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); 888 890 m_hostImpl->setViewportSize(surfaceSize); 889 891 … … 907 909 { 908 910 IntSize surfaceSize(10, 10); 909 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize);911 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); 910 912 contentLayer->setShouldScrollOnMainThread(true); 911 913 contentLayer->setScrollable(false); 912 914 913 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer( 1, FloatPoint(5, 5), surfaceSize);915 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); 914 916 scrollLayer->addChild(contentLayer.release()); 915 917 … … 926 928 IntSize surfaceSize(10, 10); 927 929 float pageScale = 2; 928 OwnPtr<CCLayerImpl> root = createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize);930 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); 929 931 m_hostImpl->setRootLayer(root.release()); 930 932 m_hostImpl->setViewportSize(surfaceSize); … … 944 946 expectedScrollDelta.scale(pageScale); 945 947 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 946 expectContains(*scrollInfo.get(), 0, expectedScrollDelta);948 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta); 947 949 948 950 // The scroll range should also have been updated. … … 957 959 IntSize surfaceSize(10, 10); 958 960 float pageScale = 2; 959 OwnPtr<CCLayerImpl> root = createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize);961 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); 960 962 m_hostImpl->setRootLayer(root.release()); 961 963 m_hostImpl->setViewportSize(surfaceSize); … … 977 979 // The scroll delta is not scaled because the main thread did not scale. 978 980 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 979 expectContains(*scrollInfo.get(), 0, expectedScrollDelta);981 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta); 980 982 981 983 // The scroll range should also have been updated. … … 989 991 { 990 992 IntSize surfaceSize(10, 10); 991 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);993 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 992 994 // Also mark the root scrollable so it becomes the root scroll layer. 993 995 root->setScrollable(true); 994 root->addChild(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize)); 996 int scrollLayerId = 2; 997 root->addChild(createScrollableLayer(scrollLayerId, FloatPoint(5, 5), surfaceSize)); 995 998 m_hostImpl->setRootLayer(root.release()); 996 999 m_hostImpl->setViewportSize(surfaceSize); … … 1012 1015 expectedScrollDelta.scale(pageScale); 1013 1016 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1014 expectContains(*scrollInfo.get(), 1, expectedScrollDelta);1017 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1015 1018 1016 1019 // The scroll range should not have changed. … … 1027 1030 // scroll. 1028 1031 IntSize surfaceSize(10, 10); 1029 OwnPtr<CCLayerImpl> root = createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize);1030 1031 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer( 2, FloatPoint(5, 5), surfaceSize);1032 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); 1033 1034 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, FloatPoint(5, 5), surfaceSize); 1032 1035 grandChild->setScrollPosition(IntPoint(0, 5)); 1033 1036 1034 OwnPtr<CCLayerImpl> child = createScrollableLayer( 1, FloatPoint(5, 5), surfaceSize);1037 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); 1035 1038 child->setScrollPosition(IntPoint(3, 0)); 1036 1039 child->addChild(grandChild.release()); … … 1063 1066 // should be applied to one of its ancestors if possible. 1064 1067 IntSize surfaceSize(10, 10); 1065 OwnPtr<CCLayerImpl> root = createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize);1066 OwnPtr<CCLayerImpl> child = createScrollableLayer( 1, FloatPoint(5, 5), surfaceSize);1068 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); 1069 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); 1067 1070 1068 1071 child->setScrollable(false); … … 1089 1092 { 1090 1093 IntSize surfaceSize(10, 10); 1091 m_hostImpl->setRootLayer(createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize));1094 m_hostImpl->setRootLayer(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize)); 1092 1095 m_hostImpl->setViewportSize(surfaceSize); 1093 1096 … … 1095 1098 initializeLayerRendererAndDrawFrame(); 1096 1099 m_hostImpl->detachLayerTree(); 1097 m_hostImpl->setRootLayer(createScrollableLayer( 0, FloatPoint(5, 5), surfaceSize));1100 m_hostImpl->setRootLayer(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize)); 1098 1101 1099 1102 // Scrolling should still work even though we did not draw yet. … … 1187 1190 1188 1191 { 1189 OwnPtr<CCLayerImpl> root = CCLayerImpl::create( 0);1192 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 1190 1193 root->setAnchorPoint(FloatPoint(0, 0)); 1191 1194 root->setBounds(IntSize(10, 10)); … … 1196 1199 CCLayerImpl* root = m_hostImpl->rootLayer(); 1197 1200 1198 root->addChild(BlendStateCheckLayer::create( 1));1201 root->addChild(BlendStateCheckLayer::create(2)); 1199 1202 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->children()[0].get()); 1200 1203 … … 1248 1251 m_hostImpl->didDrawAllLayers(frame); 1249 1252 1250 layer1->addChild(BlendStateCheckLayer::create( 2));1253 layer1->addChild(BlendStateCheckLayer::create(3)); 1251 1254 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->children()[0].get()); 1252 1255 … … 1408 1411 m_hostImpl->setViewportSize(viewportSize); 1409 1412 1410 m_hostImpl->setRootLayer(BlendStateCheckLayer::create( 0));1413 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1)); 1411 1414 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->rootLayer()); 1412 1415 root->setExpectation(false, true); … … 1998 2001 TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers) 1999 2002 { 2000 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create( 0));2003 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); 2001 2004 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificationCheckLayer*>(m_hostImpl->rootLayer()); 2002 2005 … … 2201 2204 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) 2202 2205 { 2203 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(0));2204 rootLayer->setBounds(IntSize(10, 10));2205 rootLayer->setAnchorPoint(FloatPoint(0, 0));2206 2207 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(1);2208 tileLayer->setBounds(IntSize(10, 10));2209 tileLayer->setAnchorPoint(FloatPoint(0, 0));2210 tileLayer->setContentBounds(IntSize(10, 10));2211 tileLayer->setDrawsContent(true);2212 tileLayer->setSkipsDraw(false);2213 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 10), CCLayerTilingData::NoBorderTexels));2214 tilingData->setBounds(IntSize(10, 10));2215 tileLayer->setTilingData(*tilingData);2216 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10));2217 rootLayer->addChild(tileLayer.release());2218 2219 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(2);2220 textureLayer->setBounds(IntSize(10, 10));2221 textureLayer->setAnchorPoint(FloatPoint(0, 0));2222 textureLayer->setContentBounds(IntSize(10, 10));2223 textureLayer->setDrawsContent(true);2224 textureLayer->setTextureId(1);2225 rootLayer->addChild(textureLayer.release());2226 2227 FakeVideoFrameProvider provider;2228 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(3, &provider);2229 videoLayer->setBounds(IntSize(10, 10));2230 videoLayer->setAnchorPoint(FloatPoint(0, 0));2231 videoLayer->setContentBounds(IntSize(10, 10));2232 videoLayer->setDrawsContent(true);2233 videoLayer->setLayerTreeHostImpl(m_hostImpl.get());2234 rootLayer->addChild(videoLayer.release());2235 2236 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(4);2237 ioSurfaceLayer->setBounds(IntSize(10, 10));2238 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0));2239 ioSurfaceLayer->setContentBounds(IntSize(10, 10));2240 ioSurfaceLayer->setDrawsContent(true);2241 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10));2242 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());2243 rootLayer->addChild(ioSurfaceLayer.release());2244 2245 // Use a context that supports IOSurfaces2246 m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);2247 2248 m_hostImpl->setRootLayer(rootLayer.release());2249 2250 CCLayerTreeHostImpl::FrameData frame;2251 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));2252 m_hostImpl->drawLayers(frame);2253 m_hostImpl->didDrawAllLayers(frame);2254 m_hostImpl->swapBuffers();2255 2256 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface,2257 // that will warn if any resource from the previous context gets used.2258 m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);2259 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));2260 m_hostImpl->drawLayers(frame);2261 m_hostImpl->didDrawAllLayers(frame);2262 m_hostImpl->swapBuffers();2263 }2264 2265 // Fake WebGraphicsContext3D that tracks the number of textures in use.2266 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D {2267 public:2268 TrackingWebGraphicsContext3D()2269 : FakeWebGraphicsContext3D()2270 , m_numTextures(0)2271 { }2272 2273 virtual WebGLId createTexture() OVERRIDE2274 {2275 WebGLId id = FakeWebGraphicsContext3D::createTexture();2276 2277 m_textures.set(id, true);2278 ++m_numTextures;2279 return id;2280 }2281 2282 virtual void deleteTexture(WebGLId id) OVERRIDE2283 {2284 if (!m_textures.get(id))2285 return;2286 2287 m_textures.set(id, false);2288 --m_numTextures;2289 }2290 2291 virtual WebString getString(WGC3Denum name) OVERRIDE2292 {2293 if (name == WebCore::GraphicsContext3D::EXTENSIONS)2294 return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle");2295 2296 return WebString();2297 }2298 2299 unsigned numTextures() const { return m_numTextures; }2300 2301 private:2302 HashMap<WebGLId, bool> m_textures;2303 unsigned m_numTextures;2304 };2305 2306 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)2307 {2308 2206 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); 2309 2207 rootLayer->setBounds(IntSize(10, 10)); … … 2348 2246 rootLayer->addChild(ioSurfaceLayer.release()); 2349 2247 2248 // Use a context that supports IOSurfaces 2249 m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader); 2250 2251 m_hostImpl->setRootLayer(rootLayer.release()); 2252 2253 CCLayerTreeHostImpl::FrameData frame; 2254 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2255 m_hostImpl->drawLayers(frame); 2256 m_hostImpl->didDrawAllLayers(frame); 2257 m_hostImpl->swapBuffers(); 2258 2259 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface, 2260 // that will warn if any resource from the previous context gets used. 2261 m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader); 2262 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2263 m_hostImpl->drawLayers(frame); 2264 m_hostImpl->didDrawAllLayers(frame); 2265 m_hostImpl->swapBuffers(); 2266 } 2267 2268 // Fake WebGraphicsContext3D that tracks the number of textures in use. 2269 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D { 2270 public: 2271 TrackingWebGraphicsContext3D() 2272 : FakeWebGraphicsContext3D() 2273 , m_numTextures(0) 2274 { } 2275 2276 virtual WebGLId createTexture() OVERRIDE 2277 { 2278 WebGLId id = FakeWebGraphicsContext3D::createTexture(); 2279 2280 m_textures.set(id, true); 2281 ++m_numTextures; 2282 return id; 2283 } 2284 2285 virtual void deleteTexture(WebGLId id) OVERRIDE 2286 { 2287 if (!m_textures.get(id)) 2288 return; 2289 2290 m_textures.set(id, false); 2291 --m_numTextures; 2292 } 2293 2294 virtual WebString getString(WGC3Denum name) OVERRIDE 2295 { 2296 if (name == WebCore::GraphicsContext3D::EXTENSIONS) 2297 return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"); 2298 2299 return WebString(); 2300 } 2301 2302 unsigned numTextures() const { return m_numTextures; } 2303 2304 private: 2305 HashMap<WebGLId, bool> m_textures; 2306 unsigned m_numTextures; 2307 }; 2308 2309 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) 2310 { 2311 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); 2312 rootLayer->setBounds(IntSize(10, 10)); 2313 rootLayer->setAnchorPoint(FloatPoint(0, 0)); 2314 2315 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); 2316 tileLayer->setBounds(IntSize(10, 10)); 2317 tileLayer->setAnchorPoint(FloatPoint(0, 0)); 2318 tileLayer->setContentBounds(IntSize(10, 10)); 2319 tileLayer->setDrawsContent(true); 2320 tileLayer->setSkipsDraw(false); 2321 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 10), CCLayerTilingData::NoBorderTexels)); 2322 tilingData->setBounds(IntSize(10, 10)); 2323 tileLayer->setTilingData(*tilingData); 2324 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); 2325 rootLayer->addChild(tileLayer.release()); 2326 2327 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3); 2328 textureLayer->setBounds(IntSize(10, 10)); 2329 textureLayer->setAnchorPoint(FloatPoint(0, 0)); 2330 textureLayer->setContentBounds(IntSize(10, 10)); 2331 textureLayer->setDrawsContent(true); 2332 textureLayer->setTextureId(1); 2333 rootLayer->addChild(textureLayer.release()); 2334 2335 FakeVideoFrameProvider provider; 2336 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provider); 2337 videoLayer->setBounds(IntSize(10, 10)); 2338 videoLayer->setAnchorPoint(FloatPoint(0, 0)); 2339 videoLayer->setContentBounds(IntSize(10, 10)); 2340 videoLayer->setDrawsContent(true); 2341 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2342 rootLayer->addChild(videoLayer.release()); 2343 2344 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(5); 2345 ioSurfaceLayer->setBounds(IntSize(10, 10)); 2346 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); 2347 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); 2348 ioSurfaceLayer->setDrawsContent(true); 2349 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); 2350 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2351 rootLayer->addChild(ioSurfaceLayer.release()); 2352 2350 2353 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of). 2351 2354 OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new TrackingWebGraphicsContext3D))); … … 2466 2469 } 2467 2470 2471 class LayerRendererChromiumWithReleaseTextures : public LayerRendererChromium { 2472 public: 2473 using LayerRendererChromium::releaseRenderPassTextures; 2474 }; 2475 2468 2476 TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching) 2469 2477 { … … 2549 2557 } 2550 2558 2551 // Change opacity again, but evict the cached surface texture2559 // Change opacity again, and evict the cached surface texture. 2552 2560 surfaceLayerPtr->setOpacity(0.5f); 2553 ManagedTexture* contentsTexture = surfaceLayerPtr->renderSurface()->contentsTexture(); 2554 ASSERT_TRUE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format())); 2555 CCRenderer* renderer = myHostImpl->layerRenderer(); 2556 TextureManager* textureManager = renderer->implTextureManager(); 2557 size_t maxMemoryLimit = textureManager->maxMemoryLimitBytes(); 2558 2559 // This should evice all cached surfaces 2560 textureManager->setMaxMemoryLimitBytes(0); 2561 2562 // Restore original limit 2563 textureManager->setMaxMemoryLimitBytes(maxMemoryLimit); 2564 2565 // Was our surface evicted? 2566 ASSERT_FALSE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format())); 2561 static_cast<LayerRendererChromiumWithReleaseTextures*>(myHostImpl->layerRenderer())->releaseRenderPassTextures(); 2567 2562 2568 2563 // Change opacity and draw … … 2583 2578 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get()); 2584 2579 EXPECT_FALSE(quad->renderPass()->targetSurface()->contentsChanged()); 2580 2581 // Was our surface evicted? 2582 EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(quad->renderPass()->id())); 2585 2583 2586 2584 myHostImpl->drawLayers(frame); … … 2707 2705 } 2708 2706 2709 // Change opacity again, but evict the cached surface texture2707 // Change opacity again, and evict the cached surface texture. 2710 2708 surfaceLayerPtr->setOpacity(0.5f); 2711 ManagedTexture* contentsTexture = surfaceLayerPtr->renderSurface()->contentsTexture(); 2712 ASSERT_TRUE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format())); 2713 CCRenderer* renderer = myHostImpl->layerRenderer(); 2714 TextureManager* textureManager = renderer->implTextureManager(); 2715 size_t maxMemoryLimit = textureManager->maxMemoryLimitBytes(); 2716 2717 // This should evice all cached surfaces 2718 textureManager->setMaxMemoryLimitBytes(0); 2719 2720 // Restore original limit 2721 textureManager->setMaxMemoryLimitBytes(maxMemoryLimit); 2722 2723 // Was our surface evicted? 2724 ASSERT_FALSE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format())); 2709 static_cast<LayerRendererChromiumWithReleaseTextures*>(myHostImpl->layerRenderer())->releaseRenderPassTextures(); 2725 2710 2726 2711 // Change opacity and draw … … 2741 2726 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get()); 2742 2727 EXPECT_FALSE(quad->renderPass()->targetSurface()->contentsChanged()); 2728 2729 // Was our surface evicted? 2730 EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(quad->renderPass()->id())); 2743 2731 2744 2732 myHostImpl->drawLayers(frame); … … 2899 2887 }; 2900 2888 2901 class FakeRenderSurface : public CCRenderSurface {2902 private:2903 bool m_hasCachedTexture;2904 bool m_contentsChanged;2905 2906 public:2907 FakeRenderSurface(CCLayerImpl* layerImpl)2908 : CCRenderSurface(layerImpl),2909 m_hasCachedTexture(false)2910 {2911 }2912 2913 virtual bool hasCachedContentsTexture() const OVERRIDE2914 {2915 return m_hasCachedTexture;2916 }2917 2918 virtual bool prepareContentsTexture(LayerRendererChromium* lrc) OVERRIDE2919 {2920 return true;2921 }2922 2923 virtual bool contentsChanged() const OVERRIDE2924 {2925 return m_contentsChanged;2926 }2927 2928 void setHasCachedTexture(bool hasCachedTexture)2929 {2930 m_hasCachedTexture = hasCachedTexture;2931 }2932 2933 void setContentsChanged(bool contentsChanged)2934 {2935 m_contentsChanged = contentsChanged;2936 }2937 };2938 2939 2889 class CCTestRenderPass: public CCRenderPass { 2940 2890 public: 2941 static PassOwnPtr<CCRenderPass> create(CCRenderSurface* targetSurface) 2942 { 2943 return adoptPtr(new CCTestRenderPass(targetSurface)); 2944 } 2891 static PassOwnPtr<CCRenderPass> create(CCRenderSurface* targetSurface, int id) { return adoptPtr(new CCTestRenderPass(targetSurface, id)); } 2892 2893 void appendQuad(PassOwnPtr<CCDrawQuad> quad) { m_quadList.append(quad); } 2945 2894 2946 2895 protected: 2947 CCTestRenderPass(CCRenderSurface* surface) 2948 : CCRenderPass(surface) 2949 { 2950 } 2951 2896 CCTestRenderPass(CCRenderSurface* targetSurface, int id) : CCRenderPass(targetSurface, id) { } 2897 }; 2898 2899 class CCTestRenderer : public LayerRendererChromium, public CCRendererClient { 2952 2900 public: 2953 void appendQuad(PassOwnPtr<CCDrawQuad> quad) 2954 { 2955 m_quadList.append(quad); 2956 } 2901 static PassOwnPtr<CCTestRenderer> create(WebKit::WebGraphicsContext3D* context) 2902 { 2903 OwnPtr<CCTestRenderer> renderer(adoptPtr(new CCTestRenderer(context))); 2904 if (!renderer->initialize()) 2905 return nullptr; 2906 2907 return renderer.release(); 2908 } 2909 2910 void clearCachedTextures() { m_textures.clear(); } 2911 void setHaveCachedResourcesForRenderPassId(int id) { m_textures.add(id); } 2912 2913 virtual bool haveCachedResourcesForRenderPassId(int id) const OVERRIDE { return m_textures.contains(id); } 2914 2915 // CCRendererClient implementation. 2916 virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_viewportSize; } 2917 virtual const CCLayerTreeSettings& settings() const OVERRIDE { return m_settings; } 2918 virtual void didLoseContext() OVERRIDE { } 2919 virtual void onSwapBuffersComplete() OVERRIDE { } 2920 virtual void setFullRootLayerDamage() OVERRIDE { } 2921 virtual void releaseContentsTextures() OVERRIDE { } 2922 virtual void setMemoryAllocationLimitBytes(size_t) OVERRIDE { } 2923 2924 protected: 2925 CCTestRenderer(WebKit::WebGraphicsContext3D* context) : LayerRendererChromium(this, context, UnthrottledUploader) { } 2926 2927 private: 2928 CCLayerTreeSettings m_settings; 2929 IntSize m_viewportSize; 2930 HashSet<int> m_textures; 2957 2931 }; 2958 2932 2959 static PassOwnPtr<CCRenderPass> createDummyRenderPass(RenderPassRemovalTestData& testData )2960 { 2961 OwnPtr<CCLayerImpl> layerImpl = CCLayerImpl::create(1);2962 CCRenderSurface* renderSurface = new FakeRenderSurface(layerImpl.get());2963 OwnPtr<CCRenderPass> renderPassPtr = CCTestRenderPass::create(renderSurface);2964 2965 testData.renderSurfaceStore.append( adoptPtr(renderSurface));2933 static PassOwnPtr<CCRenderPass> createDummyRenderPass(RenderPassRemovalTestData& testData, int id) 2934 { 2935 OwnPtr<CCLayerImpl> layerImpl(CCLayerImpl::create(id)); 2936 OwnPtr<CCRenderSurface> renderSurface(adoptPtr(new CCRenderSurface(layerImpl.get()))); 2937 OwnPtr<CCRenderPass> renderPassPtr(CCTestRenderPass::create(renderSurface.get(), layerImpl->id())); 2938 2939 testData.renderSurfaceStore.append(renderSurface.release()); 2966 2940 testData.layerStore.append(layerImpl.release()); 2967 2941 return renderPassPtr.release(); 2968 2942 } 2969 2943 2970 static void configureRenderPassTestData(const char* testScript, RenderPassRemovalTestData& testData) 2971 { 2944 static void configureRenderPassTestData(const char* testScript, RenderPassRemovalTestData& testData, CCTestRenderer* renderer) 2945 { 2946 renderer->clearCachedTextures(); 2947 2972 2948 // One shared state for all quads - we don't need the correct details 2973 2949 testData.sharedQuadState = CCSharedQuadState::create(WebTransformationMatrix(), WebTransformationMatrix(), IntRect(), IntRect(), 1.0, true); … … 2976 2952 2977 2953 // Pre-create root pass 2978 OwnPtr<CCRenderPass> rootRenderPass = createDummyRenderPass(testData); 2979 testData.renderPassId.insert(std::pair<CCRenderPass*, char>(rootRenderPass.get(), testScript[0])); 2980 testData.renderPassCache.insert(std::pair<char, RenderPassCacheEntry>(testScript[0], RenderPassCacheEntry(rootRenderPass.release()))); 2981 while (*currentChar != '\0') { 2954 char rootRenderPassId = testScript[0]; 2955 OwnPtr<CCRenderPass> rootRenderPass = createDummyRenderPass(testData, rootRenderPassId); 2956 testData.renderPassId.insert(std::pair<CCRenderPass*, char>(rootRenderPass.get(), rootRenderPassId)); 2957 testData.renderPassCache.insert(std::pair<char, RenderPassCacheEntry>(rootRenderPassId, RenderPassCacheEntry(rootRenderPass.release()))); 2958 while (*currentChar) { 2982 2959 char renderPassId = currentChar[0]; 2983 2960 currentChar++; … … 2992 2969 2993 2970 // Cycle through quad data and create all quads 2994 while (*currentChar != '\n' && *currentChar != '\0') {2971 while (*currentChar && *currentChar != '\n') { 2995 2972 if (*currentChar == 's') { 2996 2973 // Solid color draw quad … … 3002 2979 // RenderPass draw quad 3003 2980 char newRenderPassId = *currentChar; 2981 ASSERT_NE(rootRenderPassId, newRenderPassId); 3004 2982 currentChar++; 3005 2983 bool hasTexture = false; … … 3008 2986 if (*currentChar == '[') { 3009 2987 currentChar++; 3010 while ( (*currentChar != ']') && (*currentChar != '\0')) {2988 while (*currentChar && *currentChar != ']') { 3011 2989 switch (*currentChar) { 3012 2990 case 'c': … … 3026 3004 3027 3005 if (testData.renderPassCache.find(newRenderPassId) == testData.renderPassCache.end()) { 3028 OwnPtr<CCRenderPass> refRenderPass = createDummyRenderPass(testData); 3006 if (hasTexture) 3007 renderer->setHaveCachedResourcesForRenderPassId(newRenderPassId); 3008 3009 OwnPtr<CCRenderPass> refRenderPass = createDummyRenderPass(testData, newRenderPassId); 3029 3010 refRenderPassPtr = refRenderPass.get(); 3030 FakeRenderSurface* refRenderSurface = static_cast<FakeRenderSurface*>(refRenderPass->targetSurface());3031 refRenderSurface->setHasCachedTexture(hasTexture);3032 refRenderSurface->setContentsChanged(contentsChanged);3033 3011 testData.renderPassId.insert(std::pair<CCRenderPass*, char>(refRenderPass.get(), newRenderPassId)); 3034 3012 testData.renderPassCache.insert(std::pair<char, RenderPassCacheEntry>(newRenderPassId, RenderPassCacheEntry(refRenderPass.release()))); … … 3036 3014 refRenderPassPtr = testData.renderPassCache[newRenderPassId].renderPass; 3037 3015 3038 OwnPtr<CCRenderPassDrawQuad> quad = CCRenderPassDrawQuad::create(testData.sharedQuadState.get(), IntRect(), refRenderPassPtr, isReplica, WebKit::WebFilterOperations(), WebKit::WebFilterOperations(), 1); 3016 IntRect quadRect = IntRect(0, 0, 1, 1); 3017 IntRect contentsChangedRect = contentsChanged ? quadRect : IntRect(); 3018 OwnPtr<CCRenderPassDrawQuad> quad = CCRenderPassDrawQuad::create(testData.sharedQuadState.get(), quadRect, refRenderPassPtr, isReplica, WebKit::WebFilterOperations(), WebKit::WebFilterOperations(), 1, contentsChangedRect); 3039 3019 static_cast<CCTestRenderPass*>(renderPass.get())->appendQuad(quad.release()); 3040 3020 } 3041 3021 } 3042 3022 testData.renderPassList.insert(0, renderPass.release()); 3043 if (*currentChar != '\0')3023 if (*currentChar) 3044 3024 currentChar++; 3045 3025 } … … 3064 3044 pos++; 3065 3045 break; 3066 case CCDrawQuad::RenderPass: 3067 { 3068 CCRenderPassDrawQuad* renderPassDrawQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad); 3069 const CCRenderPass* refPass = renderPassDrawQuad->renderPass(); 3070 char refPassId = testData.renderPassId.find(refPass)->second; 3071 *pos = refPassId; 3072 pos++; 3073 } 3046 case CCDrawQuad::RenderPass: { 3047 CCRenderPassDrawQuad* renderPassDrawQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad); 3048 const CCRenderPass* refPass = renderPassDrawQuad->renderPass(); 3049 char refPassId = testData.renderPassId.find(refPass)->second; 3050 *pos = refPassId; 3051 pos++; 3074 3052 break; 3053 } 3075 3054 default: 3076 3055 *pos = 'x'; … … 3236 3215 } 3237 3216 3238 TEST(RenderPassRemovalTest, testRemoveRenderPasses) 3239 { 3217 TEST_F(CCLayerTreeHostImplTest, testRemoveRenderPasses) 3218 { 3219 OwnPtr<CCGraphicsContext> context(createContext()); 3220 WebKit::WebGraphicsContext3D* context3d = context->context3D(); 3221 ASSERT_TRUE(context3d); 3222 OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(context3d)); 3223 3240 3224 int testCaseIndex = 0; 3241 3225 while (removeRenderPassesCases[testCaseIndex].name) { 3242 DebugScopedSetImplThread implThread;3243 3226 RenderPassRemovalTestData testData; 3244 3227 CCRenderPassList skippedPasses; 3245 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initScript, testData );3246 CCLayerTreeHostImpl::removePassesWithCachedTextures(testData.renderPassList, skippedPasses );3228 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initScript, testData, renderer.get()); 3229 CCLayerTreeHostImpl::removePassesWithCachedTextures(testData.renderPassList, skippedPasses, renderer.get()); 3247 3230 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testData); 3248 3231 testCaseIndex++; -
trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
r121060 r122160 157 157 }; 158 158 159 int CCOcclusionTrackerTestImplThreadTypes::nextCCLayerImplId = 0;159 int CCOcclusionTrackerTestImplThreadTypes::nextCCLayerImplId = 1; 160 160 161 161 template<typename Types, bool opaqueLayers> -
trunk/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
r120820 r122160 61 61 static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList) 62 62 { 63 OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create( 0);63 OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(1); 64 64 OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels); 65 65 tiler->setBounds(layerRect.size()); -
trunk/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
r119401 r122160 58 58 DebugScopedSetImplThread setImplThread; 59 59 60 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create( 0);60 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(1); 61 61 owningLayer->createRenderSurface(); 62 62 ASSERT_TRUE(owningLayer->renderSurface()); … … 96 96 DebugScopedSetImplThread setImplThread; 97 97 98 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create( 0);98 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(1); 99 99 owningLayer->createRenderSurface(); 100 100 ASSERT_TRUE(owningLayer->renderSurface()); -
trunk/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp
r121396 r122160 48 48 IntRect visibleLayerRect = IntRect(IntPoint(), layerSize); 49 49 50 OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create( 0);50 OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1); 51 51 layer->setVisibleLayerRect(visibleLayerRect); 52 52 layer->setBounds(layerSize); … … 69 69 IntRect visibleLayerRect = IntRect(IntPoint(), layerSize); 70 70 71 OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create( 0);71 OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1); 72 72 layer->setVisibleLayerRect(visibleLayerRect); 73 73 layer->setBounds(layerSize); … … 92 92 IntRect visibleLayerRect = IntRect(IntPoint(), layerSize); 93 93 94 OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create( 0);94 OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1); 95 95 layer->setVisibleLayerRect(visibleLayerRect); 96 96 layer->setBounds(layerSize); -
trunk/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp
r120820 r122160 44 44 static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexels) 45 45 { 46 OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create( 0);46 OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(1); 47 47 OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(tileSize, borderTexels); 48 48 tiler->setBounds(layerSize); -
trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
r121204 r122160 80 80 { 81 81 m_rootLayer->createRenderSurface(); 82 m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface() );82 m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface(), m_rootLayer->id()); 83 83 } 84 84 -
trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
r121870 r122160 98 98 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 99 99 DebugScopedSetImplThread implThread; 100 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));100 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 101 101 102 102 // The tile size is 100x100, so this invalidates and then paints two tiles. … … 135 135 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 136 136 DebugScopedSetImplThread implThread; 137 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));137 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 138 138 TestCCOcclusionTracker occluded; 139 139 … … 181 181 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 182 182 DebugScopedSetImplThread implThread; 183 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));183 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 184 184 185 185 // The tile size is 100x100, so this invalidates and then paints two tiles. … … 227 227 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 228 228 DebugScopedSetImplThread implThread; 229 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));229 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 230 230 231 231 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center. … … 286 286 DebugScopedSetImplThread implThread; 287 287 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 288 OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl( 0)));288 OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(1))); 289 289 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 290 OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl( 0)));290 OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(2))); 291 291 292 292 // For this test we have two layers. layer1 exhausts most texture memory, leaving room for 2 more tiles from … … 369 369 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 370 370 DebugScopedSetImplThread implThread; 371 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));371 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 372 372 TestCCOcclusionTracker occluded; 373 373 … … 396 396 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 397 397 DebugScopedSetImplThread implThread; 398 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));398 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 399 399 400 400 // The tile size is 100x100, so this invalidates and then paints two tiles. … … 423 423 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 424 424 DebugScopedSetImplThread implThread; 425 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl( 0)));426 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl( 0)));425 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1))); 426 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2))); 427 427 428 428 layer1->setBounds(IntSize(100, 200)); … … 461 461 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 462 462 DebugScopedSetImplThread implThread; 463 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl( 0)));464 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl( 0)));463 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1))); 464 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2))); 465 465 466 466 layer1->setBounds(IntSize(100, 200)); … … 504 504 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 505 505 DebugScopedSetImplThread implThread; 506 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));506 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 507 507 508 508 // Invalidates 9 tiles and then paints one visible tile. … … 538 538 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 539 539 DebugScopedSetImplThread implThread; 540 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));540 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 541 541 542 542 // The layer's bounds are empty. … … 579 579 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 580 580 DebugScopedSetImplThread implThread; 581 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));581 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 582 582 583 583 // Pretend the layer is animating. … … 626 626 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 627 627 DebugScopedSetImplThread implThread; 628 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));628 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 629 629 630 630 // Invalidate the layer but make none of it visible, so nothing paints. … … 679 679 for (int i = 0; width[i]; ++i) { 680 680 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 681 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));681 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 682 682 683 683 // Pretend the layer is animating. … … 748 748 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 749 749 DebugScopedSetImplThread implThread; 750 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));750 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 751 751 752 752 FakeTextureAllocator fakeAllocator; … … 837 837 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 838 838 DebugScopedSetImplThread implThread; 839 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));839 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 840 840 841 841 // Create a layer with one tile. … … 1002 1002 { 1003 1003 DebugScopedSetImplThread implThread; 1004 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));1004 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 1005 1005 updateTextures(4); 1006 1006 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); … … 1020 1020 { 1021 1021 DebugScopedSetImplThread implThread; 1022 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));1022 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 1023 1023 updateTextures(4); 1024 1024 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); … … 1037 1037 { 1038 1038 DebugScopedSetImplThread implThread; 1039 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));1039 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 1040 1040 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1041 1041 updateTextures(4); … … 1055 1055 { 1056 1056 DebugScopedSetImplThread implThread; 1057 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));1057 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 1058 1058 layer->pushPropertiesTo(layerImpl.get()); 1059 1059 } … … 1064 1064 { 1065 1065 DebugScopedSetImplThread implThread; 1066 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));1066 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 1067 1067 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1068 1068 updateTextures(4); … … 1082 1082 { 1083 1083 DebugScopedSetImplThread implThread; 1084 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl( 0)));1084 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); 1085 1085 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1086 1086 updateTextures(4);
Note: See TracChangeset
for help on using the changeset viewer.