WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
225081
Use ImageBuffer scaling in RemoteLayerBackingStore, rather than handling scale in the class
https://bugs.webkit.org/show_bug.cgi?id=225081
Summary
Use ImageBuffer scaling in RemoteLayerBackingStore, rather than handling scal...
Sam Weinig
Reported
2021-04-26 16:28:35 PDT
Use ImageBuffer scaling in RemoteLayerBackingStore, rather than handling scale in the class.
Attachments
Patch
(7.62 KB, patch)
2021-04-28 12:43 PDT
,
Tim Horton
no flags
Details
Formatted Diff
Diff
Patch
(9.11 KB, patch)
2021-04-28 19:23 PDT
,
Tim Horton
no flags
Details
Formatted Diff
Diff
Patch
(10.08 KB, patch)
2021-05-03 16:59 PDT
,
Tim Horton
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Tim Horton
Comment 1
2021-04-28 12:43:13 PDT
Created
attachment 427288
[details]
Patch
Tim Horton
Comment 2
2021-04-28 16:03:08 PDT
Interesting! The bot breakage I can reproduce, but only with accelerated drawing off (which I of course did not test locally)... I will investigate!
Tim Horton
Comment 3
2021-04-28 17:54:07 PDT
Mystifying. We make a software buffer with resolutionScale=2 but when it comes back it's got a CTM with scale 1. But only on iOS, and only software buffers, IOSurface works fine.
Tim Horton
Comment 4
2021-04-28 18:05:46 PDT
OK, here's why: ImageBufferShareableBitmapBackend::create adopts a GraphicsContext created by ShareableBitmap::createGraphicsContext. ShareableBitmap doesn't know about scale; it's just a bag of bytes. So, if we use ImageBuffer's setupContext to apply the root transform (the flip and device scale), we get the scale as we'd like, but then we've double flipped (because ShareableBitmap::createGraphicsContext DOES flip). There are many ways to fix this, I'm not sure which is best.
Said Abou-Hallawa
Comment 5
2021-04-28 18:30:25 PDT
A possible solution: 1. Add a new parameter ShareableBitmap::createGraphicsContext(float scaleFactor = 1) 2. Add the following call at the end of ShareableBitmap::createGraphicsContext() CGContextSetBaseCTM(bitmapContext.get(), CGAffineTransformScale(CGContextGetBaseCTM(bitmapContext.get()), scaleFactor, scaleFactor)); 3. Change ImageBufferShareableBitmapBackend::create() to call bitmap->createGraphicsContext(parameters.resolutionScale)
Tim Horton
Comment 6
2021-04-28 18:36:48 PDT
Yeah, "teach ShareableBitmap about scale" is definitely one of the options. The other easy one is "make ImageBufferShareableBitmapBackend apply its scale when it adopts the context". *Ideally* setupContext would just like... do the right thing, and we'd have enough bits on each of the backends to know what we need. But that's a bigger refactor.
Tim Horton
Comment 7
2021-04-28 19:23:40 PDT
Created
attachment 427324
[details]
Patch
Said Abou-Hallawa
Comment 8
2021-04-28 19:31:12 PDT
Comment on
attachment 427324
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=427324&action=review
> Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:131 > + m_context->applyDeviceScaleFactor(resolutionScale());
I think this is fine. Splitting the context setup between here and ShareableBitmap::createGraphicsContext() seems inconsistent with IOSurface and CGBitamp backends. So maybe in the future we need to call setupContext() for all CG contexts instead.
Tim Horton
Comment 9
2021-04-28 19:31:44 PDT
(In reply to Said Abou-Hallawa from
comment #8
)
> Comment on
attachment 427324
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=427324&action=review
> > > Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:131 > > + m_context->applyDeviceScaleFactor(resolutionScale()); > > I think this is fine. Splitting the context setup between here and > ShareableBitmap::createGraphicsContext() seems inconsistent with IOSurface > and CGBitamp backends. So maybe in the future we need to call setupContext() > for all CG contexts instead.
Agreed, there is definitely some cleanup that can be done, with more typing :)
Tim Horton
Comment 10
2021-04-29 02:27:55 PDT
Seems like there's oooonneeee broken test left.
Sam Weinig
Comment 11
2021-05-02 19:16:39 PDT
Just to ask the really dumb question here, but what about going the other way, and removing ImageBuffer scaling entirely?
Radar WebKit Bug Importer
Comment 12
2021-05-03 16:29:14 PDT
<
rdar://problem/77477683
>
Tim Horton
Comment 13
2021-05-03 16:59:13 PDT
Created
attachment 427621
[details]
Patch
Tim Horton
Comment 14
2021-05-03 17:00:03 PDT
(In reply to Sam Weinig from
comment #11
)
> Just to ask the really dumb question here, but what about going the other > way, and removing ImageBuffer scaling entirely?
That is a much scarier prospect. Not crazy, but would require more typing and care for sure.
Sam Weinig
Comment 15
2021-05-03 19:06:23 PDT
(In reply to Tim Horton from
comment #14
)
> (In reply to Sam Weinig from
comment #11
) > > Just to ask the really dumb question here, but what about going the other > > way, and removing ImageBuffer scaling entirely? > > That is a much scarier prospect. Not crazy, but would require more typing > and care for sure.
Definitely. I just don't recall the reason we made scale a property of ImageBuffer.
Said Abou-Hallawa
Comment 16
2021-05-03 19:16:38 PDT
(In reply to Sam Weinig from
comment #15
)
> (In reply to Tim Horton from
comment #14
) > > (In reply to Sam Weinig from
comment #11
) > > > Just to ask the really dumb question here, but what about going the other > > > way, and removing ImageBuffer scaling entirely? > > > > That is a much scarier prospect. Not crazy, but would require more typing > > and care for sure. > > Definitely. I just don't recall the reason we made scale a property of > ImageBuffer.
I think the scaling is used when creating ImageBuffers for Retina display. We want to have the right pixel resolution for the backend. But at the same time we draw to the context in logical coordinates. See ImageBufferCGBackend::setupContext().
Tim Horton
Comment 17
2021-05-03 19:18:29 PDT
(In reply to Said Abou-Hallawa from
comment #16
)
> (In reply to Sam Weinig from
comment #15
) > > (In reply to Tim Horton from
comment #14
) > > > (In reply to Sam Weinig from
comment #11
) > > > > Just to ask the really dumb question here, but what about going the other > > > > way, and removing ImageBuffer scaling entirely? > > > > > > That is a much scarier prospect. Not crazy, but would require more typing > > > and care for sure. > > > > Definitely. I just don't recall the reason we made scale a property of > > ImageBuffer. > > I think the scaling is used when creating ImageBuffers for Retina display. > We want to have the right pixel resolution for the backend. But at the same > time we draw to the context in logical coordinates. See > ImageBufferCGBackend::setupContext().
Sam's point is that this could be something that *clients* of ImageBuffer worry about, instead of ImageBuffer itself (just like e.g. IOSurface).
Said Abou-Hallawa
Comment 18
2021-05-03 19:25:05 PDT
This will make things a little bit more difficult. For example putImageData() and getImageData() have deal with logical coordinates.
EWS
Comment 19
2021-05-03 21:08:31 PDT
Committed
r276945
(
237278@main
): <
https://commits.webkit.org/237278@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 427621
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug