Changeset 86805 in webkit
- Timestamp:
- May 18, 2011 4:53:12 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 added
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86804 r86805 1 2011-05-18 Alok Priyadarshi <alokp@chromium.org> and Adrienne Walker <enne@google.com> 2 3 Reviewed by James Robinson. 4 5 [chromium] Split canvas from LayerTilerChromium 6 https://bugs.webkit.org/show_bug.cgi?id=60719 7 8 LayerTilerChromium now just does tiling. It delegates the task of painting and updating textures to LayerTextureUpdater. 9 Also abstracted LayerTextureSubImage to upload texture pixels. 10 11 * WebCore.gypi: 12 * platform/chromium/TraceEvent.h: 13 * platform/graphics/chromium/ContentLayerChromium.cpp: 14 (WebCore::ContentLayerChromium::create): 15 (WebCore::ContentLayerChromium::ContentLayerChromium): 16 (WebCore::ContentLayerChromium::~ContentLayerChromium): 17 (WebCore::ContentLayerChromium::paintContentsIfDirty): 18 (WebCore::ContentLayerChromium::cleanupResources): 19 (WebCore::ContentLayerChromium::setLayerRenderer): 20 (WebCore::ContentLayerChromium::createTextureUpdater): 21 (WebCore::ContentLayerChromium::drawsContent): 22 (WebCore::ContentLayerChromium::createTilerIfNeeded): 23 (WebCore::ContentLayerChromium::updateCompositorResources): 24 * platform/graphics/chromium/ContentLayerChromium.h: 25 * platform/graphics/chromium/ImageLayerChromium.cpp: 26 (WebCore::ImageLayerTextureUpdater::ImageLayerTextureUpdater): 27 (WebCore::ImageLayerTextureUpdater::~ImageLayerTextureUpdater): 28 (WebCore::ImageLayerTextureUpdater::orientation): 29 (WebCore::ImageLayerTextureUpdater::prepareToUpdate): 30 (WebCore::ImageLayerTextureUpdater::updateTextureRect): 31 (WebCore::ImageLayerTextureUpdater::imageRect): 32 (WebCore::ImageLayerChromium::paintContentsIfDirty): 33 (WebCore::ImageLayerChromium::updateCompositorResources): 34 (WebCore::ImageLayerChromium::createTextureUpdater): 35 * platform/graphics/chromium/ImageLayerChromium.h: 36 * platform/graphics/chromium/LayerPainterChromium.h: Added. 37 * platform/graphics/chromium/LayerRendererChromium.cpp: 38 (WebCore::LayerRendererChromium::create): 39 (WebCore::LayerRendererChromium::LayerRendererChromium): 40 (WebCore::LayerRendererChromium::updateRootLayerContents): 41 (WebCore::LayerRendererChromium::drawRootLayer): 42 (WebCore::LayerRendererChromium::updateAndDrawLayers): 43 (WebCore::LayerRendererChromium::updateLayers): 44 * platform/graphics/chromium/LayerRendererChromium.h: 45 * platform/graphics/chromium/LayerTextureSubImage.cpp: Added. 46 (WebCore::LayerTextureSubImage::LayerTextureSubImage): 47 (WebCore::LayerTextureSubImage::~LayerTextureSubImage): 48 (WebCore::LayerTextureSubImage::setSubImageSize): 49 (WebCore::LayerTextureSubImage::upload): 50 (WebCore::LayerTextureSubImage::uploadWithTexSubImage): 51 (WebCore::LayerTextureSubImage::uploadWithMapTexSubImage): 52 * platform/graphics/chromium/LayerTextureSubImage.h: Copied from Source/WebCore/platform/chromium/TraceEvent.h. 53 * platform/graphics/chromium/LayerTextureUpdater.h: Copied from Source/WebCore/platform/chromium/TraceEvent.h. 54 (WebCore::LayerTextureUpdater::LayerTextureUpdater): 55 (WebCore::LayerTextureUpdater::~LayerTextureUpdater): 56 (WebCore::LayerTextureUpdater::context): 57 * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp: Added. 58 (WebCore::LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas): 59 (WebCore::LayerTextureUpdaterCanvas::paintContents): 60 (WebCore::LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap): 61 (WebCore::LayerTextureUpdaterBitmap::prepareToUpdate): 62 (WebCore::LayerTextureUpdaterBitmap::updateTextureRect): 63 * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: Added. 64 (WebCore::LayerTextureUpdaterCanvas::~LayerTextureUpdaterCanvas): 65 (WebCore::LayerTextureUpdaterCanvas::contentRect): 66 (WebCore::LayerTextureUpdaterBitmap::~LayerTextureUpdaterBitmap): 67 (WebCore::LayerTextureUpdaterBitmap::orientation): 68 * platform/graphics/chromium/LayerTilerChromium.cpp: 69 (WebCore::LayerTilerChromium::create): 70 (WebCore::LayerTilerChromium::LayerTilerChromium): 71 (WebCore::LayerTilerChromium::setTileSize): 72 (WebCore::LayerTilerChromium::prepareToUpdate): 73 (WebCore::LayerTilerChromium::updateRect): 74 (WebCore::LayerTilerChromium::draw): 75 * platform/graphics/chromium/LayerTilerChromium.h: 76 (WebCore::LayerTilerChromium::Tile::Tile): 77 * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: 78 (WebCore::CCHeadsUpDisplay::draw): 79 1 80 2011-05-18 Mark Pilgrim <pilgrim@chromium.org> 2 81 -
trunk/Source/WebCore/WebCore.gypi
r86765 r86805 4041 4041 'platform/graphics/chromium/LayerChromium.cpp', 4042 4042 'platform/graphics/chromium/LayerChromium.h', 4043 'platform/graphics/chromium/LayerPainterChromium.h', 4043 4044 'platform/graphics/chromium/LayerRendererChromium.cpp', 4044 4045 'platform/graphics/chromium/LayerRendererChromium.h', 4045 4046 'platform/graphics/chromium/LayerTexture.cpp', 4046 4047 'platform/graphics/chromium/LayerTexture.h', 4048 'platform/graphics/chromium/LayerTextureSubImage.cpp', 4049 'platform/graphics/chromium/LayerTextureSubImage.h', 4050 'platform/graphics/chromium/LayerTextureUpdater.h', 4051 'platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp', 4052 'platform/graphics/chromium/LayerTextureUpdaterCanvas.h', 4047 4053 'platform/graphics/chromium/LayerTilerChromium.cpp', 4048 4054 'platform/graphics/chromium/LayerTilerChromium.h', -
trunk/Source/WebCore/platform/chromium/TraceEvent.h
r86640 r86805 27 27 28 28 #include "PlatformBridge.h" 29 #include <wtf/OwnArrayPtr.h> 29 30 30 31 // Implementation detail: trace event macros create temporary variables -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r86640 r86805 37 37 #include "cc/CCLayerImpl.h" 38 38 #include "GraphicsContext3D.h" 39 #include "LayerPainterChromium.h" 39 40 #include "LayerRendererChromium.h" 40 41 #include "LayerTexture.h" 42 #include "LayerTextureUpdaterCanvas.h" 43 #include "LayerTilerChromium.h" 41 44 #include "RenderLayerBacking.h" 42 45 #include "TextStream.h" … … 52 55 namespace WebCore { 53 56 54 PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(GraphicsLayerChromium* owner) 55 { 56 return adoptRef(new ContentLayerChromium(owner)); 57 } 58 59 ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner) 60 : LayerChromium(owner) 61 , m_tilingOption(ContentLayerChromium::AutoTile) 62 { 63 } 64 65 ContentLayerChromium::~ContentLayerChromium() 66 { 67 m_tiler.clear(); 68 LayerChromium::cleanupResources(); 69 } 70 71 class ContentLayerPainter : public TilePaintInterface { 57 class ContentLayerPainter : public LayerPainterChromium { 72 58 public: 73 59 explicit ContentLayerPainter(GraphicsLayerChromium* owner) … … 86 72 }; 87 73 74 PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(GraphicsLayerChromium* owner) 75 { 76 return adoptRef(new ContentLayerChromium(owner)); 77 } 78 79 ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner) 80 : LayerChromium(owner) 81 , m_tilingOption(ContentLayerChromium::AutoTile) 82 { 83 } 84 85 ContentLayerChromium::~ContentLayerChromium() 86 { 87 cleanupResources(); 88 } 89 88 90 void ContentLayerChromium::paintContentsIfDirty(const IntRect& targetSurfaceRect) 89 91 { … … 91 93 ASSERT(layerRenderer()); 92 94 93 createTilerIfNeeded();94 95 ContentLayerPainter painter(m_owner);96 95 updateLayerSize(layerBounds().size()); 97 96 … … 104 103 m_tiler->invalidateRect(dirty); 105 104 106 m_tiler-> update(painter,layerRect);105 m_tiler->prepareToUpdate(layerRect); 107 106 m_dirtyRect = FloatRect(); 107 } 108 109 void ContentLayerChromium::cleanupResources() 110 { 111 m_tiler.clear(); 112 LayerChromium::cleanupResources(); 108 113 } 109 114 … … 112 117 LayerChromium::setLayerRenderer(layerRenderer); 113 118 createTilerIfNeeded(); 114 m_tiler->setLayerRenderer(layerRenderer); 119 } 120 121 PassOwnPtr<LayerTextureUpdater> ContentLayerChromium::createTextureUpdater() 122 { 123 OwnPtr<LayerPainterChromium> painter = adoptPtr(new ContentLayerPainter(m_owner)); 124 return adoptPtr(new LayerTextureUpdaterBitmap(layerRendererContext(), painter.release(), layerRenderer()->contextSupportsMapSub())); 115 125 } 116 126 … … 187 197 } 188 198 199 bool ContentLayerChromium::drawsContent() const 200 { 201 return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw()); 202 } 203 189 204 void ContentLayerChromium::createTilerIfNeeded() 190 205 { 191 206 if (m_tiler) 192 207 return; 193 m_tiler = LayerTilerChromium::create(layerRenderer(), IntSize(defaultTileSize, defaultTileSize), LayerTilerChromium::HasBorderTexels); 208 209 m_tiler = LayerTilerChromium::create( 210 layerRenderer(), 211 createTextureUpdater(), 212 IntSize(defaultTileSize, defaultTileSize), 213 LayerTilerChromium::HasBorderTexels); 194 214 } 195 215 196 216 void ContentLayerChromium::updateCompositorResources() 197 217 { 198 m_tiler->up loadCanvas();218 m_tiler->updateRect(); 199 219 } 200 220 -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r86640 r86805 36 36 37 37 #include "LayerChromium.h" 38 #include "LayerTilerChromium.h"39 #include "TextureManager.h"40 38 41 39 namespace WebCore { 42 40 43 41 class LayerTexture; 42 class LayerTilerChromium; 43 class LayerTextureUpdater; 44 44 45 45 // A Layer that requires a GraphicsContext to render its contents. … … 59 59 60 60 virtual void draw(const IntRect& targetSurfaceRect); 61 virtual bool drawsContent() const { return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw()); }61 virtual bool drawsContent() const; 62 62 63 63 protected: … … 67 67 virtual void dumpLayerProperties(TextStream&, int indent) const; 68 68 69 virtual void cleanupResources(); 69 70 virtual void setLayerRenderer(LayerRendererChromium*); 71 72 virtual PassOwnPtr<LayerTextureUpdater> createTextureUpdater(); 70 73 71 74 virtual IntRect layerBounds() const; -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r86640 r86805 39 39 #include "LayerRendererChromium.h" 40 40 #include "LayerTexture.h" 41 #include "LayerTextureSubImage.h" 42 #include "LayerTextureUpdater.h" 41 43 42 44 namespace WebCore { 45 46 class ImageLayerTextureUpdater : public LayerTextureUpdater { 47 public: 48 ImageLayerTextureUpdater(GraphicsContext3D* context, const PlatformImage& image, bool useMapTexSubImage) 49 : LayerTextureUpdater(context) 50 , m_image(image) 51 , m_texSubImage(useMapTexSubImage) 52 { 53 } 54 virtual ~ImageLayerTextureUpdater() { } 55 56 virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } 57 58 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) 59 { 60 m_texSubImage.setSubImageSize(tileSize); 61 } 62 63 virtual void updateTextureRect(LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect) 64 { 65 texture->bindTexture(); 66 67 // Source rect should never go outside the image pixels, even if this 68 // is requested because the texture extends outside the image. 69 IntRect clippedSourceRect = sourceRect; 70 clippedSourceRect.intersect(imageRect()); 71 72 IntRect clippedDestRect = destRect; 73 clippedDestRect.move(clippedSourceRect.location() - sourceRect.location()); 74 clippedDestRect.setSize(sourceRect.size()); 75 76 m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, context()); 77 } 78 79 private: 80 IntRect imageRect() const 81 { 82 return IntRect(IntPoint::zero(), m_image.size()); 83 } 84 85 // FIXME: ImageLayerTextureUpdater should rather own a PlatformImage rather than keeping a reference. 86 const PlatformImage& m_image; 87 LayerTextureSubImage m_texSubImage; 88 }; 43 89 44 90 PassRefPtr<ImageLayerChromium> ImageLayerChromium::create(GraphicsLayerChromium* owner) … … 81 127 m_dirtyRect = IntRect(); 82 128 } 129 m_tiler->prepareToUpdate(paintRect); 83 130 } 84 131 } … … 86 133 void ImageLayerChromium::updateCompositorResources() 87 134 { 88 IntRect paintRect(IntPoint(0, 0), m_decodedImage.size()); 89 m_tiler->updateFromPixels(paintRect, paintRect, m_decodedImage.pixels()); 135 m_tiler->updateRect(); 136 } 137 138 PassOwnPtr<LayerTextureUpdater> ImageLayerChromium::createTextureUpdater() 139 { 140 return adoptPtr(new ImageLayerTextureUpdater(layerRendererContext(), m_decodedImage, layerRenderer()->contextSupportsMapSub())); 90 141 } 91 142 -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
r86640 r86805 60 60 virtual const char* layerTypeAsString() const { return "ImageLayer"; } 61 61 62 virtual PassOwnPtr<LayerTextureUpdater> createTextureUpdater(); 62 63 virtual TransformationMatrix tilingTransform(); 63 64 virtual IntRect layerBounds() const; -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r86713 r86805 41 41 #include "GraphicsContext3D.h" 42 42 #include "LayerChromium.h" 43 #include "LayerPainterChromium.h" 43 44 #include "LayerTexture.h" 45 #include "LayerTextureUpdaterCanvas.h" 44 46 #include "NotImplemented.h" 45 47 #include "TextStream.h" … … 95 97 } 96 98 97 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr< TilePaintInterface> contentPaint)99 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<LayerPainterChromium> contentPaint) 98 100 { 99 101 if (!context) … … 108 110 109 111 LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> context, 110 PassOwnPtr< TilePaintInterface> contentPaint)112 PassOwnPtr<LayerPainterChromium> contentPaint) 111 113 : m_viewportScrollPosition(IntPoint(-1, -1)) 112 114 , m_rootLayer(0) 113 , m_rootLayerContentPaint(contentPaint)114 115 , m_currentShader(0) 115 116 , m_currentRenderSurface(0) … … 127 128 m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub"); 128 129 m_hardwareCompositing = initializeSharedObjects(); 129 m_rootLayerContentTiler = LayerTilerChromium::create(this, IntSize(256, 256), LayerTilerChromium::NoBorderTexels); 130 131 OwnPtr<LayerTextureUpdater> textureUpdater = adoptPtr(new LayerTextureUpdaterBitmap(m_context.get(), contentPaint, m_contextSupportsMapSub)); 132 m_rootLayerContentTiler = LayerTilerChromium::create(this, textureUpdater.release(), IntSize(256, 256), LayerTilerChromium::NoBorderTexels); 130 133 ASSERT(m_rootLayerContentTiler); 131 134 … … 167 170 { 168 171 TRACE_EVENT("LayerRendererChromium::updateRootLayerContents", this, 0); 169 m_rootLayerContentTiler-> update(*m_rootLayerContentPaint,m_viewportVisibleRect);172 m_rootLayerContentTiler->prepareToUpdate(m_viewportVisibleRect); 170 173 } 171 174 … … 175 178 scroll.translate(-m_viewportVisibleRect.x(), -m_viewportVisibleRect.y()); 176 179 177 m_rootLayerContentTiler->uploadCanvas();178 180 m_rootLayerContentTiler->draw(m_viewportVisibleRect, scroll, 1.0f); 179 181 } … … 219 221 220 222 LayerList renderSurfaceLayerList; 221 222 223 updateLayers(renderSurfaceLayerList); 223 224 … … 323 324 324 325 updateCompositorResourcesRecursive(m_rootLayer.get()); 326 // Update compositor resources for root layer. 327 m_rootLayerContentTiler->updateRect(); 325 328 326 329 // After updateCompositorResourcesRecursive, set/wait latches for all child -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r86652 r86805 65 65 class GeometryBinding; 66 66 class GraphicsContext3D; 67 class LayerPainterChromium; 67 68 68 69 // Class that handles drawing of composited render layers using GL. 69 70 class LayerRendererChromium : public RefCounted<LayerRendererChromium> { 70 71 public: 71 static PassRefPtr<LayerRendererChromium> create(PassRefPtr<GraphicsContext3D>, PassOwnPtr< TilePaintInterface> contentPaint);72 static PassRefPtr<LayerRendererChromium> create(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint); 72 73 73 74 ~LayerRendererChromium(); … … 152 153 RefPtr<CCLayerImpl> m_rootCCLayerImpl; 153 154 154 LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr< TilePaintInterface> contentPaint);155 LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint); 155 156 156 157 void updateLayers(LayerList& renderSurfaceLayerList); … … 192 193 193 194 RefPtr<LayerChromium> m_rootLayer; 194 OwnPtr<TilePaintInterface> m_rootLayerContentPaint;195 195 OwnPtr<LayerTilerChromium> m_rootLayerContentTiler; 196 196 -
trunk/Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.h
r86804 r86805 23 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 #ifndef TraceEvent_h26 #define TraceEvent_h27 25 28 #include "PlatformBridge.h"29 26 30 // Implementation detail: trace event macros create temporary variables 31 // to keep instrumentation overhead low. These macros give each temporary 32 // variable a unique name based on the line number to prevent name collissions. 33 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) a##b 34 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(a, b) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) 35 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(name_prefix) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(name_prefix, __LINE__) 27 #ifndef LayerTextureSubImage_h 28 #define LayerTextureSubImage_h 36 29 37 // Issues PlatformBridge::traceEventBegin and traceEventEnd calls for the enclosing scope 38 #define TRACE_EVENT(name, id, extra) WebCore::internal::ScopeTracer TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(__traceEventScope)(name, id, extra); 30 #if USE(ACCELERATED_COMPOSITING) 31 32 #include "IntRect.h" 33 #include "IntSize.h" 34 #include <wtf/OwnArrayPtr.h> 39 35 40 36 namespace WebCore { 41 37 42 namespace internal { 38 class GraphicsContext3D; 43 39 44 // Used by TRACE_EVENT macro. Do not use directly. 45 class ScopeTracer { 40 class LayerTextureSubImage { 46 41 public: 47 ScopeTracer(const char* name, void*, const char* extra); 48 ~ScopeTracer(); 42 explicit LayerTextureSubImage(bool useMapSubForUpload); 43 ~LayerTextureSubImage(); 44 45 void setSubImageSize(const IntSize&); 46 void upload(const uint8_t* image, const IntRect& imageRect, 47 const IntRect& sourceRect, const IntRect& destRect, 48 GraphicsContext3D*); 49 49 50 50 private: 51 const char* m_name; 52 void* m_id; 53 OwnArrayPtr<char> m_extra; 51 void uploadWithTexSubImage(const uint8_t* image, const IntRect& imageRect, 52 const IntRect& sourceRect, const IntRect& destRect, 53 GraphicsContext3D*); 54 void uploadWithMapTexSubImage(const uint8_t* image, const IntRect& imageRect, 55 const IntRect& sourceRect, const IntRect& destRect, 56 GraphicsContext3D*); 57 58 bool m_useMapTexSubImage; 59 IntSize m_subImageSize; 60 OwnArrayPtr<uint8_t> m_subImage; 54 61 }; 55 62 56 inline ScopeTracer::ScopeTracer(const char* name, void* id, const char* extra) 57 : m_name(name) 58 , m_id(id) 59 { 60 PlatformBridge::traceEventBegin(name, id, extra); \ 61 if (extra) 62 m_extra = adoptArrayPtr(strdup(extra)); 63 } 63 } // namespace WebCore 64 #endif // USE(ACCELERATED_COMPOSITING) 65 #endif // LayerTextureSubImage_h 64 66 65 inline ScopeTracer::~ScopeTracer()66 {67 PlatformBridge::traceEventEnd(m_name, m_id, m_extra.get());68 }69 70 } // namespace internal71 72 } // namespace WebCore73 74 #endif -
trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h
r86804 r86805 23 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 #ifndef TraceEvent_h26 #define TraceEvent_h27 25 28 #include "PlatformBridge.h"29 26 30 // Implementation detail: trace event macros create temporary variables 31 // to keep instrumentation overhead low. These macros give each temporary 32 // variable a unique name based on the line number to prevent name collissions. 33 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) a##b 34 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(a, b) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) 35 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(name_prefix) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(name_prefix, __LINE__) 27 #ifndef LayerTextureUpdater_h 28 #define LayerTextureUpdater_h 36 29 37 // Issues PlatformBridge::traceEventBegin and traceEventEnd calls for the enclosing scope 38 #define TRACE_EVENT(name, id, extra) WebCore::internal::ScopeTracer TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(__traceEventScope)(name, id, extra); 30 #if USE(ACCELERATED_COMPOSITING) 39 31 40 32 namespace WebCore { 41 33 42 namespace internal { 34 class GraphicsContext3D; 35 class IntRect; 36 class IntSize; 37 class LayerTexture; 43 38 44 // Used by TRACE_EVENT macro. Do not use directly. 45 class ScopeTracer { 39 class LayerTextureUpdater { 46 40 public: 47 ScopeTracer(const char* name, void*, const char* extra); 48 ~ScopeTracer(); 41 explicit LayerTextureUpdater(GraphicsContext3D* context) : m_context(context) { } 42 virtual ~LayerTextureUpdater() { } 43 44 enum Orientation { 45 BottomUpOrientation, 46 TopDownOrientation 47 }; 48 // Returns the orientation of the texture uploaded by this interface. 49 virtual Orientation orientation() = 0; 50 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0; 51 virtual void updateTextureRect(LayerTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0; 52 53 protected: 54 GraphicsContext3D* context() const { return m_context; } 49 55 50 56 private: 51 const char* m_name; 52 void* m_id; 53 OwnArrayPtr<char> m_extra; 57 // The graphics context with which to update textures. 58 // It is assumed that the textures are either created in the same context 59 // or shared with this context. 60 GraphicsContext3D* m_context; 54 61 }; 55 62 56 inline ScopeTracer::ScopeTracer(const char* name, void* id, const char* extra) 57 : m_name(name) 58 , m_id(id) 59 { 60 PlatformBridge::traceEventBegin(name, id, extra); \ 61 if (extra) 62 m_extra = adoptArrayPtr(strdup(extra)); 63 } 63 } // namespace WebCore 64 #endif // USE(ACCELERATED_COMPOSITING) 65 #endif // LayerTextureUpdater_h 64 66 65 inline ScopeTracer::~ScopeTracer()66 {67 PlatformBridge::traceEventEnd(m_name, m_id, m_extra.get());68 }69 70 } // namespace internal71 72 } // namespace WebCore73 74 #endif -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
r86640 r86805 36 36 #include "LayerRendererChromium.h" 37 37 #include "LayerTexture.h" 38 #include "LayerTextureUpdater.h" 38 39 #include "TraceEvent.h" 39 40 40 #include <wtf/PassOwnArrayPtr.h>41 42 41 using namespace std; 43 42 44 43 namespace WebCore { 45 44 46 PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)45 PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* layerRenderer, PassOwnPtr<LayerTextureUpdater> textureUpdater, const IntSize& tileSize, BorderTexelOption border) 47 46 { 48 47 if (!layerRenderer || tileSize.isEmpty()) 49 48 return nullptr; 50 49 51 return adoptPtr(new LayerTilerChromium(layerRenderer, t ileSize, border));52 } 53 54 LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)50 return adoptPtr(new LayerTilerChromium(layerRenderer, textureUpdater, tileSize, border)); 51 } 52 53 LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, PassOwnPtr<LayerTextureUpdater> textureUpdater, const IntSize& tileSize, BorderTexelOption border) 55 54 : m_skipsDraw(false) 56 55 , m_tilingData(max(tileSize.width(), tileSize.height()), 0, 0, border == HasBorderTexels) 57 , m_ useMapSubForUploads(layerRenderer->contextSupportsMapSub())56 , m_textureUpdater(textureUpdater) 58 57 , m_layerRenderer(layerRenderer) 59 58 { 60 59 setTileSize(tileSize); 61 }62 63 void LayerTilerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer)64 {65 if (m_layerRenderer != layerRenderer)66 reset();67 m_layerRenderer = layerRenderer;68 60 } 69 61 … … 87 79 88 80 m_tileSize = size; 89 if (!m_useMapSubForUploads)90 m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);91 81 m_tilingData.setMaxTextureSize(max(size.width(), size.height())); 92 82 } … … 231 221 } 232 222 233 void LayerTilerChromium:: update(TilePaintInterface& painter,const IntRect& contentRect)223 void LayerTilerChromium::prepareToUpdate(const IntRect& contentRect) 234 224 { 235 225 if (m_skipsDraw) … … 268 258 return; 269 259 270 m_canvas.resize(m_paintRect.size()); 271 272 // Assumption: if a tiler is using border texels, then it is because the 273 // layer is likely to be filtered or transformed. Because of it might be 274 // transformed, draw the text in grayscale instead of subpixel antialiasing. 275 PlatformCanvas::Painter::TextOption textOption = m_tilingData.borderTexels() ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText; 276 PlatformCanvas::Painter canvasPainter(&m_canvas, textOption); 277 canvasPainter.context()->translate(-m_paintRect.x(), -m_paintRect.y()); 278 { 279 TRACE_EVENT("LayerTilerChromium::update::paint", this, 0); 280 painter.paint(*canvasPainter.context(), m_paintRect); 281 } 282 } 283 284 void LayerTilerChromium::uploadCanvas() 285 { 286 PlatformCanvas::AutoLocker locker(&m_canvas); 287 { 288 TRACE_EVENT("LayerTilerChromium::updateFromPixels", this, 0); 289 updateFromPixels(m_updateRect, m_paintRect, locker.pixels()); 290 } 291 } 292 293 void LayerTilerChromium::updateFromPixels(const IntRect& contentRect, const IntRect& paintRect, const uint8_t* paintPixels) 260 m_textureUpdater->prepareToUpdate(m_paintRect, m_tileSize, m_tilingData.borderTexels()); 261 } 262 263 void LayerTilerChromium::updateRect() 294 264 { 295 265 // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. … … 300 270 301 271 int left, top, right, bottom; 302 contentRectToTileIndices( contentRect, left, top, right, bottom);272 contentRectToTileIndices(m_updateRect, left, top, right, bottom); 303 273 for (int j = top; j <= bottom; ++j) { 304 274 for (int i = left; i <= right; ++i) { … … 315 285 // Paint rect not guaranteed to line up on tile boundaries, so 316 286 // make sure that sourceRect doesn't extend outside of it. 317 sourceRect.intersect( paintRect);287 sourceRect.intersect(m_paintRect); 318 288 if (sourceRect.isEmpty()) 319 289 continue; … … 335 305 336 306 // Offset from paint rectangle to this tile's dirty rectangle. 337 IntPoint paintOffset(sourceRect.x() - paintRect.x(), sourceRect.y() -paintRect.y());307 IntPoint paintOffset(sourceRect.x() - m_paintRect.x(), sourceRect.y() - m_paintRect.y()); 338 308 if (paintOffset.x() < 0) 339 309 CRASH(); 340 310 if (paintOffset.y() < 0) 341 311 CRASH(); 342 if (paintOffset.x() + destRect.width() > paintRect.width())343 CRASH(); 344 if (paintOffset.y() + destRect.height() > paintRect.height())312 if (paintOffset.x() + destRect.width() > m_paintRect.width()) 313 CRASH(); 314 if (paintOffset.y() + destRect.height() > m_paintRect.height()) 345 315 CRASH(); 346 316 347 317 tile->texture()->bindTexture(); 348 349 318 const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; 350 319 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); 351 320 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); 352 321 353 if (m_useMapSubForUploads) { 354 // Upload tile data via a mapped transfer buffer 355 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions()); 356 uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY)); 357 ASSERT(pixelDest); 358 if (paintRect.width() == sourceRect.width() && !paintOffset.x()) 359 memcpy(pixelDest, &paintPixels[4 * paintOffset.y() * paintRect.width()], paintRect.width() * destRect.height() * 4); 360 else { 361 // Strides not equal, so do a row-by-row memcpy from the 362 // paint results into the pixelDest 363 for (int row = 0; row < destRect.height(); ++row) 364 memcpy(&pixelDest[destRect.width() * 4 * row], 365 &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())], 366 destRect.width() * 4); 367 } 368 extensions->unmapTexSubImage2DCHROMIUM(pixelDest); 369 } else { 370 const uint8_t* pixelSource; 371 if (paintRect.width() == sourceRect.width() && !paintOffset.x()) 372 pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()]; 373 else { 374 // Strides not equal, so do a row-by-row memcpy from the 375 // paint results into a temp buffer for uploading. 376 for (int row = 0; row < destRect.height(); ++row) 377 memcpy(&m_tilePixels[destRect.width() * 4 * row], 378 &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())], 379 destRect.width() * 4); 380 381 pixelSource = &m_tilePixels[0]; 382 } 383 384 385 GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource)); 386 } 387 322 m_textureUpdater->updateTextureRect(tile->texture(), sourceRect, destRect); 388 323 tile->clearDirty(); 389 324 } … … 431 366 float texScaleX = tileRect.width() / tileWidth; 432 367 float texScaleY = tileRect.height() / tileHeight; 433 368 // OpenGL coordinate system is bottom-up. 369 // If tile texture is top-down, we need to flip the texture coordinates. 370 if (m_textureUpdater->orientation() == LayerTextureUpdater::TopDownOrientation) { 371 texTranslateY += 1.0; 372 texScaleY *= -1.0; 373 } 434 374 drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, tileRect.width(), tileRect.height(), opacity, texTranslateX, texTranslateY, texScaleX, texScaleY, program); 435 375 } -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
r86640 r86805 32 32 #include "LayerChromium.h" 33 33 #include "LayerTexture.h" 34 #include "PlatformCanvas.h"35 34 #include "TilingData.h" 36 35 #include <wtf/HashTraits.h> 37 #include <wtf/OwnArrayPtr.h>38 36 #include <wtf/RefCounted.h> 39 37 … … 42 40 class GraphicsContext3D; 43 41 class LayerRendererChromium; 44 45 class TilePaintInterface { 46 public: 47 virtual void paint(GraphicsContext& context, const IntRect& contentRect) = 0; 48 }; 42 class LayerTextureUpdater; 49 43 50 44 class LayerTilerChromium { … … 53 47 enum BorderTexelOption { HasBorderTexels, NoBorderTexels }; 54 48 55 static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium*, const IntSize& tileSize, BorderTexelOption);49 static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium*, PassOwnPtr<LayerTextureUpdater>, const IntSize& tileSize, BorderTexelOption); 56 50 57 51 ~LayerTilerChromium(); … … 61 55 void invalidateEntireLayer(); 62 56 63 // Paint all invalidations and missing tiles needed to draw the contentRect 64 // into the internal canvas. 65 void update(TilePaintInterface& painter, const IntRect& contentRect); 66 67 // Reserve and upload tile textures from the internal canvas. 68 void uploadCanvas(); 69 70 // Reserve and upload tile textures from an externally painted buffer. 71 void updateFromPixels(const IntRect& contentRect, const IntRect& paintRect, const uint8_t* pixels); 72 57 // Prepare data needed to update textures that instersect with contentRect. 58 void prepareToUpdate(const IntRect& contentRect); 59 // Update invalid textures that intersect with contentRect provided in prepareToUpdate(). 60 void updateRect(); 73 61 // Draw all tiles that intersect with the content rect. 74 62 void draw(const IntRect& contentRect, const TransformationMatrix&, float opacity); … … 78 66 // Change the tile size. This may invalidate all the existing tiles. 79 67 void setTileSize(const IntSize& size); 80 void setLayerRenderer(LayerRendererChromium*);81 68 82 69 bool skipsDraw() const { return m_skipsDraw; } … … 88 75 89 76 private: 90 LayerTilerChromium(LayerRendererChromium*, const IntSize& tileSize, BorderTexelOption);77 LayerTilerChromium(LayerRendererChromium*, PassOwnPtr<LayerTextureUpdater>, const IntSize& tileSize, BorderTexelOption); 91 78 92 79 class Tile : public RefCounted<Tile> { 93 80 WTF_MAKE_NONCOPYABLE(Tile); 94 81 public: 95 explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex), m_i(-1), m_j(-1) { }82 explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex), m_i(-1), m_j(-1) { } 96 83 97 84 LayerTexture* texture() { return m_tex.get(); } … … 158 145 Vector<RefPtr<Tile> > m_unusedTiles; 159 146 160 // State held between update and upload Canvas.147 // State held between update and upload. 161 148 IntRect m_paintRect; 162 149 IntRect m_updateRect; 163 PlatformCanvas m_canvas;164 165 // Cache a tile-sized pixel buffer to draw into.166 OwnArrayPtr<uint8_t> m_tilePixels;167 150 168 151 TilingData m_tilingData; 169 152 170 // Whether the tiler will use GL_CHROMIUM_map_sub for texture uploads. 171 bool m_useMapSubForUploads; 172 153 OwnPtr<LayerTextureUpdater> m_textureUpdater; 173 154 LayerRendererChromium* m_layerRenderer; 174 155 }; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
r86788 r86805 35 35 #include "LayerRendererChromium.h" 36 36 #include "LayerTexture.h" 37 #include "PlatformCanvas.h" 37 38 #include "TextRun.h" 38 39 #include "TextStream.h" … … 116 117 extensions->unmapTexSubImage2DCHROMIUM(pixelDest); 117 118 } else 118 GLC(context .get(), context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));119 GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels())); 119 120 } 120 121 -
trunk/Source/WebKit/chromium/ChangeLog
r86799 r86805 1 2011-05-18 Alok Priyadarshi <alokp@chromium.org> and Adrienne Walker <enne@google.com> 2 3 Reviewed by James Robinson. 4 5 Split canvas from LayerTilerChromium 6 https://bugs.webkit.org/show_bug.cgi?id=60719 7 8 * src/WebViewImpl.cpp: 9 1 10 2011-05-18 Brett Wilson <brettw@chromium.org> 2 11 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r86640 r86805 73 73 #include "KeyboardCodes.h" 74 74 #include "KeyboardEvent.h" 75 #include "LayerPainterChromium.h" 75 76 #include "MIMETypeRegistry.h" 76 77 #include "NodeRenderStyle.h" … … 2410 2411 } 2411 2412 2412 class WebViewImplContentPainter : public TilePaintInterface{2413 class WebViewImplContentPainter : public LayerPainterChromium { 2413 2414 WTF_MAKE_NONCOPYABLE(WebViewImplContentPainter); 2414 2415 public:
Note: See TracChangeset
for help on using the changeset viewer.