Changeset 249414 in webkit
- Timestamp:
- Sep 2, 2019 2:37:06 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249378 r249414 1 2019-09-02 Brent Fulgham <bfulgham@apple.com> 2 3 [FTW] NativeImagePtr is drawn with invalid scaling 4 https://bugs.webkit.org/show_bug.cgi?id=201391 5 6 Reviewed by Don Olmstead. 7 8 The current implementation of FTW improperly applies scaling factors to native images, 9 resulting in blocky images (in some cases). 10 11 This patch corrects the handling of native images, corrects a bug in bitmap render 12 context scaling, and retrieves more data from the ImageDecoder's metadata system. 13 14 * platform/graphics/win/Direct2DUtilities.cpp: 15 (WebCore::Direct2D::createBitmapRenderTargetOfSize): Supply an appropriately sized 16 pixel dimension for non-unity scale factors. 17 * platform/graphics/win/ImageBufferDirect2D.cpp: 18 (WebCore::ImageBuffer::ImageBuffer): Include the scale factor when creating a 19 bitmap render target. 20 * platform/graphics/win/ImageDecoderDirect2D.cpp: 21 (WebCore::ImageDecoderDirect2D::frameOrientationAtIndex const): Read the orientation 22 data form the image metadata. 23 (WebCore::ImageDecoderDirect2D::frameAllowSubsamplingAtIndex const): Always return 24 true, to match the CG implementation. 25 (WebCore::ImageDecoderDirect2D::frameHasAlphaAtIndex const): Correct to match the 26 behavior of CG. 27 * platform/graphics/win/NativeImageDirect2D.cpp: 28 (WebCore::drawNativeImage): Pass through the Direct2DOperations helper method, which 29 handles scaling and subsampling properly. 30 1 31 2019-09-02 Youenn Fablet <youenn@apple.com> 2 32 -
trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp
r249335 r249414 225 225 COMPtr<ID2D1BitmapRenderTarget> bitmapContext; 226 226 auto desiredSize = D2D1::SizeF(size.width(), size.height()); 227 D2D1_SIZE_U pixelSize = size;227 D2D1_SIZE_U pixelSize = D2D1::SizeU(clampTo<unsigned>(deviceScaleFactor * size.width()), clampTo<unsigned>(deviceScaleFactor * size.height())); 228 228 HRESULT hr = renderTarget->CreateCompatibleRenderTarget(&desiredSize, &pixelSize, nullptr, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_GDI_COMPATIBLE, &bitmapContext); 229 229 if (!SUCCEEDED(hr)) -
trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp
r249371 r249414 108 108 renderTarget = GraphicsContext::defaultRenderTarget(); 109 109 110 D2D1_SIZE_F desiredSize = FloatSize(m_logicalSize); 111 D2D1_SIZE_U pixelSize = IntSize(m_logicalSize); 112 113 auto bitmapContext = Direct2D::createBitmapRenderTargetOfSize(m_logicalSize, renderTarget); 110 auto bitmapContext = Direct2D::createBitmapRenderTargetOfSize(m_logicalSize, renderTarget, m_resolutionScale); 114 111 if (!bitmapContext) 115 112 return; -
trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp
r249110 r249414 172 172 return ImageOrientation::None; 173 173 174 // FIXME: Identify image type, and ask proper orientation. 174 PROPVARIANT value; 175 PropVariantInit(&value); 176 hr = metadata->GetMetadataByName(L"System.Photo.Orientation", &value); 177 if (SUCCEEDED(hr)) 178 return ImageOrientation(static_cast<ImageOrientation::Orientation>(value.uiVal)); 179 175 180 return ImageOrientation::None; 176 181 } … … 193 198 bool ImageDecoderDirect2D::frameAllowSubsamplingAtIndex(size_t index) const 194 199 { 195 if (!m_nativeDecoder)196 return false;197 198 COMPtr<IWICBitmapFrameDecode> frame;199 HRESULT hr = m_nativeDecoder->GetFrame(index, &frame);200 if (!SUCCEEDED(hr))201 return false;202 203 // FIXME: Figure out correct image format-specific query for subsampling check.204 notImplemented();205 200 return true; 206 201 } … … 216 211 return false; 217 212 218 // FIXME: Figure out correct image format-specific query for alpha check. 219 notImplemented(); 213 COMPtr<IWICMetadataQueryReader> metadata; 214 hr = frame->GetMetadataQueryReader(&metadata); 215 if (!SUCCEEDED(hr)) 216 return false; 217 218 GUID containerFormat; 219 hr = metadata->GetContainerFormat(&containerFormat); 220 if (!SUCCEEDED(hr)) 221 return false; 222 223 if (::IsEqualGUID(GUID_ContainerFormatJpeg, containerFormat)) 224 return false; 225 220 226 return true; 221 227 } -
trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp
r249217 r249414 28 28 29 29 #include "Color.h" 30 #include "Direct2DOperations.h" 30 31 #include "FloatRect.h" 31 32 #include "GeometryUtilities.h" … … 79 80 } 80 81 81 void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& )82 void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options) 82 83 { 83 auto platformContext = context.platformContext();84 auto* platformContext = context.platformContext(); 84 85 85 86 // Subsampling may have given us an image that is smaller than size(). … … 91 92 adjustedSrcRect = mapRect(srcRect, FloatRect({ }, srcSize), FloatRect({ }, subsampledImageSize)); 92 93 93 float opacity = 1.0f; 94 95 platformContext->renderTarget()->DrawBitmap(image.get(), destRect, opacity, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, adjustedSrcRect); 94 auto& state = context.state(); 95 Direct2D::drawNativeImage(*platformContext, image.get(), subsampledImageSize, destRect, adjustedSrcRect, options, state.alpha, Direct2D::ShadowState(state)); 96 96 } 97 97
Note: See TracChangeset
for help on using the changeset viewer.