[Webkit-unassigned] [Bug 106842] adding support for DiscardablePixelRef for caching lazily decoded images

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Jan 26 12:46:52 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=106842





--- Comment #77 from Stephen White <senorblanco at chromium.org>  2013-01-26 12:48:48 PST ---
(From update of attachment 184824)
View in context: https://bugs.webkit.org/attachment.cgi?id=184824&action=review

>>> Source/WebCore/platform/graphics/chromium/DiscardablePixelRef.cpp:49
>>> +        dst->setPixelRef(pixelRef.leakPtr())->unref();
>> 
>> i'm not sure what the ->unref here is supposed to be balancing. SkBitmap appears to take a reference on the SkPixelRef, but it's storing it in a member so it should hold a ref.  is someone/something else ref()ing the SkPixelRef that we need to compensate for?
> 
> ok, will remove

The usual patterns in Skia are:

bar->setFoo(new Foo())->unref();  // "new Foo()" leaves refcnt at 1.
                                  //  setFoo() bumps it to 2.
                                  //  unref() sets it back to 1, owned by bar.

or:

{
  SkAutoTUnref<Foo> foo(new Foo());  // created w/refcnt 1  
  bar->setFoo(foo);                  // foo now has refcnt 2
}                                    // foo goes out of scope -> refcnt 1, owned by bar.

I prefer the latter, so there are no explicit unref() calls necessary.  The former should only be necessary if the object is allocated in the same call and not stored in a local var.

(And of course, we should have real smart pointers, but that's another story.)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list