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

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

Issue 1652053004: Add Histogram Macros to Skia (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fix unused constant error in release w/ enum-based constant Created 4 years, 10 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 | « include/core/SkPostConfig.h ('k') | src/gpu/SkGpuDevice.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkImage_Base.h" 10 #include "SkImage_Base.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * We have a 5 ways to try to return a texture (in sorted order) 233 * We have a 5 ways to try to return a texture (in sorted order)
234 * 234 *
235 * 1. Check the cache for a pre-existing one 235 * 1. Check the cache for a pre-existing one
236 * 2. Ask the generator to natively create one 236 * 2. Ask the generator to natively create one
237 * 3. Ask the generator to return a compressed form that the GPU might support 237 * 3. Ask the generator to return a compressed form that the GPU might support
238 * 4. Ask the generator to return YUV planes, which the GPU can convert 238 * 4. Ask the generator to return YUV planes, which the GPU can convert
239 * 5. Ask the generator to return RGB(A) data, which the GPU can convert 239 * 5. Ask the generator to return RGB(A) data, which the GPU can convert
240 */ 240 */
241 GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key , 241 GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key ,
242 const SkImage* client, SkImage::Cachin gHint chint) { 242 const SkImage* client, SkImage::Cachin gHint chint) {
243 // Values representing the various texture lock paths we can take. Used for logging the path
244 // taken to a histogram.
245 enum LockTexturePath {
246 kFailure_LockTexturePath,
247 kPreExisting_LockTexturePath,
248 kNative_LockTexturePath,
249 kCompressed_LockTexturePath,
250 kYUV_LockTexturePath,
251 kRGBA_LockTexturePath,
252 };
253
254 enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 };
ericrk 2016/02/05 22:59:02 This appears to be the style in Skia anyway for co
255
243 // 1. Check the cache for a pre-existing one 256 // 1. Check the cache for a pre-existing one
244 if (key.isValid()) { 257 if (key.isValid()) {
245 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKe y(key)) { 258 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKe y(key)) {
259 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexture Path,
260 kLockTexturePathCount);
246 return tex; 261 return tex;
247 } 262 }
248 } 263 }
249 264
250 // 2. Ask the generator to natively create one 265 // 2. Ask the generator to natively create one
251 { 266 {
252 ScopedGenerator generator(this); 267 ScopedGenerator generator(this);
253 SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width (), fInfo.height()); 268 SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width (), fInfo.height());
254 if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { 269 if (GrTexture* tex = generator->generateTexture(ctx, &subset)) {
270 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath,
271 kLockTexturePathCount);
255 return set_key_and_return(tex, key); 272 return set_key_and_return(tex, key);
256 } 273 }
257 } 274 }
258 275
259 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); 276 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo);
260 277
261 // 3. Ask the generator to return a compressed form that the GPU might suppo rt 278 // 3. Ask the generator to return a compressed form that the GPU might suppo rt
262 SkAutoTUnref<SkData> data(this->refEncoded(ctx)); 279 SkAutoTUnref<SkData> data(this->refEncoded(ctx));
263 if (data) { 280 if (data) {
264 GrTexture* tex = load_compressed_into_texture(ctx, data, desc); 281 GrTexture* tex = load_compressed_into_texture(ctx, data, desc);
265 if (tex) { 282 if (tex) {
283 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kCompressed_LockTextureP ath,
284 kLockTexturePathCount);
266 return set_key_and_return(tex, key); 285 return set_key_and_return(tex, key);
267 } 286 }
268 } 287 }
269 288
270 // 4. Ask the generator to return YUV planes, which the GPU can convert 289 // 4. Ask the generator to return YUV planes, which the GPU can convert
271 { 290 {
272 ScopedGenerator generator(this); 291 ScopedGenerator generator(this);
273 Generator_GrYUVProvider provider(generator); 292 Generator_GrYUVProvider provider(generator);
274 GrTexture* tex = provider.refAsTexture(ctx, desc, true); 293 GrTexture* tex = provider.refAsTexture(ctx, desc, true);
275 if (tex) { 294 if (tex) {
295 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
296 kLockTexturePathCount);
276 return set_key_and_return(tex, key); 297 return set_key_and_return(tex, key);
277 } 298 }
278 } 299 }
279 300
280 // 5. Ask the generator to return RGB(A) data, which the GPU can convert 301 // 5. Ask the generator to return RGB(A) data, which the GPU can convert
281 SkBitmap bitmap; 302 SkBitmap bitmap;
282 if (this->tryLockAsBitmap(&bitmap, client, chint)) { 303 if (this->tryLockAsBitmap(&bitmap, client, chint)) {
283 GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap); 304 GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap);
284 if (tex) { 305 if (tex) {
306 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath,
307 kLockTexturePathCount);
285 return set_key_and_return(tex, key); 308 return set_key_and_return(tex, key);
286 } 309 }
287 } 310 }
311 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
312 kLockTexturePathCount);
288 return nullptr; 313 return nullptr;
289 } 314 }
290 315
291 //////////////////////////////////////////////////////////////////////////////// /////////////////// 316 //////////////////////////////////////////////////////////////////////////////// ///////////////////
292 317
293 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s& params, 318 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s& params,
294 const SkImage* client, SkImage::Cach ingHint chint) { 319 const SkImage* client, SkImage::Cach ingHint chint) {
295 if (!ctx) { 320 if (!ctx) {
296 return nullptr; 321 return nullptr;
297 } 322 }
298 323
299 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par ams); 324 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par ams);
300 } 325 }
301 326
302 #else 327 #else
303 328
304 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&, 329 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&,
305 const SkImage* client, SkImage::Cach ingHint) { 330 const SkImage* client, SkImage::Cach ingHint) {
306 return nullptr; 331 return nullptr;
307 } 332 }
308 333
309 #endif 334 #endif
OLDNEW
« no previous file with comments | « include/core/SkPostConfig.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698