Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: src/core/SkXfermode.cpp

Issue 651723003: Require SK_DECLARE_STATIC_LAZY_PTR is used in global scope. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: safe unref Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/fonts/SkRemotableFontMgr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkXfermode.h" 10 #include "SkXfermode.h"
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 this->addTextureAccess(&fBackgroundAccess); 1204 this->addTextureAccess(&fBackgroundAccess);
1205 } else { 1205 } else {
1206 this->setWillReadDstColor(); 1206 this->setWillReadDstColor();
1207 } 1207 }
1208 } 1208 }
1209 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { 1209 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
1210 const XferEffect& s = other.cast<XferEffect>(); 1210 const XferEffect& s = other.cast<XferEffect>();
1211 return fMode == s.fMode && 1211 return fMode == s.fMode &&
1212 fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture( ); 1212 fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture( );
1213 } 1213 }
1214 1214
1215 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE { 1215 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE {
1216 inout->fValidFlags = 0; 1216 inout->fValidFlags = 0;
1217 inout->fIsSingleComponent = false; 1217 inout->fIsSingleComponent = false;
1218 } 1218 }
1219 1219
1220 SkXfermode::Mode fMode; 1220 SkXfermode::Mode fMode;
1221 GrCoordTransform fBackgroundTransform; 1221 GrCoordTransform fBackgroundTransform;
1222 GrTextureAccess fBackgroundAccess; 1222 GrTextureAccess fBackgroundAccess;
1223 1223
1224 typedef GrFragmentProcessor INHERITED; 1224 typedef GrFragmentProcessor INHERITED;
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 default: 1702 default:
1703 // no special-case, just rely in the rec and its function-ptrs 1703 // no special-case, just rely in the rec and its function-ptrs
1704 xfer = SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode)); 1704 xfer = SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
1705 break; 1705 break;
1706 } 1706 }
1707 } 1707 }
1708 return xfer; 1708 return xfer;
1709 } 1709 }
1710 } // namespace 1710 } // namespace
1711 1711
1712 SK_DECLARE_STATIC_LAZY_PTR_ARRAY(SkXfermode, cached, SkXfermode::kLastMode + 1, create_mode);
1712 1713
1713 SkXfermode* SkXfermode::Create(Mode mode) { 1714 SkXfermode* SkXfermode::Create(Mode mode) {
1714 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount); 1715 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
1715 1716
1716 if ((unsigned)mode >= kModeCount) { 1717 if ((unsigned)mode >= kModeCount) {
1717 // report error 1718 // report error
1718 return NULL; 1719 return NULL;
1719 } 1720 }
1720 1721
1721 // Skia's "default" mode is srcover. NULL in SkPaint is interpreted as srcov er 1722 // Skia's "default" mode is srcover. NULL in SkPaint is interpreted as srcov er
1722 // so we can just return NULL from the factory. 1723 // so we can just return NULL from the factory.
1723 if (kSrcOver_Mode == mode) { 1724 if (kSrcOver_Mode == mode) {
1724 return NULL; 1725 return NULL;
1725 } 1726 }
1726 1727
1727 SK_DECLARE_STATIC_LAZY_PTR_ARRAY(SkXfermode, cached, kModeCount, create_mode );
1728 return SkSafeRef(cached[mode]); 1728 return SkSafeRef(cached[mode]);
1729 } 1729 }
1730 1730
1731 SkXfermodeProc SkXfermode::GetProc(Mode mode) { 1731 SkXfermodeProc SkXfermode::GetProc(Mode mode) {
1732 SkXfermodeProc proc = NULL; 1732 SkXfermodeProc proc = NULL;
1733 if ((unsigned)mode < kModeCount) { 1733 if ((unsigned)mode < kModeCount) {
1734 proc = gProcCoeffs[mode].fProc; 1734 proc = gProcCoeffs[mode].fProc;
1735 } 1735 }
1736 return proc; 1736 return proc;
1737 } 1737 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 } else { 1955 } else {
1956 proc16 = rec.fProc16_General; 1956 proc16 = rec.fProc16_General;
1957 } 1957 }
1958 } 1958 }
1959 return proc16; 1959 return proc16;
1960 } 1960 }
1961 1961
1962 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1962 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1963 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1963 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1964 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1964 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/fonts/SkRemotableFontMgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698