Changeset 151262 in webkit
- Timestamp:
- Jun 6, 2013 2:43:20 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r151259 r151262 1 2013-06-06 Jae Hyun Park <jae.park@company100.net> 2 3 Coordinated Graphics : Refactor CoordinatedSurface to manage the lifecycle of GraphicsContext 4 https://bugs.webkit.org/show_bug.cgi?id=108899 5 6 Reviewed by Noam Rosenthal. 7 8 This is a preparation patch for Threaded Coordinated Graphics. 9 10 This patch changes CoordinatedSurface to be responsible for the 11 lifecycle of GraphicsContext used in Coordinated Graphics System. 12 CoordinatedImageBacking and UpdateAtlas do not ask for the ownership 13 of GraphicsContext anymore. Instead, those classes use client pattern to 14 ask the CoordiantedSurface to paint to the GraphicsContext. 15 16 This refactoring is needed to implement CoordinatedSurface for Threaded 17 Coordinated Graphics. 18 19 No new tests, covered by existing tests. 20 21 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: 22 (WebCore::CoordinatedGraphicsLayer::paintToSurface): 23 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h: 24 * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp: 25 (WebCore::ImageBackingSurfaceClient::ImageBackingSurfaceClient): 26 (WebCore::CoordinatedImageBacking::update): 27 * platform/graphics/texmap/coordinated/CoordinatedSurface.h: 28 (WebCore::CoordinatedSurface::Client::~Client): 29 * platform/graphics/texmap/coordinated/CoordinatedTile.cpp: 30 (WebCore::CoordinatedTile::updateBackBuffer): 31 (WebCore::CoordinatedTile::paintToSurfaceContext): 32 * platform/graphics/texmap/coordinated/CoordinatedTile.h: 33 * platform/graphics/texmap/coordinated/UpdateAtlas.cpp: 34 (WebCore::UpdateAtlasSurfaceClient::UpdateAtlasSurfaceClient): 35 (WebCore::UpdateAtlas::paintOnAvailableBuffer): 36 * platform/graphics/texmap/coordinated/UpdateAtlas.h: 37 1 38 2013-06-05 Ryosuke Niwa <rniwa@webkit.org> 2 39 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
r151220 r151262 960 960 } 961 961 962 PassOwnPtr<GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const IntSize& size, uint32_t& atlas, IntPoint& offset)962 bool CoordinatedGraphicsLayer::paintToSurface(const IntSize& size, uint32_t& atlas, IntPoint& offset, CoordinatedSurface::Client* client) 963 963 { 964 964 ASSERT(m_coordinator); 965 965 ASSERT(m_coordinator->isFlushingLayerChanges()); 966 return m_coordinator-> beginContentUpdate(size, contentsOpaque() ? CoordinatedSurface::NoFlags : CoordinatedSurface::SupportsAlpha, atlas, offset);966 return m_coordinator->paintToSurface(size, contentsOpaque() ? CoordinatedSurface::NoFlags : CoordinatedSurface::SupportsAlpha, atlas, offset, client); 967 967 } 968 968 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
r151220 r151262 53 53 virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0; 54 54 virtual void detachLayer(CoordinatedGraphicsLayer*) = 0; 55 virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&) = 0;55 virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0; 56 56 57 57 virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) = 0; … … 143 143 virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) OVERRIDE; 144 144 virtual void removeTile(uint32_t tileID) OVERRIDE; 145 virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, uint32_t& atlasID, IntPoint&) OVERRIDE;145 virtual bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client*) OVERRIDE; 146 146 147 147 void setCoordinator(CoordinatedGraphicsLayerClient*); -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
r151214 r151262 33 33 34 34 namespace WebCore { 35 36 class ImageBackingSurfaceClient : public CoordinatedSurface::Client { 37 public: 38 ImageBackingSurfaceClient(Image* image, const IntRect& rect) 39 : m_image(image) 40 , m_rect(rect) 41 { 42 } 43 44 virtual void paintToSurfaceContext(GraphicsContext* context) OVERRIDE 45 { 46 context->drawImage(m_image, ColorSpaceDeviceRGB, m_rect, m_rect); 47 } 48 49 private: 50 Image* m_image; 51 IntRect m_rect; 52 }; 35 53 36 54 CoordinatedImageBackingID CoordinatedImageBacking::getCoordinatedImageBackingID(Image* image) … … 110 128 111 129 IntRect rect(IntPoint::zero(), m_image->size()); 112 OwnPtr<GraphicsContext> context = m_surface->createGraphicsContext(rect); 113 context->drawImage(m_image.get(), ColorSpaceDeviceRGB, rect, rect); 130 131 ImageBackingSurfaceClient surfaceClient(m_image.get(), rect); 132 m_surface->paintToSurface(rect, &surfaceClient); 114 133 115 134 m_nativeImagePtr = m_image->nativeImageForCurrentFrame(); -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h
r141543 r151262 40 40 typedef unsigned Flags; 41 41 42 class Client { 43 public: 44 virtual ~Client() { } 45 virtual void paintToSurfaceContext(GraphicsContext*) = 0; 46 }; 47 42 48 typedef PassRefPtr<CoordinatedSurface> Factory(const IntSize&, Flags); 43 49 static void setFactory(Factory); … … 49 55 virtual IntSize size() const = 0; 50 56 51 // Create a graphics context that can be used to paint into the backing store. 52 virtual PassOwnPtr<GraphicsContext> createGraphicsContext(const IntRect&) = 0; 57 virtual void paintToSurface(const IntRect&, Client*) = 0; 53 58 54 59 #if USE(TEXTURE_MAPPER) -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp
r141543 r151262 74 74 75 75 SurfaceUpdateInfo updateInfo; 76 OwnPtr<GraphicsContext> graphicsContext = m_client->beginContentUpdate(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset); 77 if (! graphicsContext)76 77 if (!m_client->paintToSurface(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset, this)) 78 78 return Vector<IntRect>(); 79 graphicsContext->translate(-m_dirtyRect.x(), -m_dirtyRect.y());80 graphicsContext->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale()));81 m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(m_dirtyRect));82 79 83 80 updateInfo.updateRect = m_dirtyRect; 84 81 updateInfo.updateRect.move(-m_rect.x(), -m_rect.y()); 85 82 updateInfo.scaleFactor = m_tiledBackingStore->contentsScale(); 86 graphicsContext.release();87 83 88 84 static uint32_t id = 1; … … 100 96 m_dirtyRect = IntRect(); 101 97 return updatedRects; 98 } 99 100 void CoordinatedTile::paintToSurfaceContext(GraphicsContext* context) 101 { 102 context->translate(-m_dirtyRect.x(), -m_dirtyRect.y()); 103 context->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale())); 104 m_tiledBackingStore->client()->tiledBackingStorePaint(context, m_tiledBackingStore->mapToContents(m_dirtyRect)); 102 105 } 103 106 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h
r141543 r151262 29 29 #if USE(TILED_BACKING_STORE) 30 30 31 #include "CoordinatedSurface.h" 31 32 #include "IntRect.h" 32 33 #include "Tile.h" … … 40 41 class TiledBackingStore; 41 42 42 class CoordinatedTile : public Tile {43 class CoordinatedTile : public Tile, public CoordinatedSurface::Client { 43 44 public: 44 45 static PassRefPtr<Tile> create(CoordinatedTileClient* client, TiledBackingStore* tiledBackingStore, const Coordinate& tileCoordinate) { return adoptRef(new CoordinatedTile(client, tiledBackingStore, tileCoordinate)); } … … 55 56 const IntRect& rect() const { return m_rect; } 56 57 void resize(const IntSize&); 58 59 virtual void paintToSurfaceContext(GraphicsContext*) OVERRIDE; 57 60 58 61 private: … … 76 79 virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0; 77 80 virtual void removeTile(uint32_t tileID) = 0; 78 virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, uint32_t& atlasID, IntPoint&) = 0;81 virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0; 79 82 }; 80 83 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp
r151214 r151262 31 31 namespace WebCore { 32 32 33 class UpdateAtlasSurfaceClient : public CoordinatedSurface::Client { 34 public: 35 UpdateAtlasSurfaceClient(CoordinatedSurface::Client* client, const IntSize& size, bool supportsAlpha) 36 : m_client(client) 37 , m_size(size) 38 , m_supportsAlpha(supportsAlpha) 39 { 40 } 41 42 virtual void paintToSurfaceContext(GraphicsContext* context) OVERRIDE 43 { 44 if (m_supportsAlpha) { 45 context->setCompositeOperation(CompositeCopy); 46 context->fillRect(IntRect(IntPoint::zero(), m_size), Color::transparent, ColorSpaceDeviceRGB); 47 context->setCompositeOperation(CompositeSourceOver); 48 } 49 50 m_client->paintToSurfaceContext(context); 51 } 52 53 private: 54 CoordinatedSurface::Client* m_client; 55 IntSize m_size; 56 bool m_supportsAlpha; 57 }; 58 33 59 UpdateAtlas::UpdateAtlas(Client* client, int dimension, CoordinatedSurface::Flags flags) 34 60 : m_client(client) … … 62 88 } 63 89 64 PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(uint32_t& atlasID, const IntSize& size, IntPoint& offset) 90 91 bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client) 65 92 { 66 93 m_inactivityInSeconds = 0; … … 68 95 IntRect rect = m_areaAllocator->allocate(size); 69 96 70 // No available buffer was found , returning null.97 // No available buffer was found. 71 98 if (rect.isEmpty()) 72 return PassOwnPtr<GraphicsContext>();99 return false; 73 100 74 101 if (!m_surface) 75 return PassOwnPtr<GraphicsContext>();102 return false; 76 103 77 104 atlasID = m_ID; … … 79 106 // FIXME: Use tri-state buffers, to allow faster updates. 80 107 offset = rect.location(); 81 OwnPtr<GraphicsContext> graphicsContext = m_surface->createGraphicsContext(rect);82 108 83 if (supportsAlpha()) { 84 graphicsContext->setCompositeOperation(CompositeCopy); 85 graphicsContext->fillRect(IntRect(IntPoint::zero(), size), Color::transparent, ColorSpaceDeviceRGB); 86 graphicsContext->setCompositeOperation(CompositeSourceOver); 87 } 109 UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha()); 110 m_surface->paintToSurface(rect, &surfaceClient); 88 111 89 return graphicsContext.release();112 return true; 90 113 } 91 114 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h
r151214 r151262 46 46 inline IntSize size() const { return m_surface->size(); } 47 47 48 // Returns a null pointer of there is no available buffer.49 PassOwnPtr<GraphicsContext> beginPaintingOnAvailableBuffer(uint32_t& atlasID, const IntSize&, IntPoint& offset);48 // Returns false if there is no available buffer. 49 bool paintOnAvailableBuffer(const IntSize&, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client*); 50 50 void didSwapBuffers(); 51 51 bool supportsAlpha() const { return m_surface->supportsAlpha(); } -
trunk/Source/WebKit2/ChangeLog
r151251 r151262 1 2013-06-06 Jae Hyun Park <jae.park@company100.net> 2 3 Coordinated Graphics : Refactor CoordinatedSurface to manage the lifecycle of GraphicsContext 4 https://bugs.webkit.org/show_bug.cgi?id=108899 5 6 Reviewed by Noam Rosenthal. 7 8 This is a preparation patch for Threaded Coordinated Graphics. 9 10 This patch changes CoordinatedSurface to be responsible for the 11 lifecycle of GraphicsContext used in Coordinated Graphics System. 12 CoordinatedImageBacking and UpdateAtlas do not ask for the ownership 13 of GraphicsContext anymore. Instead, those classes use client pattern to 14 ask the CoordiantedSurface to paint to the GraphicsContext. 15 16 This refactoring is needed to implement CoordinatedSurface for Threaded 17 Coordinated Graphics. 18 19 * Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp: 20 (WebKit::WebCoordinatedSurface::paintToSurface): 21 * Shared/CoordinatedGraphics/WebCoordinatedSurface.h: 22 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: 23 (WebKit::CoordinatedLayerTreeHost::paintToSurface): 24 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: 25 1 26 2013-06-05 Kangil Han <kangil.han@samsung.com> 2 27 -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp
r141632 r151262 184 184 } 185 185 186 void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client) 187 { 188 ASSERT(client); 189 190 OwnPtr<GraphicsContext> context = createGraphicsContext(rect); 191 client->paintToSurfaceContext(context.get()); 192 } 193 186 194 #if USE(TEXTURE_MAPPER) 187 195 void WebCoordinatedSurface::copyToTexture(PassRefPtr<WebCore::BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset) -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h
r141632 r151262 74 74 virtual WebCore::IntSize size() const OVERRIDE { return m_size; } 75 75 76 virtual PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(const WebCore::IntRect&) OVERRIDE;76 virtual void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) OVERRIDE; 77 77 78 78 #if USE(TEXTURE_MAPPER) … … 88 88 static PassRefPtr<WebCoordinatedSurface> create(const WebCore::IntSize&, Flags, PassRefPtr<ShareableBitmap>); 89 89 90 PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(const WebCore::IntRect&); 90 91 #if USE(GRAPHICS_SURFACE) 91 92 WebCoordinatedSurface(const WebCore::IntSize&, Flags, PassRefPtr<WebCore::GraphicsSurface>); -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
r151220 r151262 671 671 } 672 672 673 PassOwnPtr<GraphicsContext> CoordinatedLayerTreeHost::beginContentUpdate(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset) 674 { 675 OwnPtr<GraphicsContext> graphicsContext; 673 bool CoordinatedLayerTreeHost::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client) 674 { 676 675 for (unsigned i = 0; i < m_updateAtlases.size(); ++i) { 677 676 UpdateAtlas* atlas = m_updateAtlases[i].get(); 678 677 if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) { 679 // This will return null if there is no available buffer space. 680 graphicsContext = atlas->beginPaintingOnAvailableBuffer(atlasID, size, offset); 681 if (graphicsContext) 682 return graphicsContext.release(); 678 // This will false if there is no available buffer space. 679 if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client)) 680 return true; 683 681 } 684 682 } … … 687 685 m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags))); 688 686 scheduleReleaseInactiveAtlases(); 689 return m_updateAtlases.last()-> beginPaintingOnAvailableBuffer(atlasID, size, offset);687 return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client); 690 688 } 691 689 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
r151214 r151262 125 125 virtual PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE; 126 126 virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*); 127 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&);127 virtual bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) OVERRIDE; 128 128 virtual void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&); 129 129
Note: See TracChangeset
for help on using the changeset viewer.