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

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

Issue 751283002: Add XferProcessor factory in GrPaint and GrDrawState. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comiple bug Created 6 years 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/GrProcessor.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.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 #include "SkGr.h" 8 #include "SkGr.h"
9
10 #include "GrDrawTargetCaps.h"
11 #include "GrGpu.h"
12 #include "GrXferProcessor.h"
9 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
10 #include "SkConfig8888.h" 14 #include "SkConfig8888.h"
11 #include "SkData.h" 15 #include "SkData.h"
12 #include "SkMessageBus.h" 16 #include "SkMessageBus.h"
13 #include "SkPixelRef.h" 17 #include "SkPixelRef.h"
14 #include "SkTextureCompressor.h" 18 #include "SkTextureCompressor.h"
15 #include "GrGpu.h"
16 #include "effects/GrDitherEffect.h" 19 #include "effects/GrDitherEffect.h"
17 #include "GrDrawTargetCaps.h" 20 #include "effects/GrPorterDuffXferProcessor.h"
18 #include "effects/GrYUVtoRGBEffect.h" 21 #include "effects/GrYUVtoRGBEffect.h"
19 22
20 #ifndef SK_IGNORE_ETC1_SUPPORT 23 #ifndef SK_IGNORE_ETC1_SUPPORT
21 # include "ktx.h" 24 # include "ktx.h"
22 # include "etc1.h" 25 # include "etc1.h"
23 #endif 26 #endif
24 27
25 /* Fill out buffer with the compressed format Ganesh expects from a colortable 28 /* Fill out buffer with the compressed format Ganesh expects from a colortable
26 based bitmap. [palette (colortable) + indices]. 29 based bitmap. [palette (colortable) + indices].
27 30
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor, 461 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
459 bool constantColor, GrPaint* grPaint) { 462 bool constantColor, GrPaint* grPaint) {
460 463
461 grPaint->setDither(skPaint.isDither()); 464 grPaint->setDither(skPaint.isDither());
462 grPaint->setAntiAlias(skPaint.isAntiAlias()); 465 grPaint->setAntiAlias(skPaint.isAntiAlias());
463 466
464 SkXfermode::Coeff sm; 467 SkXfermode::Coeff sm;
465 SkXfermode::Coeff dm; 468 SkXfermode::Coeff dm;
466 469
467 SkXfermode* mode = skPaint.getXfermode(); 470 SkXfermode* mode = skPaint.getXfermode();
468 GrFragmentProcessor* xferProcessor = NULL; 471 GrFragmentProcessor* fragmentProcessor = NULL;
469 if (SkXfermode::asFragmentProcessorOrCoeff(mode, &xferProcessor, &sm, &dm)) { 472 GrXPFactory* xpFactory = NULL;
470 if (xferProcessor) { 473 if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xp Factory,
471 grPaint->addColorProcessor(xferProcessor)->unref(); 474 &sm, &dm)) {
475 if (fragmentProcessor) {
476 SkASSERT(NULL == xpFactory);
477 grPaint->addColorProcessor(fragmentProcessor)->unref();
478 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff,
479 SkXfermode::kZero_Coeff);
472 sm = SkXfermode::kOne_Coeff; 480 sm = SkXfermode::kOne_Coeff;
473 dm = SkXfermode::kZero_Coeff; 481 dm = SkXfermode::kZero_Coeff;
474 } 482 }
475 } else { 483 } else {
476 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");)
477 // Fall back to src-over 484 // Fall back to src-over
485 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff,
486 SkXfermode::kISA_Coeff);
478 sm = SkXfermode::kOne_Coeff; 487 sm = SkXfermode::kOne_Coeff;
479 dm = SkXfermode::kISA_Coeff; 488 dm = SkXfermode::kISA_Coeff;
480 } 489 }
490 SkASSERT(xpFactory);
491 grPaint->setXPFactory(xpFactory)->unref();
481 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); 492 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));
482 493
483 //set the color of the paint to the one of the parameter 494 //set the color of the paint to the one of the parameter
484 grPaint->setColor(paintColor); 495 grPaint->setColor(paintColor);
485 496
486 SkColorFilter* colorFilter = skPaint.getColorFilter(); 497 SkColorFilter* colorFilter = skPaint.getColorFilter();
487 if (colorFilter) { 498 if (colorFilter) {
488 // if the source color is a constant then apply the filter here once rat her than per pixel 499 // if the source color is a constant then apply the filter here once rat her than per pixel
489 // in a shader. 500 // in a shader.
490 if (constantColor) { 501 if (constantColor) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { 582 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
572 grPaint->addColorProcessor(fp)->unref(); 583 grPaint->addColorProcessor(fp)->unref();
573 constantColor = false; 584 constantColor = false;
574 } 585 }
575 } 586 }
576 587
577 // The grcolor is automatically set when calling asFragmentProcessor. 588 // The grcolor is automatically set when calling asFragmentProcessor.
578 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 589 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
579 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 590 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
580 } 591 }
OLDNEW
« no previous file with comments | « src/gpu/GrProcessor.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698