Changeset 161577 in webkit
- Timestamp:
- Jan 9, 2014 1:21:53 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161573 r161577 1 2014-01-09 Brian Burg <bburg@apple.com> 2 3 REGRESSION (r160152): Selection drag snapshot doesn't appear or has the wrong content on Retina 4 https://bugs.webkit.org/show_bug.cgi?id=125375 5 6 Reviewed by Darin Adler. 7 8 Move scaling of drag images by the device scale factor out of DragClient 9 and into WebCore. This removes several redundant copies and scaling operations. 10 11 Fix scaling bugs that were cancelled out by over-allocating the backing store. 12 13 * page/DragController.cpp: 14 (WebCore::DragController::startDrag): Scale the drag image for a link 15 according to the device scale factor before giving it to the OS. 16 17 (WebCore::DragController::doImageDrag): Scale the drag image for an image 18 according to the device scale factor before giving it to the OS. 19 20 * page/FrameSnapshotting.cpp: 21 (WebCore::snapshotFrameRect): Don't pre-scale or clip the snapshot. The 22 ImageBuffer does this already. 23 24 * platform/DragImage.cpp: 25 (WebCore::createDragImageFromSnapshot): Don't scale the backing store 26 when copying an ImageBuffer into an Image. 27 28 * platform/graphics/cg/ImageBufferCG.cpp: 29 (WebCore::ImageBuffer::copyImage): Draw the image in user-space coordinates, 30 not in backing-store coordinates. Remove unnecessary assertions. Crop the 31 buffer before drawing the image into it. 32 1 33 2014-01-09 Myles C. Maxfield <mmaxfield@apple.com> 2 34 -
trunk/Source/WebCore/page/DragController.cpp
r161537 r161577 829 829 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); 830 830 dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y()); 831 // Later code expects the drag image to be scaled by device's scale factor. 832 dragImage = scaleDragImage(dragImage, FloatSize(m_page.deviceScaleFactor(), m_page.deviceScaleFactor())); 831 833 } 832 834 doSystemDrag(dragImage, dragLoc, mouseDraggedPoint, clipboard, src, true); … … 870 872 IntSize fittedSize = dragImageSize(dragImage); 871 873 874 dragImage = scaleDragImage(dragImage, FloatSize(m_page.deviceScaleFactor(), m_page.deviceScaleFactor())); 872 875 dragImage = dissolveDragImageToFraction(dragImage, DragImageAlpha); 873 876 -
trunk/Source/WebCore/page/FrameSnapshotting.cpp
r160152 r161577 91 91 frame.view()->setPaintBehavior(paintBehavior); 92 92 93 float deviceScaleFactor = frame.page()->deviceScaleFactor(); 94 IntRect usedRect(imageRect); 95 usedRect.scale(deviceScaleFactor); 96 97 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(usedRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB); 93 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), frame.page()->deviceScaleFactor(), ColorSpaceDeviceRGB); 98 94 if (!buffer) 99 95 return nullptr; 100 buffer->context()->translate(-usedRect.x(), -usedRect.y()); 101 buffer->context()->clip(FloatRect(0, 0, usedRect.maxX(), usedRect.maxY())); 96 buffer->context()->translate(-imageRect.x(), -imageRect.y()); 102 97 103 frame.view()->paintContentsForSnapshot(buffer->context(), usedRect, shouldIncludeSelection, coordinateSpace);98 frame.view()->paintContentsForSnapshot(buffer->context(), imageRect, shouldIncludeSelection, coordinateSpace); 104 99 return buffer; 105 100 } -
trunk/Source/WebCore/platform/DragImage.cpp
r161537 r161577 109 109 UNUSED_PARAM(node); 110 110 #endif 111 RefPtr<Image> image = snapshot->copyImage(ImageBuffer::fastCopyImageMode() );111 RefPtr<Image> image = snapshot->copyImage(ImageBuffer::fastCopyImageMode(), Unscaled); 112 112 if (!image) 113 113 return nullptr; -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
r161001 r161577 213 213 { 214 214 RetainPtr<CGImageRef> image; 215 if (m_resolutionScale == 1 || scaleBehavior == Unscaled) 215 if (m_resolutionScale == 1 || scaleBehavior == Unscaled) { 216 216 image = copyNativeImage(copyBehavior); 217 else { 217 image = createCroppedImageIfNecessary(image.get(), internalSize()); 218 } else { 218 219 image = copyNativeImage(DontCopyBackingStore); 219 220 RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast)); 220 221 CGContextSetBlendMode(context.get(), kCGBlendModeCopy); 221 CGContextDrawImage(context.get(), CGRectMake(0, 0, m_data.m_backingStoreSize.width(), m_data.m_backingStoreSize.height()), image.get()); 222 CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize())); 223 FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize(), m_data.m_backingStoreSize, internalSize()); 224 CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get()); 222 225 image = adoptCF(CGBitmapContextCreateImage(context.get())); 223 226 } 224 225 image = createCroppedImageIfNecessary(image.get(), internalSize());226 227 227 228 if (!image) 228 return 0; 229 230 ASSERT(CGImageGetWidth(image.get()) == static_cast<size_t>(m_logicalSize.width())); 231 ASSERT(CGImageGetHeight(image.get()) == static_cast<size_t>(m_logicalSize.height())); 229 return nullptr; 232 230 233 231 RefPtr<BitmapImage> bitmapImage = BitmapImage::create(image.get()); … … 481 479 CGContextSetBlendMode(context.get(), kCGBlendModeCopy); 482 480 CGContextClipToRect(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height())); 483 FloatSize image RectInUserBounds= scaleSizeToUserSpace(logicalSize(), m_data.m_backingStoreSize, internalSize());484 CGContextDrawImage(context.get(), CGRectMake(0, 0, image RectInUserBounds.width(), imageRectInUserBounds.height()), image.get());481 FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize(), m_data.m_backingStoreSize, internalSize()); 482 CGContextDrawImage(context.get(), CGRectMake(0, 0, imageSizeInUserSpace.width(), imageSizeInUserSpace.height()), image.get()); 485 483 image = adoptCF(CGBitmapContextCreateImage(context.get())); 486 484 } -
trunk/Source/WebKit2/ChangeLog
r161571 r161577 1 2014-01-09 Brian Burg <bburg@apple.com> 2 3 REGRESSION (r160152): Selection drag snapshot doesn't appear or has the wrong content on Retina 4 https://bugs.webkit.org/show_bug.cgi?id=125375 5 6 Reviewed by Darin Adler. 7 8 Remove scaling from WebDragClient because it is now selectively 9 performed by WebCore according to the drag image source. 10 11 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 12 (WebKit::WebDragClient::startDrag): Don't scale the provided drag image. 13 1 14 2014-01-09 Tim Horton <timothy_horton@apple.com> 2 15 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r157058 r161577 80 80 { 81 81 IntSize bitmapSize([image.get() size]); 82 bitmapSize.scale(frame.page()->deviceScaleFactor());83 82 RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize); 84 83 ShareableBitmap::Handle handle;
Note: See TracChangeset
for help on using the changeset viewer.