aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRefCnt.h
Commit message (Collapse)AuthorAge
* Make GrCacheable implement its own ref counting.Gravatar bsalomon2014-07-21
| | | | | | | | R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/392333008
* Remove SkRefPtr.Gravatar bungeman2014-07-17
| | | | | | | | R=mtklein@google.com, reed@google.com, bsalomon@google.com Author: bungeman@google.com Review URL: https://codereview.chromium.org/393913002
* SkAutoRef seems lonely. Might as well delete it.Gravatar mtklein2014-07-15
| | | | | | | | | | | | | (On the other hand, SkAutoUnref is well-used.) NOTREECHECKS=true BUG=skia: R=bungeman@google.com, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/393953004
* Revert "Remove ability for Release code to call getRefCnt() or getWeakRefCnt()."Gravatar Mike Klein2014-07-09
| | | | | | | | This reverts commit 4ae94ffce5ecf1b71cb5e295b68bf4ec9e697443. BUG=skia: Review URL: https://codereview.chromium.org/382523002
* Remove ability for Release code to call getRefCnt() or getWeakRefCnt().Gravatar mtklein2014-07-08
| | | | | | | | | | | | | | | | | These getRefCnt() methods are not thread safe, so Skia code should not be calling them. unique() is fine. SkDEBUG code (SkASSERTs) can still call getRefCnt() / getWeakRefCnt(). This adds tools/RefCntIs.{h,cpp}, which lets tests make their assertions in both debug and release modes. BUG=skia:2726 R=senorblanco@chromium.org, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/378643003
* Add SkASSERTF.Gravatar mtklein2014-06-18
| | | | | | | | | | | | | | | | Example failure: fRefCnt was 3 ../../../usr/local/google/home/mtklein/skia/include/core/SkRefCnt.h:40: failed assertion "(fRefCnt == 1) || (SkDebugf("fRefCnt was %d""\n", fRefCnt), false)" Command terminated by signal 11 Not pretty, but everything's there. Perhaps we'll think of ways to make it nicer later. BUG=skia: R=bsalomon@google.com, reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/337243004
* Revert "Remove SkThread.h from public API."Gravatar commit-bot@chromium.org2014-05-28
| | | | | | | | | | | | | | | | | | | Too much depends on SkThread being in include/core in Chrome build. This reverts commit b1aec17df6078115c797839c9646081ccba2bd09. NOTREECHECKS=true NOTRY=true R=reed@google.com, mtklein@google.com TBR=reed BUG=skia: Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/303813003 git-svn-id: http://skia.googlecode.com/svn/trunk@14934 2bbb7eff-a529-9590-31e7-b0007b416f81
* Remove SkThread.h from public API.Gravatar commit-bot@chromium.org2014-05-28
| | | | | | | | | | | BUG=skia: R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/303463009 git-svn-id: http://skia.googlecode.com/svn/trunk@14926 2bbb7eff-a529-9590-31e7-b0007b416f81
* teach TSAN about SkSpinlock, SkRefCnt, and SkOnceGravatar commit-bot@chromium.org2014-04-27
| | | | | | | | | | | | | | | | | | | BUG=skia: Committed: http://code.google.com/p/skia/source/detail?r=14353 NOTRY=true NOTREECHECKS=true Committed: http://code.google.com/p/skia/source/detail?r=14354 R=bsalomon@google.com, bungeman@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/247813005 git-svn-id: http://skia.googlecode.com/svn/trunk@14390 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert of teach TSAN about SkSpinlock, SkRefCnt, and SkOnce ↵Gravatar commit-bot@chromium.org2014-04-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://codereview.chromium.org/247813005/) Reason for revert: breaks blink in roll Original issue's description: > teach TSAN about SkSpinlock, SkRefCnt, and SkOnce > > BUG=skia: > > Committed: http://code.google.com/p/skia/source/detail?r=14353 > > NOTRY=true > NOTREECHECKS=true > > Committed: http://code.google.com/p/skia/source/detail?r=14354 R=bsalomon@google.com, bungeman@google.com, mtklein@chromium.org TBR=bsalomon@google.com, bungeman@google.com, mtklein@chromium.org NOTREECHECKS=true NOTRY=true BUG=skia: Author: mtklein@google.com Review URL: https://codereview.chromium.org/258783005 git-svn-id: http://skia.googlecode.com/svn/trunk@14389 2bbb7eff-a529-9590-31e7-b0007b416f81
* teach TSAN about SkSpinlock, SkRefCnt, and SkOnceGravatar commit-bot@chromium.org2014-04-24
| | | | | | | | | | | | | | | | BUG=skia: Committed: http://code.google.com/p/skia/source/detail?r=14353 NOTRY=true NOTREECHECKS=true R=bsalomon@google.com, bungeman@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/247813005 git-svn-id: http://skia.googlecode.com/svn/trunk@14354 2bbb7eff-a529-9590-31e7-b0007b416f81
* teach TSAN about SkSpinlock, SkRefCnt, and SkOnceGravatar commit-bot@chromium.org2014-04-24
| | | | | | | | | | | BUG=skia: R=bsalomon@google.com, bungeman@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/247813005 git-svn-id: http://skia.googlecode.com/svn/trunk@14353 2bbb7eff-a529-9590-31e7-b0007b416f81
* SkNonCopyable should be used with private inheritance.Gravatar commit-bot@chromium.org2014-04-07
| | | | | | | | | | | | | | | This is mostly s/public SkNoncopyable/SkNoncopyable/g. Two classes (SkDrawLooper::Context and SkPicture::OperationList) don't actually work with SkNoncopyable because they introduce a virtual destructor. I added SkNoncopyableVirtual to make them work as intended. Sort of questionable whether they really need to be noncopyable in the first place, but I guess it doesn't hurt to keep the behavior the same. BUG=skia: R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/226183018 git-svn-id: http://skia.googlecode.com/svn/trunk@14081 2bbb7eff-a529-9590-31e7-b0007b416f81
* TSAN: use somewhat pithier SK_ANNOTATE_UNPROTECTED_READ.Gravatar commit-bot@chromium.org2014-02-04
| | | | | | | | | | | | | | | This is a little bit better practice to be i than the existing SK_ANNOTATE_BENIGN_RACE, as UNPROTECTED_READ will only ignore reads, not writes. Tag SkRefCnt::unique() as a safe unprotected read like SkOnce's double-checked locking. BUG=skia: R=reed@google.com, bungeman@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/144953005 git-svn-id: http://skia.googlecode.com/svn/trunk@13309 2bbb7eff-a529-9590-31e7-b0007b416f81
* Split atomic and mutex implementations and make inlinable.Gravatar bungeman@google.com2013-12-18
| | | | | | | | | | | | | | | | | | | | | | | Skia cannot use Chromium's implementation of mutex (Lock) due to static initializers. However, we would like to be able to use Chromium's implementation of atomics. This motivates the split of implementation. Skia's atomic and mutex calls should be inlinable, especially the atomics. These calls often compile down to very few instructions, and we currently have the overhead of a function call. This motivates the header implementation. There is still a desire for the build system to select the implementation, so the SK_XXX_PLATFORM_H pattern for header files is introduced. This allows the build system to control which platform specific header files are chosen. The Chromium side changes (most of which will need to go in before this change can be found at https://codereview.chromium.org/19477005/ . The Chromium side changes after this lands can be seen at https://codereview.chromium.org/98073013 . Review URL: https://codereview.chromium.org/19808007 git-svn-id: http://skia.googlecode.com/svn/trunk@12738 2bbb7eff-a529-9590-31e7-b0007b416f81
* Guard against most unintentionally ephemeral SkAutoFoo instantiations.Gravatar commit-bot@chromium.org2013-11-18
| | | | | | | | | | | | | | | | | | | I think I applied the trick everywhere possible. Limitations: - can't be used with templated classes - all constructors and destructors must be defined inline A couple of the SkAutoFoo were unused in Skia, Chromium, and Android, so I deleted them. This change caught the same bugs Cary found in SkPath, plus one more in SampleApp. BUG= R=reed@google.com, caryclark@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/72603005 git-svn-id: http://skia.googlecode.com/svn/trunk@12301 2bbb7eff-a529-9590-31e7-b0007b416f81
* Allow users to build on top of, instead of beneath, SkRefCnt.Gravatar bungeman@google.com2013-10-25
| | | | | | | | | | | | Alternative to r11811. The Chromium half of this can be seen at https://codereview.chromium.org/40973002/ . R=reed@google.com Review URL: https://codereview.chromium.org/40503002 git-svn-id: http://skia.googlecode.com/svn/trunk@11967 2bbb7eff-a529-9590-31e7-b0007b416f81
* Add hooks for external run-time reference adoption checks to SkRefCnt.Gravatar commit-bot@chromium.org2013-10-16
| | | | | | | | | | | | | | | The reference adoption checks are to help detect memory leaks and bad usage when using SkRefCnt subclasses with Blink's RefPtr. BUG=crbug.com/304265 R=reed@google.com, bungeman@google.com Author: junov@chromium.org Review URL: https://codereview.chromium.org/25432003 git-svn-id: http://skia.googlecode.com/svn/trunk@11811 2bbb7eff-a529-9590-31e7-b0007b416f81
* Make it explicit that some validate methods are debug onlyGravatar robertphillips@google.com2013-10-02
| | | | | | | | https://codereview.chromium.org/25716003/ git-svn-id: http://skia.googlecode.com/svn/trunk@11575 2bbb7eff-a529-9590-31e7-b0007b416f81
* Remove GrRefCnt.h in favor of SkRefCnt.hGravatar commit-bot@chromium.org2013-09-09
| | | | | | | | | | | | | | | | | This removes GrRefCnt.h with all its tyepdefs and #defines and just switch them to the Sk* equivalents. GrSafeSetNull was promoted to SkSafeSetNull in SkRefCnt.h. BUG=None TEST=none, no functional changes. R=bsalomon@google.com, robertphillips@google.com Author: tfarina@chromium.org Review URL: https://chromiumcodereview.appspot.com/23904003 git-svn-id: http://skia.googlecode.com/svn/trunk@11151 2bbb7eff-a529-9590-31e7-b0007b416f81
* Add a 'unique' method to SkRefCnt, document the usage, and add support.Gravatar bungeman@google.com2013-07-19
| | | | | | | | | | | | | | | | | | std::shared_ptr has a method called 'unique' which captures the concept that a reference count of 1 is special, and can be used to optimize copy on write. It also has some undocumented need for memory barriers in certain situations and those needs are documented here. The motivation for looking into this is crbug.com/258499 . The use of the reference count in this manner is a benign race with both ref() and unref(). By introducing sk_atomic_unprotected_read, it is possible for Chromium to annotate this read to tell ThreadSanitizer that this is known. R=bsalomon@google.com Review URL: https://codereview.chromium.org/18770007 git-svn-id: http://skia.googlecode.com/svn/trunk@10221 2bbb7eff-a529-9590-31e7-b0007b416f81
* Alias deref -> unref. This allows Skia objects to be held by WTF::RefPtrGravatar commit-bot@chromium.org2013-06-26
| | | | | | | | | | | | | | | | | | | | smart pointers without need for another smart pointer type. Note that the semantics of SkRefCnt match those WTF expects. In particular, newly created objects have refcount 1 and objects are deallocated at refcount 0. This seems like a better fit than the AddRef/Release alises which exist for scoped_ptr (but seem unused). BUG=254509 R=reed@google.com Author: jbroman@chromium.org Review URL: https://chromiumcodereview.appspot.com/17880003 git-svn-id: http://skia.googlecode.com/svn/trunk@9784 2bbb7eff-a529-9590-31e7-b0007b416f81
* Remove 'friend SkRefCnt' from SkData.Gravatar bungeman@google.com2013-04-16
| | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/13925021/ If a non-POD class does not provide a default destructor, one is provided by teh compiler. GCC will do so, but only at the point where the vtable is output; since BlockRef has no implementation its destructor is never output, so there is no complaint. VC++, however, provides the destructor implementation as soon as it sees the type. If the destructor of BlockRef is ever defined an error will be reported (since the destructor of SkData is private). Declaring (but does not defining) a destructor for BlockRef fixes two issues. First, it prevents a default destructor from being provided, removing the VC++ error. Second, BlockRef now blocks access to the destructor through '->'. git-svn-id: http://skia.googlecode.com/svn/trunk@8697 2bbb7eff-a529-9590-31e7-b0007b416f81
* have reset() return its argument as a convenienceGravatar reed@google.com2013-03-13
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@8141 2bbb7eff-a529-9590-31e7-b0007b416f81
* Sanitizing source files in Skia_Periodic_House_KeepingGravatar skia.committer@gmail.com2013-01-26
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@7406 2bbb7eff-a529-9590-31e7-b0007b416f81
* re-add SkRefPtr to SkRefCnt.h until all uses of it have been removed from ChromeGravatar robertphillips@google.com2013-01-07
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@7044 2bbb7eff-a529-9590-31e7-b0007b416f81
* Remove SkRefPtrGravatar vandebo@chromium.org2013-01-04
| | | | | | | | | (resubmit of https://codereview.appspot.com/7030059/) TBR=junov@google.com Review URL: https://codereview.appspot.com/7030065 git-svn-id: http://skia.googlecode.com/svn/trunk@7030 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "Remove SkRefPtr" - r7021Gravatar vandebo@chromium.org2013-01-04
| | | | | | | | samplecode/ still needs to be updated. Review URL: https://codereview.appspot.com/7032048 git-svn-id: http://skia.googlecode.com/svn/trunk@7022 2bbb7eff-a529-9590-31e7-b0007b416f81
* Remove SkRefPtrGravatar vandebo@chromium.org2013-01-04
| | | | | | Review URL: https://codereview.appspot.com/7030059 git-svn-id: http://skia.googlecode.com/svn/trunk@7021 2bbb7eff-a529-9590-31e7-b0007b416f81
* Create aliases AddRef() and Release() to SkRefCnt for compatibility with ↵Gravatar reed@google.com2012-11-30
| | | | | | | | scoped_refptr Review URL: https://codereview.appspot.com/6844116 git-svn-id: http://skia.googlecode.com/svn/trunk@6639 2bbb7eff-a529-9590-31e7-b0007b416f81
* revert prev change to resetGravatar reed@google.com2012-11-27
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@6571 2bbb7eff-a529-9590-31e7-b0007b416f81
* guard for self-assignment in reset()Gravatar reed@google.com2012-11-27
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@6568 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert r5557 (which itself was a revert of r5433). Relands SkPathRef. Will ↵Gravatar bsalomon@google.com2012-10-03
| | | | | | follow with change for extra debug checks to attempt to ferret out http://www.crbug.com/148637. git-svn-id: http://skia.googlecode.com/svn/trunk@5783 2bbb7eff-a529-9590-31e7-b0007b416f81
* Temporarily revert r5433 due to http://www.crbug.com/148637 until after M23 ↵Gravatar bsalomon@google.com2012-09-14
| | | | | | branch. git-svn-id: http://skia.googlecode.com/svn/trunk@5557 2bbb7eff-a529-9590-31e7-b0007b416f81
* SkPathRef: one allocation for pts+verbs, path GenID, copy-on-writeGravatar bsalomon@google.com2012-09-07
| | | | | | | | Review URL: https://codereview.appspot.com/6488063/ git-svn-id: http://skia.googlecode.com/svn/trunk@5433 2bbb7eff-a529-9590-31e7-b0007b416f81
* SkRef for expressions.Gravatar bungeman@google.com2012-08-22
| | | | | | | https://codereview.appspot.com/6475045/ git-svn-id: http://skia.googlecode.com/svn/trunk@5238 2bbb7eff-a529-9590-31e7-b0007b416f81
* Const correct BlockRef in SkAutoTUnref.Gravatar bungeman@google.com2012-07-30
| | | | | | | https://codereview.appspot.com/6448066/ git-svn-id: http://skia.googlecode.com/svn/trunk@4829 2bbb7eff-a529-9590-31e7-b0007b416f81
* Specialize SkAutoTUnref on const T so that operator -> works.Gravatar bsalomon@google.com2012-07-27
| | | | | | | | | Review URL: http://codereview.appspot.com/6450054/ git-svn-id: http://skia.googlecode.com/svn/trunk@4802 2bbb7eff-a529-9590-31e7-b0007b416f81
* add protected method for internal_dispose overrides to jam fRefCnt beforeGravatar reed@google.com2012-07-23
| | | | | | | | | calling destructor. move SkTRefArray to actually inherit from SkRefCnt Review URL: https://codereview.appspot.com/6422057 git-svn-id: http://skia.googlecode.com/svn/trunk@4719 2bbb7eff-a529-9590-31e7-b0007b416f81
* AutoScratchTexture can now release its texture and it will return to the ↵Gravatar robertphillips@google.com2012-06-22
| | | | | | | | | | texture cache when freed http://codereview.appspot.com/6262043/ git-svn-id: http://skia.googlecode.com/svn/trunk@4301 2bbb7eff-a529-9590-31e7-b0007b416f81
* Version 2 of the Instance Counting system. This one simplifies the print out ↵Gravatar robertphillips@google.com2012-06-13
| | | | | | | | | | of information. http://codereview.appspot.com/6296069/ git-svn-id: http://skia.googlecode.com/svn/trunk@4255 2bbb7eff-a529-9590-31e7-b0007b416f81
* Instance counting for SkRefCnt-derived objects (w/ CanvasTest fix)Gravatar robertphillips@google.com2012-06-05
| | | | | | | | http://codereview.appspot.com/6242070/ git-svn-id: http://skia.googlecode.com/svn/trunk@4170 2bbb7eff-a529-9590-31e7-b0007b416f81
* Reverting r4162Gravatar robertphillips@google.com2012-06-05
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@4164 2bbb7eff-a529-9590-31e7-b0007b416f81
* Added instance counting system for SkRefCnt-derived objectsGravatar robertphillips@google.com2012-06-05
| | | | | | | | http://codereview.appspot.com/6242070/ git-svn-id: http://skia.googlecode.com/svn/trunk@4162 2bbb7eff-a529-9590-31e7-b0007b416f81
* VC++ allows template parameter shadowing.Gravatar bungeman@google.com2012-06-01
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@4127 2bbb7eff-a529-9590-31e7-b0007b416f81
* Serialize support for GDI.Gravatar bungeman@google.com2012-06-01
| | | | | | | | http://codereview.appspot.com/6263046/ git-svn-id: http://skia.googlecode.com/svn/trunk@4126 2bbb7eff-a529-9590-31e7-b0007b416f81
* WeakRefCntGravatar bungeman@google.com2012-05-16
| | | | | | | http://codereview.appspot.com/5649046/ git-svn-id: http://skia.googlecode.com/svn/trunk@3978 2bbb7eff-a529-9590-31e7-b0007b416f81
* allow SkAutoTUnref to be used syntactially as the object is refsGravatar reed@google.com2012-05-08
| | | | | | Review URL: https://codereview.appspot.com/6189059 git-svn-id: http://skia.googlecode.com/svn/trunk@3870 2bbb7eff-a529-9590-31e7-b0007b416f81
* write 0 to our refcnt in the destructor, in the off-chance of it helping usGravatar reed@google.com2011-09-12
| | | | | | | | catch reuse-after-delete bugs (debug only) git-svn-id: http://skia.googlecode.com/svn/trunk@2251 2bbb7eff-a529-9590-31e7-b0007b416f81
* Fix some ref leaksGravatar bsalomon@google.com2011-08-09
| | | | | | | | Review URL: http://codereview.appspot.com/4837068/ git-svn-id: http://skia.googlecode.com/svn/trunk@2082 2bbb7eff-a529-9590-31e7-b0007b416f81