Created attachment 610652 [details] [diff] [review]
This surface is meant to be used for sharing copy on write surface between content and the compositor.
Comment on attachment 610652 [details] [diff] [review]
I'm not thrilled with some of the naming, but don't have a bunch of suggestions.
We should do away with the WriteLock stuff, it doesn't seem to be needed.
One of the things that's not clear about this stuff is that it needs to be used in a rather restrictive way. i.e. all ReadLocking has to happen on the same thread as GetWritable. I'm not sure how to make this more obvious in the interface, but it should be at least documented.
Further, we shouldn't allow access to the gfxImageSurface from a different thread. I suggest that we only have methods for decreasing the read count and getting the data/size/stride.
We can't delete gfxImageSurface from another thread, and I'm not sure how the gfxImageSurface's reference is managed by the gfxCoWSurfaceWrapper.
Another thing I don't like is the sort of duplication with reference count and the read count.
Created attachment 614555 [details] [diff] [review]
Comment on attachment 614555 [details] [diff] [review]
Review of attachment 614555 [details] [diff] [review]:
You'll need to make sure you delete this on the main thread.
@@ +21,5 @@
> + NS_ABORT_IF_FALSE(mReadCount == 0, "Should not be locked when released");
> + MOZ_COUNT_DTOR(gfxReusableSurfaceWrapper);
> + oC--;
> + printf_stderr("oC %u\n", oC);
Make sure you take this out.
@@ +48,5 @@
> + return this;
> + }
> + // Something else is reading the surface, copy it
> + gfxImageSurface* copySurface = new gfxImageSurface(mSurface->GetSize(), mSurface->Format());
You shouldn't initialize this surface.
@@ +2,5 @@
> + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
> + * You can obtain one at http://mozilla.org/MPL/2.0/. */
> +#ifndef GFXCOWSURFACEWRAPPER
> +#define GFXCOWSURFACEWRAPPER
Fix the name here
Created attachment 615937 [details] [diff] [review]
GFXCOWSURFACEWRAPPER didn't get fixed (must of not got qref properly), still need to fix this.