Changeset 118699 in webkit
- Timestamp:
- May 28, 2012 11:29:29 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r118698 r118699 1 2012-05-28 Arvid Nilsson <anilsson@rim.com> 2 3 [BlackBerry] Add an overlay layer 4 https://bugs.webkit.org/show_bug.cgi?id=87567 5 6 Reviewed by Antonio Gomes. 7 8 The overlay layer allows us to have compositing layers even though the 9 web page is not currently using accelerated compositing. 10 11 These layers can be used to implement tap highlight, inspector overlay 12 and more. 13 14 The WebCore changes support the overlay layer functionality in WebKit 15 by making it possible to add animations from the compositing thread 16 without them being instantly overwritten during the next commit. 17 18 Also a new custom layer type is added, which allow an overlay layer to 19 draw itself using raw OpenGL calls. An instance of a custom subclass of 20 LayerCompositingThread must be provided when creating the 21 LayerWebKitThread. Then, the custom layer can be used as the content 22 layer of a GraphicsLayer, or by itself. 23 24 Reviewed internally by Filip Spacek. 25 26 PR #154335 27 28 * platform/graphics/blackberry/LayerCompositingThread.cpp: 29 (WebCore::LayerCompositingThread::~LayerCompositingThread): 30 (WebCore::LayerCompositingThread::deleteTextures): 31 (WebCore::LayerCompositingThread::drawTextures): 32 (WebCore::LayerCompositingThread::drawMissingTextures): 33 (WebCore::LayerCompositingThread::updateTextureContentsIfNeeded): 34 (WebCore::LayerCompositingThread::setVisible): 35 (WebCore::LayerCompositingThread::scheduleCommit): 36 * platform/graphics/blackberry/LayerCompositingThread.h: 37 (WebCore::LayerCompositingThread::addAnimation): 38 (WebCore::LayerCompositingThread::setRunningAnimations): 39 (WebCore::LayerCompositingThread::setSuspendedAnimations): 40 (LayerCompositingThread): 41 (WebCore::LayerCompositingThread::drawCustom): 42 * platform/graphics/blackberry/LayerData.h: 43 (LayerData): 44 * platform/graphics/blackberry/LayerWebKitThread.cpp: 45 (WebCore::LayerWebKitThread::LayerWebKitThread): 46 (WebCore): 47 (WebCore::LayerWebKitThread::~LayerWebKitThread): 48 (WebCore::LayerWebKitThread::updateTextureContentsIfNeeded): 49 (WebCore::LayerWebKitThread::startAnimations): 50 (WebCore::LayerWebKitThread::commitOnCompositingThread): 51 (WebCore::LayerWebKitThread::setNeedsDisplayInRect): 52 (WebCore::LayerWebKitThread::setNeedsDisplay): 53 (WebCore::LayerWebKitThread::setIsMask): 54 (WebCore::LayerWebKitThread::setRunningAnimations): 55 (WebCore::LayerWebKitThread::setSuspendedAnimations): 56 * platform/graphics/blackberry/LayerWebKitThread.h: 57 (LayerWebKitThread): 58 1 59 2012-05-28 Leo Yang <leo.yang@torchmobile.com.cn> 2 60 -
trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp
r118696 r118699 76 76 ASSERT(isCompositingThread()); 77 77 78 m_tiler->layerCompositingThreadDestroyed(); 78 if (m_tiler) 79 m_tiler->layerCompositingThreadDestroyed(); 79 80 80 81 ASSERT(!superlayer()); … … 107 108 releaseTextureResources(); 108 109 109 m_tiler->deleteTextures(); 110 if (m_tiler) 111 m_tiler->deleteTextures(); 110 112 } 111 113 … … 257 259 } 258 260 259 m_tiler->drawTextures(this, positionLocation, texCoordLocation); 261 if (m_layerType == CustomLayer) { 262 // Custom layers don't have a LayerTiler, so they either have to set 263 // m_texID or implement drawCustom. 264 drawCustom(positionLocation, texCoordLocation); 265 return; 266 } 267 268 if (m_tiler) 269 m_tiler->drawTextures(this, positionLocation, texCoordLocation); 260 270 } 261 271 … … 296 306 #endif 297 307 298 m_tiler->drawMissingTextures(this, positionLocation, texCoordLocation); 308 if (m_tiler) 309 m_tiler->drawMissingTextures(this, positionLocation, texCoordLocation); 299 310 } 300 311 … … 419 430 #endif 420 431 421 m_tiler->uploadTexturesIfNeeded(); 432 if (m_tiler) 433 m_tiler->uploadTexturesIfNeeded(); 422 434 } 423 435 … … 437 449 #endif 438 450 439 m_tiler->layerVisibilityChanged(visible); 451 if (m_tiler) 452 m_tiler->layerVisibilityChanged(visible); 440 453 } 441 454 … … 448 461 void LayerCompositingThread::scheduleCommit() 449 462 { 463 if (!m_tiler) 464 return; 465 450 466 if (!isWebKitThread()) { 451 467 if (m_commitScheduled) -
trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h
r113868 r118699 37 37 38 38 #include "FloatQuad.h" 39 #include "LayerAnimation.h" 39 40 #include "LayerData.h" 40 41 #include "LayerRendererSurface.h" … … 140 141 bool hasVisibleHolePunchRect() const; 141 142 143 void addAnimation(LayerAnimation* animation) { m_runningAnimations.append(animation); } 144 void setRunningAnimations(const Vector<RefPtr<LayerAnimation> >& animations) { m_runningAnimations = animations; } 145 void setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >& animations) { m_suspendedAnimations = animations; } 146 142 147 protected: 143 148 virtual ~LayerCompositingThread(); 149 150 virtual void drawCustom(int positionLocation, int texCoordLocation) { } 144 151 145 152 private: … … 184 191 185 192 RefPtr<LayerTiler> m_tiler; 193 Vector<RefPtr<LayerAnimation> > m_runningAnimations; 194 Vector<RefPtr<LayerAnimation> > m_suspendedAnimations; 186 195 }; 187 196 -
trunk/Source/WebCore/platform/graphics/blackberry/LayerData.h
r112407 r118699 38 38 #include "FloatRect.h" 39 39 #include "IntRect.h" 40 #include "LayerAnimation.h"41 40 #include "PlatformString.h" 42 41 #include "TransformationMatrix.h" … … 55 54 class LayerData { 56 55 public: 57 enum LayerType { Layer, TransformLayer, WebGLLayer, CanvasLayer };56 enum LayerType { Layer, TransformLayer, WebGLLayer, CanvasLayer, CustomLayer }; 58 57 enum FilterType { Linear, Nearest, Trilinear, Lanczos }; 59 58 enum LayerProgramShader { LayerProgramShaderRGBA = 0, … … 192 191 pthread_mutex_t* m_frontBufferLock; 193 192 194 Vector<RefPtr<LayerAnimation> > m_runningAnimations;195 Vector<RefPtr<LayerAnimation> > m_suspendedAnimations;196 193 double m_suspendTime; 197 194 -
trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp
r112124 r118699 64 64 , m_isDrawable(false) 65 65 , m_isMask(false) 66 { 67 m_tiler = LayerTiler::create(this); 66 , m_animationsChanged(false) 67 { 68 if (type == Layer) 69 m_tiler = LayerTiler::create(this); 68 70 m_layerCompositingThread = LayerCompositingThread::create(type, m_tiler); 71 } 72 73 LayerWebKitThread::LayerWebKitThread(PassRefPtr<LayerCompositingThread> layerCompositingThread, GraphicsLayerBlackBerry* owner) 74 : LayerData(CustomLayer) 75 , m_owner(owner) 76 , m_superlayer(0) 77 , m_contents(0) 78 , m_scale(1.0) 79 , m_isDrawable(false) 80 , m_isMask(false) 81 { 82 m_layerCompositingThread = layerCompositingThread; 69 83 } 70 84 … … 76 90 pthread_mutex_destroy(m_frontBufferLock); 77 91 78 m_tiler->layerWebKitThreadDestroyed(); 92 if (m_tiler) 93 m_tiler->layerWebKitThreadDestroyed(); 79 94 80 95 // Our superlayer should be holding a reference to us so there should be no … … 168 183 void LayerWebKitThread::updateTextureContentsIfNeeded() 169 184 { 170 m_tiler->updateTextureContentsIfNeeded(m_isMask ? 1.0 : contentsScale()); 185 if (m_tiler) 186 m_tiler->updateTextureContentsIfNeeded(m_isMask ? 1.0 : contentsScale()); 171 187 } 172 188 … … 227 243 for (size_t i = 0; i < m_runningAnimations.size(); ++i) { 228 244 if (!m_runningAnimations[i]->startTime()) { 245 m_animationsChanged = true; 229 246 m_runningAnimations[i]->setStartTime(time); 230 247 notifyAnimationStarted(time); … … 279 296 // Copy the base variables from this object into m_layerCompositingThread 280 297 replicate(m_layerCompositingThread.get()); 298 if (m_animationsChanged) { 299 m_layerCompositingThread->setRunningAnimations(m_runningAnimations); 300 m_layerCompositingThread->setSuspendedAnimations(m_suspendedAnimations); 301 m_animationsChanged = false; 302 } 281 303 m_position = oldPosition; 282 304 updateLayerHierarchy(); 283 m_tiler->commitPendingTextureUploads(); 305 if (m_tiler) 306 m_tiler->commitPendingTextureUploads(); 284 307 285 308 size_t listSize = m_sublayers.size(); … … 425 448 void LayerWebKitThread::setNeedsDisplayInRect(const FloatRect& dirtyRect) 426 449 { 427 m_tiler->setNeedsDisplay(dirtyRect); 450 if (m_tiler) 451 m_tiler->setNeedsDisplay(dirtyRect); 428 452 setNeedsCommit(); // FIXME: Replace this with a more targeted message for dirty rect handling with plugin content? 429 453 } … … 431 455 void LayerWebKitThread::setNeedsDisplay() 432 456 { 433 m_tiler->setNeedsDisplay(); 457 if (m_tiler) 458 m_tiler->setNeedsDisplay(); 434 459 setNeedsCommit(); // FIXME: Replace this with a more targeted message for dirty rect handling with plugin content? 435 460 } … … 449 474 { 450 475 m_isMask = isMask; 451 if (isMask )476 if (isMask && m_tiler) 452 477 m_tiler->disableTiling(true); 453 478 } 454 479 480 void LayerWebKitThread::setRunningAnimations(const Vector<RefPtr<LayerAnimation> >& animations) 481 { 482 m_runningAnimations = animations; 483 m_animationsChanged = true; 484 setNeedsCommit(); 485 } 486 487 void LayerWebKitThread::setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >& animations) 488 { 489 m_suspendedAnimations = animations; 490 m_animationsChanged = true; 491 setNeedsCommit(); 492 } 493 455 494 } 456 495 -
trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h
r112407 r118699 37 37 38 38 #include "GraphicsLayerBlackBerry.h" 39 #include "LayerAnimation.h" 39 40 #include "LayerData.h" 40 41 #include "LayerTiler.h" … … 143 144 void notifyAnimationStarted(double time); 144 145 145 void setRunningAnimations(const Vector<RefPtr<LayerAnimation> >& animations) { m_runningAnimations = animations; setNeedsCommit(); }146 void setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >& animations) { m_suspendedAnimations = animations; setNeedsCommit(); }146 void setRunningAnimations(const Vector<RefPtr<LayerAnimation> >&); 147 void setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >&); 147 148 148 149 protected: 149 150 LayerWebKitThread(LayerType, GraphicsLayerBlackBerry* owner); 151 152 // Create a custom Layer{WebKitThread, CompositingThread} pair, used when you need to subclass both. 153 LayerWebKitThread(PassRefPtr<LayerCompositingThread>, GraphicsLayerBlackBerry* owner); 150 154 151 155 void setNeedsTexture(bool needsTexture) { m_needsTexture = needsTexture; } … … 179 183 GraphicsLayerBlackBerry* m_owner; 180 184 185 Vector<RefPtr<LayerAnimation> > m_runningAnimations; 186 Vector<RefPtr<LayerAnimation> > m_suspendedAnimations; 187 181 188 Vector<RefPtr<LayerWebKitThread> > m_sublayers; 182 189 LayerWebKitThread* m_superlayer; … … 190 197 FloatSize m_absoluteOffset; 191 198 double m_scale; // Scale applies only to content layers 192 bool m_isDrawable; 193 bool m_isMask; 199 unsigned m_isDrawable : 1; 200 unsigned m_isMask : 1; 201 unsigned m_animationsChanged : 1; 194 202 }; 195 203 -
trunk/Source/WebKit/blackberry/Api/WebPage.cpp
r118627 r118699 5583 5583 void WebPagePrivate::scheduleRootLayerCommit() 5584 5584 { 5585 if (! m_frameLayers || !m_frameLayers->hasLayer())5585 if (!(m_frameLayers && m_frameLayers->hasLayer()) && !m_overlayLayer) 5586 5586 return; 5587 5587 … … 5619 5619 } 5620 5620 5621 GraphicsLayer* WebPagePrivate::overlayLayer() 5622 { 5623 // The overlay layer has no GraphicsLayerClient, it's just a container 5624 // for various overlays. 5625 if (!m_overlayLayer) 5626 m_overlayLayer = GraphicsLayer::create(0); 5627 5628 return m_overlayLayer.get(); 5629 } 5630 5621 5631 void WebPagePrivate::setCompositor(PassRefPtr<WebPageCompositorPrivate> compositor) 5622 5632 { … … 5648 5658 #endif 5649 5659 5650 if (!m_frameLayers || !m_compositor) 5651 return; 5652 5653 if (m_frameLayers->rootLayer() && m_frameLayers->rootLayer()->layerCompositingThread() != m_compositor->rootLayer()) 5654 m_compositor->setRootLayer(m_frameLayers->rootLayer()->layerCompositingThread()); 5660 if (!m_compositor) 5661 return; 5662 5663 // Frame layers 5664 LayerWebKitThread* rootLayer = 0; 5665 if (m_frameLayers) 5666 rootLayer = m_frameLayers->rootLayer(); 5667 5668 if (rootLayer && rootLayer->layerCompositingThread() != m_compositor->rootLayer()) 5669 m_compositor->setRootLayer(rootLayer->layerCompositingThread()); 5670 5671 // Overlay layers 5672 LayerWebKitThread* overlayLayer = 0; 5673 if (m_overlayLayer) 5674 overlayLayer = m_overlayLayer->platformLayer(); 5675 5676 if (overlayLayer && overlayLayer->layerCompositingThread() != m_compositor->overlayLayer()) 5677 m_compositor->setOverlayLayer(overlayLayer->layerCompositingThread()); 5655 5678 5656 5679 m_compositor->setLayoutRectForCompositing(layoutRectForCompositing); 5657 5680 m_compositor->setContentsSizeForCompositing(contentsSizeForCompositing); 5658 5681 m_compositor->setDrawsRootLayer(drawsRootLayer); 5659 m_compositor->commit(m_frameLayers->rootLayer()); 5682 5683 if (rootLayer) 5684 rootLayer->commitOnCompositingThread(); 5685 5686 if (overlayLayer) 5687 overlayLayer->commitOnCompositingThread(); 5660 5688 } 5661 5689 … … 5678 5706 return false; 5679 5707 5680 if (! m_frameLayers || !m_frameLayers->hasLayer())5708 if (!(m_frameLayers && m_frameLayers->hasLayer()) && !m_overlayLayer) 5681 5709 return false; 5682 5710 … … 5703 5731 m_rootLayerCommitTimer->stop(); 5704 5732 5705 m_frameLayers->commitOnWebKitThread(currentScale()); 5733 double scale = currentScale(); 5734 if (m_frameLayers && m_frameLayers->hasLayer()) 5735 m_frameLayers->commitOnWebKitThread(scale); 5706 5736 updateDelegatedOverlays(); 5737 if (m_overlayLayer) 5738 m_overlayLayer->platformLayer()->commitOnWebKitThread(scale); 5707 5739 5708 5740 // Stash the visible content rect according to webkit thread -
trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp
r118696 r118699 79 79 } 80 80 81 void WebPageCompositorPrivate::setOverlayLayer(LayerCompositingThread* overlayLayer) 82 { 83 m_overlayLayer = overlayLayer; 84 } 85 81 86 void WebPageCompositorPrivate::prepareFrame(double animationTime) 82 87 { … … 89 94 if (m_rootLayer) 90 95 m_layerRenderer->prepareFrame(animationTime, m_rootLayer.get()); 96 if (m_overlayLayer) 97 m_layerRenderer->prepareFrame(animationTime, m_overlayLayer.get()); 91 98 } 92 99 … … 121 128 if (m_rootLayer) 122 129 m_layerRenderer->compositeLayers(transform, m_rootLayer.get()); 130 if (m_overlayLayer) 131 m_layerRenderer->compositeLayers(transform, m_overlayLayer.get()); 123 132 124 133 m_lastCompositingResults = m_layerRenderer->lastRenderingResults(); … … 163 172 if (m_rootLayer) 164 173 m_layerRenderer->compositeLayers(transform, m_rootLayer.get()); 174 if (m_overlayLayer) 175 m_layerRenderer->compositeLayers(transform, m_overlayLayer.get()); 165 176 166 177 m_lastCompositingResults = m_layerRenderer->lastRenderingResults(); -
trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h
r118696 r118699 68 68 void setRootLayer(WebCore::LayerCompositingThread*); 69 69 70 WebCore::LayerCompositingThread* overlayLayer() const { return m_overlayLayer.get(); } 71 void setOverlayLayer(WebCore::LayerCompositingThread*); 72 70 73 bool drawsRootLayer() const; 71 74 void setDrawsRootLayer(bool drawsRootLayer) { m_drawsRootLayer = drawsRootLayer; } … … 101 104 OwnPtr<WebCore::LayerRenderer> m_layerRenderer; 102 105 RefPtr<WebCore::LayerCompositingThread> m_rootLayer; 106 RefPtr<WebCore::LayerCompositingThread> m_overlayLayer; 103 107 WebCore::IntRect m_layoutRectForCompositing; 104 108 WebCore::IntSize m_contentsSizeForCompositing; -
trunk/Source/WebKit/blackberry/Api/WebPage_p.h
r116603 r118699 369 369 bool commitRootLayerIfNeeded(); 370 370 WebCore::LayerRenderingResults lastCompositingResults() const; 371 WebCore::GraphicsLayer* overlayLayer(); 371 372 372 373 // WebKit thread, plumbed through from ChromeClientBlackBerry. … … 517 518 bool m_isAcceleratedCompositingActive; 518 519 OwnPtr<FrameLayers> m_frameLayers; // WebKit thread only. 520 OwnPtr<WebCore::GraphicsLayer> m_overlayLayer; 519 521 520 522 // Compositing thread only, used only when the WebKit layer created the context. -
trunk/Source/WebKit/blackberry/ChangeLog
r118696 r118699 1 2012-05-28 Arvid Nilsson <anilsson@rim.com> 2 3 [BlackBerry] Add an overlay layer 4 https://bugs.webkit.org/show_bug.cgi?id=87567 5 6 Reviewed by Antonio Gomes. 7 8 The overlay layer allows us to have compositing layers even though the 9 web page is not currently using accelerated compositing. 10 11 These layers can be used to implement tap highlight, inspector overlay 12 and more. 13 14 Reviewed internally by Filip Spacek. 15 16 PR #154335 17 18 * Api/WebPage.cpp: 19 (BlackBerry::WebKit::WebPagePrivate::scheduleRootLayerCommit): 20 (BlackBerry::WebKit::WebPagePrivate::overlayLayer): 21 (WebKit): 22 (BlackBerry::WebKit::WebPagePrivate::commitRootLayer): 23 (BlackBerry::WebKit::WebPagePrivate::commitRootLayerIfNeeded): 24 * Api/WebPageCompositor.cpp: 25 (BlackBerry::WebKit::WebPageCompositorPrivate::setOverlayLayer): 26 (WebKit): 27 (BlackBerry::WebKit::WebPageCompositorPrivate::prepareFrame): 28 (BlackBerry::WebKit::WebPageCompositorPrivate::render): 29 (BlackBerry::WebKit::WebPageCompositorPrivate::drawLayers): 30 * Api/WebPageCompositor_p.h: 31 (BlackBerry::WebKit::WebPageCompositorPrivate::overlayLayer): 32 (WebPageCompositorPrivate): 33 * Api/WebPage_p.h: 34 (WebPagePrivate): 35 1 36 2012-05-28 Arvid Nilsson <anilsson@rim.com> 2 37
Note: See TracChangeset
for help on using the changeset viewer.