Changeset 221149 in webkit
- Timestamp:
- Aug 24, 2017 11:11:16 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221138 r221149 1 2017-08-24 Tim Horton <timothy_horton@apple.com> 2 3 _WKThumbnailView snapshots have to be copied by CA on first commit due to bad row alignment 4 https://bugs.webkit.org/show_bug.cgi?id=175898 5 <rdar://problem/34029673> 6 7 Reviewed by Sam Weinig. 8 9 In order to avoid copying, CGImages used as layer contents need to have certain 10 alignment requirements fulfilled. Align the row stride to the desired value. 11 12 * Shared/ShareableBitmap.cpp: 13 (WebKit::ShareableBitmap::create): 14 (WebKit::ShareableBitmap::createShareable): 15 (WebKit::ShareableBitmap::numBytesForSize): 16 (WebKit::ShareableBitmap::calculateBytesPerPixel): Deleted. 17 * Shared/ShareableBitmap.h: 18 (WebKit::ShareableBitmap::sizeInBytes const): 19 (WebKit::ShareableBitmap::numBytesForSize): Deleted. 20 Merge the interfaces of numBytesPerSize and sizeInBytes between the platforms. 21 numBytesForSize now makes use of the new calculateBytesPerRow, which is 22 implemented by each platform ShareableBitmap implementation to do the 23 requisite alignment for that platform. 24 25 * Shared/cairo/ShareableBitmapCairo.cpp: 26 (WebKit::ShareableBitmap::calculateBytesPerRow): 27 (WebKit::ShareableBitmap::calculateBytesPerPixel): 28 (WebKit::createSurfaceFromData): 29 (WebKit::ShareableBitmap::numBytesForSize): Deleted. 30 Implement calculateBytesPerRow (which used to be hidden inside of numBytesForSize) 31 and get rid of the now-duplicative numBytesForSize. 32 33 * Shared/cg/ShareableBitmapCG.cpp: 34 (WebKit::ShareableBitmap::calculateBytesPerRow): 35 (WebKit::ShareableBitmap::createGraphicsContext): 36 (WebKit::ShareableBitmap::createCGImage const): 37 Implement calculateBytesPerRow and make use of it when providing a row stride 38 to CoreGraphics. 39 1 40 2017-08-24 Chris Dumez <cdumez@apple.com> 2 41 -
trunk/Source/WebKit/Shared/ShareableBitmap.cpp
r221068 r221149 85 85 RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Configuration configuration) 86 86 { 87 auto numBytes = numBytesForSize(size, c alculateBytesPerPixel(configuration));87 auto numBytes = numBytesForSize(size, configuration); 88 88 if (numBytes.hasOverflowed()) 89 89 return nullptr; … … 98 98 RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Configuration configuration) 99 99 { 100 auto numBytes = numBytesForSize(size, c alculateBytesPerPixel(configuration));100 auto numBytes = numBytesForSize(size, configuration); 101 101 if (numBytes.hasOverflowed()) 102 102 return nullptr; … … 113 113 ASSERT(sharedMemory); 114 114 115 auto numBytes = numBytesForSize(size, c alculateBytesPerPixel(configuration));115 auto numBytes = numBytesForSize(size, configuration); 116 116 if (numBytes.hasOverflowed()) 117 117 return nullptr; … … 175 175 } 176 176 177 #if !USE(CG) 178 unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration&) 177 Checked<unsigned, RecordOverflow> ShareableBitmap::numBytesForSize(WebCore::IntSize size, const ShareableBitmap::Configuration& configuration) 179 178 { 180 return 4;179 return calculateBytesPerRow(size, configuration) * size.height(); 181 180 } 182 #endif183 181 184 182 } // namespace WebKit -
trunk/Source/WebKit/Shared/ShareableBitmap.h
r221068 r221149 130 130 ShareableBitmap(const WebCore::IntSize&, Configuration, RefPtr<SharedMemory>); 131 131 132 #if USE(CAIRO) 133 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize&); 134 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return numBytesForSize(size); } 135 #else 136 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return size.area<RecordOverflow>() * bytesPerPixel; } 137 #endif 132 static Checked<unsigned, RecordOverflow> numBytesForSize(WebCore::IntSize, const ShareableBitmap::Configuration&); 133 static Checked<unsigned, RecordOverflow> calculateBytesPerRow(WebCore::IntSize, const Configuration&); 134 static unsigned calculateBytesPerPixel(const Configuration&); 138 135 139 136 #if USE(CG) … … 148 145 149 146 void* data() const; 150 #if USE(CAIRO) 151 size_t sizeInBytes() const { return numBytesForSize(m_size).unsafeGet(); } 152 #else 153 size_t sizeInBytes() const { return numBytesForSize(m_size, calculateBytesPerPixel(m_configuration)).unsafeGet(); } 154 #endif 155 156 static unsigned calculateBytesPerPixel(const Configuration&); 147 size_t sizeInBytes() const { return numBytesForSize(m_size, m_configuration).unsafeGet(); } 157 148 158 149 WebCore::IntSize m_size; -
trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp
r216833 r221149 41 41 static const cairo_format_t cairoFormat = CAIRO_FORMAT_ARGB32; 42 42 43 Checked<unsigned, RecordOverflow> ShareableBitmap:: numBytesForSize(const WebCore::IntSize& size)43 Checked<unsigned, RecordOverflow> ShareableBitmap::calculateBytesPerRow(WebCore::IntSize size, const Configuration&) 44 44 { 45 return Checked<unsigned, RecordOverflow>(cairo_format_stride_for_width(cairoFormat, size.width())) * size.height(); 45 return cairo_format_stride_for_width(cairoFormat, size.width()); 46 } 47 48 unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration&) 49 { 50 return 4; 46 51 } 47 52 -
trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp
r221068 r221149 31 31 #include <WebCore/PlatformScreen.h> 32 32 #include <pal/spi/cg/CoreGraphicsSPI.h> 33 #include <pal/spi/cocoa/IOSurfaceSPI.h> 33 34 #include <wtf/RetainPtr.h> 34 35 #include "CGUtilities.h" … … 75 76 } 76 77 78 Checked<unsigned, RecordOverflow> ShareableBitmap::calculateBytesPerRow(WebCore::IntSize size, const Configuration& configuration) 79 { 80 unsigned bytesPerRow = calculateBytesPerPixel(configuration) * size.width(); 81 #if USE(IOSURFACE) 82 return IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, bytesPerRow); 83 #else 84 return bytesPerRow; 85 #endif 86 } 87 77 88 unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration& configuration) 78 89 { … … 85 96 86 97 unsigned bytesPerPixel = calculateBytesPerPixel(m_configuration); 87 RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), bytesPerPixel * 8 / 4, m_size.width() * bytesPerPixel, colorSpace(m_configuration), bitmapInfo(m_configuration), releaseBitmapContextData, this));98 RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), bytesPerPixel * 8 / 4, calculateBytesPerRow(m_size, m_configuration).unsafeGet(), colorSpace(m_configuration), bitmapInfo(m_configuration), releaseBitmapContextData, this)); 88 99 89 100 ASSERT(bitmapContext.get()); … … 124 135 ASSERT_ARG(dataProvider, dataProvider); 125 136 unsigned bytesPerPixel = calculateBytesPerPixel(m_configuration); 126 RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), bytesPerPixel * 8 / 4, bytesPerPixel * 8, m_size.width() * bytesPerPixel, colorSpace(m_configuration), bitmapInfo(m_configuration), dataProvider, 0, false, kCGRenderingIntentDefault));137 RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), bytesPerPixel * 8 / 4, bytesPerPixel * 8, calculateBytesPerRow(m_size, m_configuration).unsafeGet(), colorSpace(m_configuration), bitmapInfo(m_configuration), dataProvider, 0, false, kCGRenderingIntentDefault)); 127 138 return image; 128 139 }
Note: See TracChangeset
for help on using the changeset viewer.