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

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

Issue 2185043002: Fix leak of srgb/adobesrgb colorspace objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | 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 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkColorSpace.h" 8 #include "SkColorSpace.h"
9 #include "SkColorSpace_Base.h" 9 #include "SkColorSpace_Base.h"
10 #include "SkColorSpacePriv.h" 10 #include "SkColorSpacePriv.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 return sk_sp<SkColorSpace>(new SkColorSpace_Base(gammaNamed, toXYZD50, kUnkn own_Named)); 121 return sk_sp<SkColorSpace>(new SkColorSpace_Base(gammaNamed, toXYZD50, kUnkn own_Named));
122 } 122 }
123 123
124 sk_sp<SkColorSpace> SkColorSpace::NewRGB(GammaNamed gammaNamed, const SkMatrix44 & toXYZD50) { 124 sk_sp<SkColorSpace> SkColorSpace::NewRGB(GammaNamed gammaNamed, const SkMatrix44 & toXYZD50) {
125 return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50); 125 return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50);
126 } 126 }
127 127
128 sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) { 128 sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
129 static SkOnce sRGBOnce; 129 static SkOnce sRGBOnce;
130 static SkColorSpace* sRGB; 130 static sk_sp<SkColorSpace> sRGB;
131 static SkOnce adobeRGBOnce; 131 static SkOnce adobeRGBOnce;
132 static SkColorSpace* adobeRGB; 132 static sk_sp<SkColorSpace> adobeRGB;
133 133
134 switch (named) { 134 switch (named) {
135 case kSRGB_Named: { 135 case kSRGB_Named: {
136 sRGBOnce([] { 136 sRGBOnce([] {
137 SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); 137 SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
138 srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50); 138 srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50);
139 sRGB = new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50, kSR GB_Named); 139 sRGB.reset(new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50, kSRGB_Named));
140 }); 140 });
141 return sk_ref_sp(sRGB); 141 return sRGB;
142 } 142 }
143 case kAdobeRGB_Named: { 143 case kAdobeRGB_Named: {
144 adobeRGBOnce([] { 144 adobeRGBOnce([] {
145 SkMatrix44 adobergbToxyzD50(SkMatrix44::kUninitialized_Construct or); 145 SkMatrix44 adobergbToxyzD50(SkMatrix44::kUninitialized_Construct or);
146 adobergbToxyzD50.set3x3RowMajorf(gAdobeRGB_toXYZD50); 146 adobergbToxyzD50.set3x3RowMajorf(gAdobeRGB_toXYZD50);
147 adobeRGB = new SkColorSpace_Base(k2Dot2Curve_GammaNamed, adoberg bToxyzD50, 147 adobeRGB.reset(new SkColorSpace_Base(k2Dot2Curve_GammaNamed, ado bergbToxyzD50,
148 kAdobeRGB_Named); 148 kAdobeRGB_Named));
149 }); 149 });
150 return sk_ref_sp(adobeRGB); 150 return adobeRGB;
151 } 151 }
152 default: 152 default:
153 break; 153 break;
154 } 154 }
155 return nullptr; 155 return nullptr;
156 } 156 }
157 157
158 //////////////////////////////////////////////////////////////////////////////// /////////////////// 158 //////////////////////////////////////////////////////////////////////////////// ///////////////////
159 159
160 enum Version { 160 enum Version {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 uint32_t profileSize = *((uint32_t*) data); 298 uint32_t profileSize = *((uint32_t*) data);
299 data = SkTAddOffset<const void>(data, sizeof(uint32_t)); 299 data = SkTAddOffset<const void>(data, sizeof(uint32_t));
300 length -= sizeof(uint32_t); 300 length -= sizeof(uint32_t);
301 if (length < profileSize) { 301 if (length < profileSize) {
302 return nullptr; 302 return nullptr;
303 } 303 }
304 304
305 return NewICC(data, profileSize); 305 return NewICC(data, profileSize);
306 } 306 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698