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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 2037413002: Add SkSourceGammaTreatment enum so we know how to create mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove leftover comments Created 4 years, 6 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/gpu/SkGpuDevice_drawTexture.cpp ('k') | src/gpu/SkGrPriv.h » ('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 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "SkGr.h" 9 #include "SkGr.h"
10 #include "SkGrPriv.h" 10 #include "SkGrPriv.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {} 322 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {}
323 private: 323 private:
324 GrUniqueKeyInvalidatedMessage fMsg; 324 GrUniqueKeyInvalidatedMessage fMsg;
325 325
326 void onChange() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>:: Post(fMsg); } 326 void onChange() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>:: Post(fMsg); }
327 }; 327 };
328 328
329 pixelRef->addGenIDChangeListener(new Invalidator(key)); 329 pixelRef->addGenIDChangeListener(new Invalidator(key));
330 } 330 }
331 331
332 GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b itmap) 332 GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b itmap,
333 bool gammaCorrect)
Brian Osman 2016/06/06 14:58:29 Here's the flag for the CPU mip-mapping call. We m
333 { 334 {
334 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps()); 335 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
335 if (kIndex_8_SkColorType != bitmap.colorType() && !bitmap.readyToDraw()) { 336 if (kIndex_8_SkColorType != bitmap.colorType() && !bitmap.readyToDraw()) {
336 GrTexture* texture = load_etc1_texture(ctx, bitmap, desc); 337 GrTexture* texture = load_etc1_texture(ctx, bitmap, desc);
337 if (texture) { 338 if (texture) {
338 return texture; 339 return texture;
339 } 340 }
340 } 341 }
341 342
342 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc)); 343 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 397
397 GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info, 398 GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
398 const GrMipLevel* texels, int mipLevelCount) { 399 const GrMipLevel* texels, int mipLevelCount) {
399 const GrCaps* caps = ctx->caps(); 400 const GrCaps* caps = ctx->caps();
400 return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDe sc(info, *caps), 401 return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDe sc(info, *caps),
401 SkBudgeted::kYes, texe ls, 402 SkBudgeted::kYes, texe ls,
402 mipLevelCount); 403 mipLevelCount);
403 } 404 }
404 405
405 GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap, 406 GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
406 const GrTextureParams& params) { 407 const GrTextureParams& params, bool gammaCor rect) {
407 if (bitmap.getTexture()) { 408 if (bitmap.getTexture()) {
408 return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params, nullptr); 409 return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params, gammaCorrect,
410 nullptr) ;
409 } 411 }
410 return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params); 412 return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, gammaCo rrect);
411 } 413 }
412 414
413 /////////////////////////////////////////////////////////////////////////////// 415 ///////////////////////////////////////////////////////////////////////////////
414 416
415 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass 417 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
416 // alpha info, that will be considered. 418 // alpha info, that will be considered.
417 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt, 419 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt,
418 const GrCaps& caps) { 420 const GrCaps& caps) {
419 // We intentionally ignore profile type for non-8888 formats. Anything we ca n't support 421 // We intentionally ignore profile type for non-8888 formats. Anything we ca n't support
420 // in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture. 422 // in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 515
514 // Setup the initial color considering the shader, the SkPaint color, and th e presence or not 516 // Setup the initial color considering the shader, the SkPaint color, and th e presence or not
515 // of per-vertex colors. 517 // of per-vertex colors.
516 SkAutoTUnref<const GrFragmentProcessor> aufp; 518 SkAutoTUnref<const GrFragmentProcessor> aufp;
517 const GrFragmentProcessor* shaderFP = nullptr; 519 const GrFragmentProcessor* shaderFP = nullptr;
518 if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc)) { 520 if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc)) {
519 if (shaderProcessor) { 521 if (shaderProcessor) {
520 shaderFP = *shaderProcessor; 522 shaderFP = *shaderProcessor;
521 } else if (const SkShader* shader = skPaint.getShader()) { 523 } else if (const SkShader* shader = skPaint.getShader()) {
522 aufp.reset(shader->asFragmentProcessor(context, viewM, nullptr, 524 aufp.reset(shader->asFragmentProcessor(context, viewM, nullptr,
523 skPaint.getFilterQuality())); 525 skPaint.getFilterQuality(), a llowSRGBInputs));
524 shaderFP = aufp; 526 shaderFP = aufp;
525 if (!shaderFP) { 527 if (!shaderFP) {
526 return false; 528 return false;
527 } 529 }
528 } 530 }
529 } 531 }
530 532
531 // Set this in below cases if the output of the shader/paint-color/paint-alp ha/primXfermode is 533 // Set this in below cases if the output of the shader/paint-color/paint-alp ha/primXfermode is
532 // a known constant value. In that case we can simply apply a color filter d uring this 534 // a known constant value. In that case we can simply apply a color filter d uring this
533 // conversion without converting the color filter to a GrFragmentProcessor. 535 // conversion without converting the color filter to a GrFragmentProcessor.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 const GrFragmentProcessor* fp, 687 const GrFragmentProcessor* fp,
686 bool textureIsAlphaOnly, 688 bool textureIsAlphaOnly,
687 bool allowSRGBInputs, 689 bool allowSRGBInputs,
688 GrPaint* grPaint) { 690 GrPaint* grPaint) {
689 SkAutoTUnref<const GrFragmentProcessor> shaderFP; 691 SkAutoTUnref<const GrFragmentProcessor> shaderFP;
690 if (textureIsAlphaOnly) { 692 if (textureIsAlphaOnly) {
691 if (const SkShader* shader = paint.getShader()) { 693 if (const SkShader* shader = paint.getShader()) {
692 shaderFP.reset(shader->asFragmentProcessor(context, 694 shaderFP.reset(shader->asFragmentProcessor(context,
693 viewM, 695 viewM,
694 nullptr, 696 nullptr,
695 paint.getFilterQuality()) ); 697 paint.getFilterQuality(),
698 allowSRGBInputs));
696 if (!shaderFP) { 699 if (!shaderFP) {
697 return false; 700 return false;
698 } 701 }
699 const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp }; 702 const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp };
700 shaderFP.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2)); 703 shaderFP.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2));
701 } else { 704 } else {
702 shaderFP.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp )); 705 shaderFP.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp ));
703 } 706 }
704 } else { 707 } else {
705 shaderFP.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 708 shaderFP.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 SkErrorInternals::SetError( kInvalidPaint_SkError, 770 SkErrorInternals::SetError( kInvalidPaint_SkError,
768 "Sorry, I don't understand the filtering " 771 "Sorry, I don't understand the filtering "
769 "mode you asked for. Falling back to " 772 "mode you asked for. Falling back to "
770 "MIPMaps."); 773 "MIPMaps.");
771 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 774 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
772 break; 775 break;
773 776
774 } 777 }
775 return textureFilterMode; 778 return textureFilterMode;
776 } 779 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice_drawTexture.cpp ('k') | src/gpu/SkGrPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698