|
|
DescriptionUse SkSurface and SkImage instead of SkGpuDevice and SkBitmap in cc.
Committed: https://crrev.com/55ebb77d934328f027c2dc5c5cd2f7739eb3cd50
Cr-Commit-Position: refs/heads/master@{#293553}
Patch Set 1 #Patch Set 2 : Remove #include in resource_provider.cc #
Total comments: 3
Patch Set 3 : Use skia::RefPtrs #Patch Set 4 : Add null texture checks. #Patch Set 5 : move null check to functions that create skimage #
Total comments: 3
Messages
Total messages: 28 (7 generated)
bsalomon@google.com changed reviewers: + enne@chromium.org, senorblanco@chromium.org
I want to make SkGpuDevice a private subclass in Skia. These are the last remaining users of it in Chromium/Blink. We also have a long term goal of removing texture-backed SkBitmaps. This removes a couple uses of them.
https://codereview.chromium.org/520793002/diff/20001/cc/output/gl_renderer.cc File cc/output/gl_renderer.cc (right): https://codereview.chromium.org/520793002/diff/20001/cc/output/gl_renderer.cc... cc/output/gl_renderer.cc:802: SkImage* image = surface->newImageSnapshot(); After fixing numerous memory leaks, I'm a little allergic to raw pointers from Skia in Chromium. Can you wrap all the SkImage* in this patch in skia::RefPtr via AdoptRef or SharePtr?
https://codereview.chromium.org/520793002/diff/20001/cc/output/gl_renderer.cc File cc/output/gl_renderer.cc (right): https://codereview.chromium.org/520793002/diff/20001/cc/output/gl_renderer.cc... cc/output/gl_renderer.cc:802: SkImage* image = surface->newImageSnapshot(); On 2014/08/29 19:05:40, enne wrote: > After fixing numerous memory leaks, I'm a little allergic to raw pointers from > Skia in Chromium. Can you wrap all the SkImage* in this patch in skia::RefPtr > via AdoptRef or SharePtr? I tried in the new patch. I've never used these before so lemme know if I'm messing it up.
lgtm, although senorblanco should definitely take a look too. https://codereview.chromium.org/520793002/diff/20001/cc/output/gl_renderer.cc File cc/output/gl_renderer.cc (right): https://codereview.chromium.org/520793002/diff/20001/cc/output/gl_renderer.cc... cc/output/gl_renderer.cc:802: SkImage* image = surface->newImageSnapshot(); On 2014/08/29 20:47:33, bsalomon wrote: > On 2014/08/29 19:05:40, enne wrote: > > After fixing numerous memory leaks, I'm a little allergic to raw pointers from > > Skia in Chromium. Can you wrap all the SkImage* in this patch in skia::RefPtr > > via AdoptRef or SharePtr? > > I tried in the new patch. I've never used these before so lemme know if I'm > messing it up. Thanks. Those usages look right to me, based on what I'm guessing the Skia functions are doing.
bsalomon@google.com changed reviewers: + sugoi@chromium.org
Alexis, do you feel comfortable reviewing this in Stephen's absence or know if there is anyone familiar with the image filter code who would?
On 2014/09/02 21:17:29, bsalomon wrote: > Alexis, do you feel comfortable reviewing this in Stephen's absence or know if > there is anyone familiar with the image filter code who would? I only have 1 question: how does the existence of an SkImage object guarantees that it has a texture? All the NULL pointer checks for textures have been removed and changed to simply check for the SkImage object. Looking at the code, it's not obvious to me that no error can possibly occur that would make the texture NULL somehow. Or maybe we just want to crash if that's the case. In any case, could you just explain this quickly?
On 2014/09/03 12:11:43, sugoi1 wrote: > On 2014/09/02 21:17:29, bsalomon wrote: > > Alexis, do you feel comfortable reviewing this in Stephen's absence or know if > > there is anyone familiar with the image filter code who would? > > I only have 1 question: how does the existence of an SkImage object guarantees > that it has a texture? All the NULL pointer checks for textures have been > removed and changed to simply check for the SkImage object. Looking at the code, > it's not obvious to me that no error can possibly occur that would make the > texture NULL somehow. Or maybe we just want to crash if that's the case. In any > case, could you just explain this quickly? I *think* the textures could never be NULL the way the surfaces and images are used as the code is, but when I started to explain it I started thinking it was a fragile assumption. So I added checks for NULL getTexture()s.
On 2014/09/03 17:33:58, bsalomon wrote: > On 2014/09/03 12:11:43, sugoi1 wrote: > > On 2014/09/02 21:17:29, bsalomon wrote: > > > Alexis, do you feel comfortable reviewing this in Stephen's absence or know > if > > > there is anyone familiar with the image filter code who would? > > > > I only have 1 question: how does the existence of an SkImage object guarantees > > that it has a texture? All the NULL pointer checks for textures have been > > removed and changed to simply check for the SkImage object. Looking at the > code, > > it's not obvious to me that no error can possibly occur that would make the > > texture NULL somehow. Or maybe we just want to crash if that's the case. In > any > > case, could you just explain this quickly? > > I *think* the textures could never be NULL the way the surfaces and images are > used as the code is, but when I started to explain it I started thinking it was > a fragile assumption. So I added checks for NULL getTexture()s. LGTM, I think this is safe enough for now.
The CQ bit was checked by bsalomon@google.com
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bsalomon@google.com/520793002/60001
On 2014/09/03 17:33:58, bsalomon wrote: > On 2014/09/03 12:11:43, sugoi1 wrote: > > On 2014/09/02 21:17:29, bsalomon wrote: > > > Alexis, do you feel comfortable reviewing this in Stephen's absence or know > if > > > there is anyone familiar with the image filter code who would? > > > > I only have 1 question: how does the existence of an SkImage object guarantees > > that it has a texture? All the NULL pointer checks for textures have been > > removed and changed to simply check for the SkImage object. Looking at the > code, > > it's not obvious to me that no error can possibly occur that would make the > > texture NULL somehow. Or maybe we just want to crash if that's the case. In > any > > case, could you just explain this quickly? > > I *think* the textures could never be NULL the way the surfaces and images are > used as the code is, but when I started to explain it I started thinking it was > a fragile assumption. So I added checks for NULL getTexture()s. Will you revisit these null checks? I don't like having null checks when we're not sure what's going on. Can you add TODO for them if so?
The CQ bit was unchecked by danakj@chromium.org
On 2014/09/03 19:11:00, danakj wrote: > On 2014/09/03 17:33:58, bsalomon wrote: > > On 2014/09/03 12:11:43, sugoi1 wrote: > > > On 2014/09/02 21:17:29, bsalomon wrote: > > > > Alexis, do you feel comfortable reviewing this in Stephen's absence or > know > > if > > > > there is anyone familiar with the image filter code who would? > > > > > > I only have 1 question: how does the existence of an SkImage object > guarantees > > > that it has a texture? All the NULL pointer checks for textures have been > > > removed and changed to simply check for the SkImage object. Looking at the > > code, > > > it's not obvious to me that no error can possibly occur that would make the > > > texture NULL somehow. Or maybe we just want to crash if that's the case. In > > any > > > case, could you just explain this quickly? > > > > I *think* the textures could never be NULL the way the surfaces and images are > > used as the code is, but when I started to explain it I started thinking it > was > > a fragile assumption. So I added checks for NULL getTexture()s. > > Will you revisit these null checks? I don't like having null checks when we're > not sure what's going on. Can you add TODO for them if so? I wasn't planning to. In general it is possible for SkImage to have a NULL texture. So I don't think it is fundamentally wrong to check for NULL. I might be able to convince myself that they're unnecessary here based on how the SkSurfaces and SkImags are used, but even if so I think it's a fragile assumption that could be invalidated by a Skia-only change.
On Wed, Sep 3, 2014 at 3:24 PM, bsalomon via cc-bugs <cc-bugs@chromium.org> wrote: > On 2014/09/03 19:11:00, danakj wrote: > >> On 2014/09/03 17:33:58, bsalomon wrote: >> > On 2014/09/03 12:11:43, sugoi1 wrote: >> > > On 2014/09/02 21:17:29, bsalomon wrote: >> > > > Alexis, do you feel comfortable reviewing this in Stephen's absence >> or >> know >> > if >> > > > there is anyone familiar with the image filter code who would? >> > > >> > > I only have 1 question: how does the existence of an SkImage object >> guarantees >> > > that it has a texture? All the NULL pointer checks for textures have >> been >> > > removed and changed to simply check for the SkImage object. Looking >> at the >> > code, >> > > it's not obvious to me that no error can possibly occur that would >> make >> > the > >> > > texture NULL somehow. Or maybe we just want to crash if that's the >> case. >> > In > >> > any >> > > case, could you just explain this quickly? >> > >> > I *think* the textures could never be NULL the way the surfaces and >> images >> > are > >> > used as the code is, but when I started to explain it I started >> thinking it >> was >> > a fragile assumption. So I added checks for NULL getTexture()s. >> > > Will you revisit these null checks? I don't like having null checks when >> we're >> not sure what's going on. Can you add TODO for them if so? >> > > I wasn't planning to. In general it is possible for SkImage to have a NULL > texture. So I don't think it is fundamentally wrong to check for NULL. I > might > be able to convince myself that they're unnecessary here based on how the > SkSurfaces and SkImags are used, but even if so I think it's a fragile > assumption that could be invalidated by a Skia-only change. > Hm, but it seems like cc would be able to know if the SkImage has a texture earlier, when it decided to use the SkImage at all? For instance in https://code.google.com/p/chromium/codesearch#chromium/src/cc/output/gl_rende... , ApplyImageFilter will return an empty SkBitmap in cases where it had an error. When it returns a non-empty SkBitmap, it will have done SkGpuDevice <https://code.google.com/p/chromium/codesearch#chromium/src/third_party/skia/i...> ::Create <https://code.google.com/p/chromium/codesearch#chromium/src/third_party/skia/s..., and drawn things into it. Can it still have a null texture at that point? To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2014/09/03 19:34:36, danakj wrote: > On Wed, Sep 3, 2014 at 3:24 PM, bsalomon via cc-bugs <mailto:cc-bugs@chromium.org> > wrote: > > > On 2014/09/03 19:11:00, danakj wrote: > > > >> On 2014/09/03 17:33:58, bsalomon wrote: > >> > On 2014/09/03 12:11:43, sugoi1 wrote: > >> > > On 2014/09/02 21:17:29, bsalomon wrote: > >> > > > Alexis, do you feel comfortable reviewing this in Stephen's absence > >> or > >> know > >> > if > >> > > > there is anyone familiar with the image filter code who would? > >> > > > >> > > I only have 1 question: how does the existence of an SkImage object > >> guarantees > >> > > that it has a texture? All the NULL pointer checks for textures have > >> been > >> > > removed and changed to simply check for the SkImage object. Looking > >> at the > >> > code, > >> > > it's not obvious to me that no error can possibly occur that would > >> make > >> > > the > > > >> > > texture NULL somehow. Or maybe we just want to crash if that's the > >> case. > >> > > In > > > >> > any > >> > > case, could you just explain this quickly? > >> > > >> > I *think* the textures could never be NULL the way the surfaces and > >> images > >> > > are > > > >> > used as the code is, but when I started to explain it I started > >> thinking it > >> was > >> > a fragile assumption. So I added checks for NULL getTexture()s. > >> > > > > Will you revisit these null checks? I don't like having null checks when > >> we're > >> not sure what's going on. Can you add TODO for them if so? > >> > > > > I wasn't planning to. In general it is possible for SkImage to have a NULL > > texture. So I don't think it is fundamentally wrong to check for NULL. I > > might > > be able to convince myself that they're unnecessary here based on how the > > SkSurfaces and SkImags are used, but even if so I think it's a fragile > > assumption that could be invalidated by a Skia-only change. > > > > Hm, but it seems like cc would be able to know if the SkImage has a texture > earlier, when it decided to use the SkImage at all? > > For instance in > https://code.google.com/p/chromium/codesearch#chromium/src/cc/output/gl_rende... > , ApplyImageFilter will return an empty SkBitmap in cases where it had an > error. When it returns a non-empty SkBitmap, it will have done SkGpuDevice > <https://code.google.com/p/chromium/codesearch#chromium/src/third_party/skia/i...> > ::Create > <https://code.google.com/p/chromium/codesearch#chromium/src/third_party/skia/s..., > and drawn things into it. Can it still have a null texture at that point? In the current implementation of newImageSnapshot() it is not possible for valid gpu-backed SkSurface to return either a NULL SkImage or an SkImage with a NULL texture. But it is possible that that could change in the future. I modified the code to do the NULL check before returning SkImage in Apply*(). So the caller can know that if a non-NULL SkImage was returned then it contains a valid texture. PTAL.
Thanks, that looks a lot better to me. LGTM
The CQ bit was checked by danakj@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bsalomon@google.com/520793002/80001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: mac_chromium_rel_swarming on tryserver.chromium.mac (http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...) win_chromium_rel_swarming on tryserver.chromium.win (http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by bsalomon@google.com
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bsalomon@google.com/520793002/80001
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as 37ffe8f81510bbfb82b48640aa96fe7e51efc654
Message was sent while issue was closed.
A revert of this CL (patchset #5 id:80001) has been created in https://codereview.chromium.org/546073002/ by bsalomon@google.com. The reason for reverting is: Looks like it may have broken the layout tests. http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac10.7/builds/....
Message was sent while issue was closed.
Some post-commit comments. https://codereview.chromium.org/520793002/diff/80001/cc/output/gl_renderer.cc File cc/output/gl_renderer.cc (right): https://codereview.chromium.org/520793002/diff/80001/cc/output/gl_renderer.cc... cc/output/gl_renderer.cc:673: skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); Nit: does this really need to be a RefPtr? Doesn't this canvas live at least as long as the surface that returns it? If so, I'd actually prefer a bare ptr here, since SharePtr() is an uncommon idiom. https://codereview.chromium.org/520793002/diff/80001/cc/output/gl_renderer.cc... cc/output/gl_renderer.cc:796: skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); Same here. https://codereview.chromium.org/520793002/diff/80001/cc/output/gl_renderer.cc... cc/output/gl_renderer.cc:1000: skia::RefPtr<SkImage> filter_bitmap; Naming nit: perhaps this should be renamed filter_image, now that it's no longer an SkBitmap.
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/55ebb77d934328f027c2dc5c5cd2f7739eb3cd50 Cr-Commit-Position: refs/heads/master@{#293553} |