RESOLVED FIXED93677
[chromium] Add software bitmap resources to CCResourceProvider
https://bugs.webkit.org/show_bug.cgi?id=93677
Summary [chromium] Add software bitmap resources to CCResourceProvider
Alexandre Elias
Reported 2012-08-09 19:07:15 PDT
[chromium] Add software bitmap resources to CCResourceProvider
Attachments
Patch (32.58 KB, patch)
2012-08-09 19:20 PDT, Alexandre Elias
no flags
Patch (33.01 KB, patch)
2012-08-09 20:48 PDT, Alexandre Elias
no flags
Patch (36.60 KB, patch)
2012-08-15 17:32 PDT, Alexandre Elias
no flags
Patch (39.04 KB, patch)
2012-08-17 12:46 PDT, Alexandre Elias
no flags
Patch (39.02 KB, patch)
2012-08-17 17:59 PDT, Alexandre Elias
no flags
Patch (38.87 KB, patch)
2012-08-20 14:28 PDT, Alexandre Elias
no flags
Patch (39.52 KB, patch)
2012-08-20 16:01 PDT, Alexandre Elias
no flags
Patch (39.61 KB, patch)
2012-08-20 20:02 PDT, Alexandre Elias
no flags
Patch (40.27 KB, patch)
2012-08-21 18:49 PDT, Alexandre Elias
no flags
Alexandre Elias
Comment 1 2012-08-09 19:20:42 PDT
Alexandre Elias
Comment 2 2012-08-09 19:23:11 PDT
This approach doesn't have anything in the way of static type safety, but it seems hard to avoid that given the desired model. In practice, since a single CCRenderer subclass will use most of the resources, it shouldn't come up that often though. I'll write tests before landing.
Antoine Labour
Comment 3 2012-08-09 20:28:21 PDT
Comment on attachment 157613 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157613&action=review > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.cpp:323 > + , m_creationPolicy(CreateGLTextures) Should we choose this based on the context? > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.h:48 > +class ScopedWriteLockGL; You moved the definitions inside of CCResourceProvider, so these forward declarations are superfluous / wrong. > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.h:87 > + ResourceId createBitmap(int pool, const IntSize&); It would probably be useful to add a resourceType(ResourceID). That kinda calls CreationPolicy to be renamed ResourceType, and setCreationPolicy to setDefaultResourceType? > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.h:154 > + class ScopedWriteLockSoftware { Are we going to be using this in layers? If yes, can we make it work on texture-based resources too (e.g. add a pixel backing sore on the lock, and upload on the unlock), so that we don't need to have 2 paths based on the resource type?
Antoine Labour
Comment 4 2012-08-09 20:29:03 PDT
For tests, maybe we can reuse existing tests and have a way to execute twice, once with each policy?
Alexandre Elias
Comment 5 2012-08-09 20:48:36 PDT
Created attachment 157627 [details] Patch Introduce ResourceType and remove forward declarations
Alexandre Elias
Comment 6 2012-08-09 20:52:56 PDT
> > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.cpp:323 > > + , m_creationPolicy(CreateGLTextures) > > Should we choose this based on the context? Possibly; I'll change this in a later patch when it becomes feasible to run with a different policy. > > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.h:154 > > + class ScopedWriteLockSoftware { > > Are we going to be using this in layers? If yes, can we make it work on texture-based resources too (e.g. add a pixel backing sore on the lock, and upload on the unlock), so that we don't need to have 2 paths based on the resource type? This isn't intended for use by layers, CCRenderer will be the primary user. > For tests, maybe we can reuse existing tests and have a way to execute twice, once with each policy? Seems reasonable, I'll take a look.
Alexandre Elias
Comment 7 2012-08-15 17:32:02 PDT
Created attachment 158670 [details] Patch Added unit tests and rewrote upload() to use SkCanvas::writePixels
Alexandre Elias
Comment 8 2012-08-17 12:46:34 PDT
Created attachment 159182 [details] Patch Rebased on Bug 93524
Alexandre Elias
Comment 9 2012-08-17 17:59:29 PDT
Created attachment 159246 [details] Patch Rebased
Adrienne Walker
Comment 10 2012-08-20 13:18:00 PDT
Comment on attachment 159246 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159246&action=review > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.h:262 > + uint8_t* pixels; Is it possible to use OwnArrayPtr<uint8> here?
Alexandre Elias
Comment 11 2012-08-20 14:16:17 PDT
(In reply to comment #10) > (From update of attachment 159246 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=159246&action=review > > > Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.h:262 > > + uint8_t* pixels; > > Is it possible to use OwnArrayPtr<uint8> here? I'm running into hashmap-related errors. It looks like there's a trick to allow OwnPtrs in hashmaps, but only if they're at the top level (not in a struct). We could explore various ways of tackling this, but it seems like the details will change when we move away from WTF data structures, and also ResourceProvider needs to manage explicit create/delete calls for GL resources anyway.
Alexandre Elias
Comment 12 2012-08-20 14:28:32 PDT
Created attachment 159522 [details] Patch Rebased
Adrienne Walker
Comment 13 2012-08-20 15:03:56 PDT
Can you run double check that webkit_unit_tests passes in a debug build? I see an assert with your patch. [ RUN ] CCLayerTreeHostImplTest.dontUseOldResourcesAfterLostContext ASSERTION FAILED: m_textureId ../../third_party/WebKit/Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.cpp(272) : WebCore::CCResourceProvider::ScopedReadLockGL::ScopedReadLockGL(WebCore::CCResourceProvider*, unsigned int)
Alexandre Elias
Comment 14 2012-08-20 15:59:19 PDT
(In reply to comment #13) > Can you run double check that webkit_unit_tests passes in a debug build? I see an assert with your patch. > > [ RUN ] CCLayerTreeHostImplTest.dontUseOldResourcesAfterLostContext > ASSERTION FAILED: m_textureId > ../../third_party/WebKit/Source/WebCore/platform/graphics/chromium/cc/CCResourceProvider.cpp(272) : WebCore::CCResourceProvider::ScopedReadLockGL::ScopedReadLockGL(WebCore::CCResourceProvider*, unsigned int) Hmm, this is because I added a new assertion that we don't try to lock a zero textureId. The root cause is in CCTextureLayerImpl: void CCTextureLayerImpl::didLoseContext() { m_textureId = 0; } then it goes ahead and creates an external texture resource with that ID. What would be the best place to fix that?
Alexandre Elias
Comment 15 2012-08-20 16:01:41 PDT
Created attachment 159551 [details] Patch Fix an upload bug when imageRect.location != 0, and add a new test case for it.
Dana Jansens
Comment 16 2012-08-20 16:06:07 PDT
(In reply to comment #14) > Hmm, this is because I added a new assertion that we don't try to lock a zero textureId. The root cause is in CCTextureLayerImpl: > > void CCTextureLayerImpl::didLoseContext() > { > m_textureId = 0; > } > > then it goes ahead and creates an external texture resource with that ID. What would be the best place to fix that? Hm, probably early-out in willDraw(), and then early out in appendQuads and didDraw if !m_externalTextureResource
Alexandre Elias
Comment 17 2012-08-20 20:02:57 PDT
Created attachment 159597 [details] Patch Fix another assertion failure in CCResourceProviderTest by checking for glId != 0 in deleteResource()
Adrienne Walker
Comment 18 2012-08-21 09:04:05 PDT
Comment on attachment 159597 [details] Patch R=me.
WebKit Review Bot
Comment 19 2012-08-21 15:59:48 PDT
Comment on attachment 159597 [details] Patch Clearing flags on attachment: 159597 Committed r126202: <http://trac.webkit.org/changeset/126202>
WebKit Review Bot
Comment 20 2012-08-21 15:59:53 PDT
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 21 2012-08-21 17:58:41 PDT
Re-opened since this is blocked by 94657
Alexandre Elias
Comment 22 2012-08-21 18:49:22 PDT
Created attachment 159842 [details] Patch Change back to initializing m_maxTextureSize to 0 in constructor, since glGetIntegerv asserts that it receives only zero values.
Adrienne Walker
Comment 23 2012-08-22 10:27:01 PDT
Comment on attachment 159842 [details] Patch R=me, assuming you've tested directly that this fixes the problem. I'm also leaving CQ+ for you to set yourself after you land 94266.
WebKit Review Bot
Comment 24 2012-08-22 14:26:23 PDT
Comment on attachment 159842 [details] Patch Clearing flags on attachment: 159842 Committed r126351: <http://trac.webkit.org/changeset/126351>
WebKit Review Bot
Comment 25 2012-08-22 14:26:28 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.