Changeset 90198 in webkit
- Timestamp:
- Jun 30, 2011, 8:06:44 PM (15 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 12 edited
-
ChangeLog (modified) (1 diff)
-
Platform/cg/CGUtilities.cpp (modified) (3 diffs)
-
Platform/cg/CGUtilities.h (modified) (1 diff)
-
Shared/ShareableBitmap.h (modified) (3 diffs)
-
Shared/UpdateInfo.cpp (modified) (2 diffs)
-
Shared/UpdateInfo.h (modified) (1 diff)
-
Shared/cg/ShareableBitmapCG.cpp (modified) (1 diff)
-
UIProcess/BackingStore.cpp (modified) (2 diffs)
-
UIProcess/BackingStore.h (modified) (3 diffs)
-
UIProcess/DrawingAreaProxyImpl.cpp (modified) (2 diffs)
-
UIProcess/mac/BackingStoreMac.mm (modified) (1 diff)
-
WebProcess/WebPage/DrawingAreaImpl.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r90168 r90198 1 2011-06-30 Darin Adler <darin@apple.com> 2 3 Reviewed by Anders Carlsson. 4 5 [WebKit2] Consider scale factor when allocating backing store 6 https://bugs.webkit.org/show_bug.cgi?id=63766 7 8 This is the first step in considering scale factor. It considers 9 scale factor for the primary backing store, not graphics layers, 10 and for CG only. 11 12 * Platform/cg/CGUtilities.cpp: 13 (WebKit::paintImage): Added a scale factor argument. 14 (WebKit::paintBitmapContext): Pass 1 for scale factor. 15 * Platform/cg/CGUtilities.h: Updated for above. 16 17 * Shared/ShareableBitmap.h: Added an overload of paint that can handle 18 a scale factor. 19 20 * Shared/UpdateInfo.cpp: 21 (WebKit::UpdateInfo::encode): Encode scale factor. 22 (WebKit::UpdateInfo::decode): Decode scale factor. 23 * Shared/UpdateInfo.h: Added scale factor. 24 25 * Shared/cg/ShareableBitmapCG.cpp: 26 (WebKit::ShareableBitmap::paint): Added the overload that can handle 27 a scale factor. 28 29 * UIProcess/BackingStore.cpp: 30 (WebKit::BackingStore::create): Take a scale factor. 31 (WebKit::BackingStore::BackingStore): Store the scale factor. 32 (WebKit::BackingStore::incorporateUpdate): Consider the scale factor 33 when asserting the size is correct. 34 35 * UIProcess/BackingStore.h: Add a scale factor. 36 37 * UIProcess/DrawingAreaProxyImpl.cpp: 38 (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Check the 39 scale factor too when deciding whether to reuse a backing store. 40 (WebKit::DrawingAreaProxyImpl::incorporateUpdate): Pass in the scale 41 factor when creating a backing store. 42 43 * UIProcess/mac/BackingStoreMac.mm: 44 (WebKit::BackingStore::incorporateUpdate): Take the scale factor into 45 account when painting. 46 47 * WebProcess/WebPage/DrawingAreaImpl.cpp: 48 (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Put the 49 scale factor into the UpdateInfo. 50 (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Ditto. 51 (WebKit::DrawingAreaImpl::display): Take the scale factor into account 52 when allocating the bitmap and creating a graphics context for it. 53 1 54 2011-06-30 Mark Rowe <mrowe@apple.com> 2 55 -
trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp
r82151 r90198 31 31 namespace WebKit { 32 32 33 void paintImage(CGContextRef context, CGImageRef image, CG Point destination, CGRect source)33 void paintImage(CGContextRef context, CGImageRef image, CGFloat scaleFactor, CGPoint destination, CGRect source) 34 34 { 35 35 CGContextSaveGState(context); … … 38 38 CGContextScaleCTM(context, 1, -1); 39 39 40 size_t imageHeight = CGImageGetHeight(image);41 size_t imageWidth = CGImageGetWidth(image);40 CGFloat imageHeight = CGImageGetHeight(image) / scaleFactor; 41 CGFloat imageWidth = CGImageGetWidth(image) / scaleFactor; 42 42 43 43 CGFloat destX = destination.x - source.origin.x; 44 CGFloat destY = - static_cast<CGFloat>(imageHeight)- destination.y + source.origin.y;44 CGFloat destY = -imageHeight - destination.y + source.origin.y; 45 45 46 46 CGContextDrawImage(context, CGRectMake(destX, destY, imageWidth, imageHeight), image); 47 47 48 CGContextRestoreGState(context); 48 49 } … … 51 52 { 52 53 RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext)); 53 paintImage(context, image.get(), destination, source);54 paintImage(context, image.get(), 1, destination, source); 54 55 } 55 56 56 57 } // namespace WebKit 57 -
trunk/Source/WebKit2/Platform/cg/CGUtilities.h
r82151 r90198 29 29 namespace WebKit { 30 30 31 void paintImage(CGContextRef, CGImageRef, CG Point destination, CGRect source);31 void paintImage(CGContextRef, CGImageRef, CGFloat scaleFactor, CGPoint destination, CGRect source); 32 32 void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source); 33 33 -
trunk/Source/WebKit2/Shared/ShareableBitmap.h
r88978 r90198 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 104 104 105 105 // Paint the backing store into the given context. 106 void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& dstPoint, const WebCore::IntRect& srcRect); 106 void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& destination, const WebCore::IntRect& source); 107 void paint(WebCore::GraphicsContext&, float scaleFactor, const WebCore::IntPoint& destination, const WebCore::IntRect& source); 107 108 108 109 bool isBackedBySharedMemory() const { return m_sharedMemory; } … … 159 160 // If the shareable bitmap is backed by fastMalloced memory, this points to the data. 160 161 void* m_data; 162 161 163 #if PLATFORM(WIN) 162 164 mutable OwnPtr<HDC> m_windowsContext; -
trunk/Source/WebKit2/Shared/UpdateInfo.cpp
r77533 r90198 34 34 { 35 35 encoder->encode(viewSize); 36 encoder->encode(scaleFactor); 36 37 encoder->encode(scrollRect); 37 38 encoder->encode(scrollOffset); … … 44 45 { 45 46 if (!decoder->decode(result.viewSize)) 47 return false; 48 if (!decoder->decode(result.scaleFactor)) 46 49 return false; 47 50 if (!decoder->decode(result.scrollRect)) -
trunk/Source/WebKit2/Shared/UpdateInfo.h
r82441 r90198 49 49 // The size of the web view. 50 50 WebCore::IntSize viewSize; 51 float scaleFactor; 51 52 52 53 // The rect and delta to be scrolled. -
trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp
r88967 r90198 63 63 } 64 64 65 void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& d stPoint, const IntRect& srcRect)65 void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& destination, const IntRect& source) 66 66 { 67 paintImage(context.platformContext(), makeCGImageCopy().get(), dstPoint, srcRect); 67 paintImage(context.platformContext(), makeCGImageCopy().get(), 1, destination, source); 68 } 69 70 void ShareableBitmap::paint(WebCore::GraphicsContext& context, float scaleFactor, const IntPoint& destination, const IntRect& source) 71 { 72 paintImage(context.platformContext(), makeCGImageCopy().get(), scaleFactor, destination, source); 68 73 } 69 74 -
trunk/Source/WebKit2/UIProcess/BackingStore.cpp
r84524 r90198 34 34 namespace WebKit { 35 35 36 PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, WebPageProxy* webPageProxy)36 PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, float scaleFactor, WebPageProxy* webPageProxy) 37 37 { 38 return adoptPtr(new BackingStore(size, webPageProxy));38 return adoptPtr(new BackingStore(size, scaleFactor, webPageProxy)); 39 39 } 40 40 41 BackingStore::BackingStore(const IntSize& size, WebPageProxy* webPageProxy)41 BackingStore::BackingStore(const IntSize& size, float scaleFactor, WebPageProxy* webPageProxy) 42 42 : m_size(size) 43 , m_scaleFactor(scaleFactor) 43 44 , m_webPageProxy(webPageProxy) 44 45 { … … 57 58 if (!bitmap) 58 59 return; 59 ASSERT(bitmap->size() == updateInfo.updateRectBounds.size()); 60 61 #if !ASSERT_DISABLED 62 IntSize updateSize = updateInfo.updateRectBounds.size(); 63 updateSize.scale(m_scaleFactor); 64 ASSERT(bitmap->size() == updateSize); 65 #endif 60 66 61 67 incorporateUpdate(bitmap.get(), updateInfo); -
trunk/Source/WebKit2/UIProcess/BackingStore.h
r89442 r90198 61 61 62 62 public: 63 static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, WebPageProxy*);63 static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, float scaleFactor, WebPageProxy*); 64 64 ~BackingStore(); 65 65 66 66 const WebCore::IntSize& size() const { return m_size; } 67 float scaleFactor() const { return m_scaleFactor; } 67 68 68 69 #if PLATFORM(MAC) … … 80 81 81 82 private: 82 BackingStore(const WebCore::IntSize&, WebPageProxy*);83 BackingStore(const WebCore::IntSize&, float scaleFactor, WebPageProxy*); 83 84 84 85 void incorporateUpdate(ShareableBitmap*, const UpdateInfo&); … … 86 87 87 88 WebCore::IntSize m_size; 89 float m_scaleFactor; 88 90 WebPageProxy* m_webPageProxy; 89 91 -
trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
r88463 r90198 206 206 207 207 // If we have a backing store the right size, reuse it. 208 if (m_backingStore && m_backingStore->size() != updateInfo.viewSize)208 if (m_backingStore && (m_backingStore->size() != updateInfo.viewSize || m_backingStore->scaleFactor() != updateInfo.scaleFactor)) 209 209 m_backingStore = nullptr; 210 210 incorporateUpdate(updateInfo); … … 243 243 244 244 if (!m_backingStore) 245 m_backingStore = BackingStore::create(updateInfo.viewSize, m_webPageProxy);245 m_backingStore = BackingStore::create(updateInfo.viewSize, updateInfo.scaleFactor, m_webPageProxy); 246 246 247 247 m_backingStore->incorporateUpdate(updateInfo); -
trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm
r76991 r90198 110 110 srcRect.move(-updateRectLocation.x(), -updateRectLocation.y()); 111 111 112 bitmap->paint(graphicsContext, update Rect.location(), srcRect);112 bitmap->paint(graphicsContext, updateInfo.scaleFactor, updateRect.location(), srcRect); 113 113 } 114 114 } -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
r88978 r90198 358 358 if (m_isPaintingSuspended || m_layerTreeHost) { 359 359 updateInfo.viewSize = m_webPage->size(); 360 updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor(); 360 361 361 362 if (m_layerTreeHost) { … … 462 463 463 464 UpdateInfo updateInfo; 464 if (m_isPaintingSuspended) 465 if (m_isPaintingSuspended) { 465 466 updateInfo.viewSize = m_webPage->size(); 466 else 467 updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor(); 468 } else 467 469 display(updateInfo); 468 470 … … 614 616 615 617 updateInfo.viewSize = m_webPage->size(); 618 updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor(); 616 619 617 620 IntRect bounds = m_dirtyRegion.bounds(); 618 621 ASSERT(m_webPage->bounds().contains(bounds)); 619 622 620 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha); 623 IntSize bitmapSize = bounds.size(); 624 bitmapSize.scale(m_webPage->userSpaceScaleFactor()); 625 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha); 621 626 if (!bitmap) 622 627 return; … … 640 645 641 646 OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get()); 647 graphicsContext->scale(FloatSize(m_webPage->userSpaceScaleFactor(), m_webPage->userSpaceScaleFactor())); 642 648 643 649 updateInfo.updateRectBounds = bounds;
Note:
See TracChangeset
for help on using the changeset viewer.