Changeset 276945 in webkit
- Timestamp:
- May 3, 2021, 9:08:22 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
-
WebCore/platform/graphics/GraphicsContext.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (modified) (1 diff)
-
WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (modified) (6 diffs)
-
WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r275660 r276945 391 391 WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatPoint& destination, const ImagePaintingOptions& = { }); 392 392 void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const ImagePaintingOptions& = { }); 393 void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });393 WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { }); 394 394 395 395 WEBCORE_EXPORT void drawConsumingImageBuffer(RefPtr<ImageBuffer>, const FloatPoint& destination, const ImagePaintingOptions& = { }); -
trunk/Source/WebKit/ChangeLog
r276941 r276945 1 2021-05-03 Tim Horton <timothy_horton@apple.com> 2 3 Use ImageBuffer scaling in RemoteLayerBackingStore, rather than handling scale in the class 4 https://bugs.webkit.org/show_bug.cgi?id=225081 5 6 Reviewed by Said Abou-Hallawa. 7 8 No new tests, no behavior change. 9 10 * Shared/RemoteLayerTree/RemoteLayerBackingStore.h: 11 * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm: 12 (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer): 13 (WebKit::RemoteLayerBackingStore::display): 14 (WebKit::RemoteLayerBackingStore::backingStoreSize const): Deleted. 15 Make use of ImageBuffer's scaling support instead of scaling ourselves. 16 This will be helpful for future patches where the backing store's ImageBuffer 17 needs to know the presentation size, not just the backing store size. 18 We also do the back->front copy in scaled space now, which simplifies the code a bit. 19 20 We have to explicitly specify the source and destination rect for the copy, because 21 GraphicsContext::drawImageBuffer's implicit source rect is computed using 22 ImageBuffer::logicalSize(), which is a *truncated* IntSize. 23 24 * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp: 25 (WebKit::ImageBufferShareableBitmapBackend::ImageBufferShareableBitmapBackend): 26 Apply the device scale factor to the GraphicsContext that ImageBufferShareableBitmapBackend 27 adopts from ShareableBitmap. We don't need to flip because ShareableBitmap does that, 28 but it doesn't know anything about scales at all. 29 1 30 2021-05-03 Patrick Angle <pangle@apple.com> 2 31 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h
r269824 r276945 100 100 101 101 WebCore::PixelFormat pixelFormat() const; 102 WebCore::IntSize backingStoreSize() const;103 102 104 103 PlatformCALayerRemote* m_layer; -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
r274033 r276945 147 147 } 148 148 149 WebCore::IntSize RemoteLayerBackingStore::backingStoreSize() const150 {151 WebCore::FloatSize scaledSize = m_size;152 scaledSize.scale(m_scale);153 return roundedIntSize(scaledSize);154 }155 156 149 WebCore::PixelFormat RemoteLayerBackingStore::pixelFormat() const 157 150 { … … 200 193 201 194 if (WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM)) 202 m_frontBuffer.imageBuffer = m_layer->context()->ensureRemoteRenderingBackendProxy().createImageBuffer( backingStoreSize(), renderingMode, 1, WebCore::DestinationColorSpace::SRGB, pixelFormat());195 m_frontBuffer.imageBuffer = m_layer->context()->ensureRemoteRenderingBackendProxy().createImageBuffer(m_size, renderingMode, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat()); 203 196 else if (renderingMode == WebCore::RenderingMode::Accelerated) 204 m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableMappedBackend>::create( backingStoreSize(), 1, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);197 m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableMappedBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr); 205 198 else 206 m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create( backingStoreSize(), 1, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);199 m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr); 207 200 } 208 201 … … 220 213 setBufferVolatility(BufferType::Front, false); 221 214 222 WebCore::IntSize expandedScaledSize = backingStoreSize(); 223 224 if (m_dirtyRegion.isEmpty() || expandedScaledSize.isEmpty()) 215 if (m_dirtyRegion.isEmpty() || m_size.isEmpty()) 225 216 return needToEncodeBackingStore; 226 217 … … 234 225 } 235 226 236 WebCore::IntRect expandedScaledLayerBounds(WebCore::IntPoint(), expandedScaledSize);237 238 227 swapToValidFrontBuffer(); 239 228 if (!m_frontBuffer.imageBuffer) … … 241 230 242 231 WebCore::GraphicsContext& context = m_frontBuffer.imageBuffer->context(); 243 244 232 WebCore::GraphicsContextStateSaver stateSaver(context); 245 246 WebCore::FloatSize scaledSize = m_size;247 scaledSize.scale(m_scale);248 WebCore::IntRect scaledLayerBounds(WebCore::IntPoint(), WebCore::roundedIntSize(scaledSize));249 233 250 234 // If we have less than webLayerMaxRectsToPaint rects to paint and they cover less … … 270 254 if (!m_dirtyRegion.contains(layerBounds)) { 271 255 ASSERT(m_backBuffer.imageBuffer); 272 context.drawImageBuffer(*m_backBuffer.imageBuffer, { 0, 0 }, { WebCore::CompositeOperator::Copy }); 273 } 274 275 if (m_paintingRects.size() == 1) { 276 WebCore::FloatRect scaledPaintingRect = m_paintingRects[0]; 277 scaledPaintingRect.scale(m_scale); 278 context.clip(scaledPaintingRect); 279 } else { 256 context.drawImageBuffer(*m_backBuffer.imageBuffer, { {0, 0}, m_size }, { {0, 0}, m_size }, { WebCore::CompositeOperator::Copy }); 257 } 258 259 if (m_paintingRects.size() == 1) 260 context.clip(m_paintingRects[0]); 261 else { 280 262 WebCore::Path clipPath; 281 for (auto rect : m_paintingRects) { 282 rect.scale(m_scale); 263 for (auto rect : m_paintingRects) 283 264 clipPath.addRect(rect); 284 }285 265 context.clipPath(clipPath); 286 266 } 287 267 288 268 if (!m_isOpaque) 289 context.clearRect( scaledLayerBounds);269 context.clearRect(layerBounds); 290 270 291 271 #ifndef NDEBUG 292 272 if (m_isOpaque) 293 context.fillRect( scaledLayerBounds, WebCore::SRGBA<uint8_t> { 255, 47, 146 });273 context.fillRect(layerBounds, WebCore::SRGBA<uint8_t> { 255, 47, 146 }); 294 274 #endif 295 275 296 context.scale(m_scale);297 298 276 // FIXME: Clarify that WebCore::GraphicsLayerPaintSnapshotting is just about image decoding. 299 277 auto flags = m_layer->context() && m_layer->context()->nextRenderingUpdateRequiresSynchronousImageDecoding() ? WebCore::GraphicsLayerPaintSnapshotting : WebCore::GraphicsLayerPaintNormal; -
trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp
r275905 r276945 125 125 , m_context(WTFMove(context)) 126 126 { 127 // ShareableBitmap ensures that the coordinate space in the context that we're adopting 128 // has a top-left origin, so we don't ever need to flip here, so we don't call setupContext(). 129 // However, ShareableBitmap does not have a notion of scale, so we must apply the device 130 // scale factor to the context ourselves. 131 m_context->applyDeviceScaleFactor(resolutionScale()); 127 132 } 128 133
Note:
See TracChangeset
for help on using the changeset viewer.