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

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: Review changes 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
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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor, 463 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
461 bool constantColor, GrPaint* grPaint) { 464 bool constantColor, GrPaint* grPaint) {
462 465
463 grPaint->setDither(skPaint.isDither()); 466 grPaint->setDither(skPaint.isDither());
464 grPaint->setAntiAlias(skPaint.isAntiAlias()); 467 grPaint->setAntiAlias(skPaint.isAntiAlias());
465 468
466 SkXfermode::Coeff sm; 469 SkXfermode::Coeff sm;
467 SkXfermode::Coeff dm; 470 SkXfermode::Coeff dm;
468 471
469 SkXfermode* mode = skPaint.getXfermode(); 472 SkXfermode* mode = skPaint.getXfermode();
470 GrFragmentProcessor* xferProcessor = NULL; 473 GrFragmentProcessor* fragmentProcessor = NULL;
471 if (SkXfermode::asFragmentProcessorOrCoeff(mode, &xferProcessor, &sm, &dm)) { 474 GrXPFactory* xpFactory = NULL;
472 if (xferProcessor) { 475 if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xp Factory,
473 grPaint->addColorProcessor(xferProcessor)->unref(); 476 &sm, &dm)) {
477 if (fragmentProcessor) {
478 SkASSERT(NULL == xpFactory);
479 grPaint->addColorProcessor(fragmentProcessor)->unref();
480 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff,
481 SkXfermode::kZero_Coeff);
474 sm = SkXfermode::kOne_Coeff; 482 sm = SkXfermode::kOne_Coeff;
475 dm = SkXfermode::kZero_Coeff; 483 dm = SkXfermode::kZero_Coeff;
476 } 484 }
477 } else { 485 } else {
478 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");)
479 // Fall back to src-over 486 // Fall back to src-over
487 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff,
488 SkXfermode::kISA_Coeff);
480 sm = SkXfermode::kOne_Coeff; 489 sm = SkXfermode::kOne_Coeff;
481 dm = SkXfermode::kISA_Coeff; 490 dm = SkXfermode::kISA_Coeff;
482 } 491 }
492 SkASSERT(xpFactory);
493 grPaint->setXPFactory(xpFactory)->unref();
483 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); 494 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));
484 495
485 //set the color of the paint to the one of the parameter 496 //set the color of the paint to the one of the parameter
486 grPaint->setColor(paintColor); 497 grPaint->setColor(paintColor);
487 498
488 SkColorFilter* colorFilter = skPaint.getColorFilter(); 499 SkColorFilter* colorFilter = skPaint.getColorFilter();
489 if (colorFilter) { 500 if (colorFilter) {
490 // if the source color is a constant then apply the filter here once rat her than per pixel 501 // if the source color is a constant then apply the filter here once rat her than per pixel
491 // in a shader. 502 // in a shader.
492 if (constantColor) { 503 if (constantColor) {
493 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); 504 SkColor filtered = colorFilter->filterColor(skPaint.getColor());
494 grPaint->setColor(SkColor2GrColor(filtered)); 505 grPaint->setColor(SkColor2GrColor(filtered));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { 584 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
574 grPaint->addColorProcessor(fp)->unref(); 585 grPaint->addColorProcessor(fp)->unref();
575 constantColor = false; 586 constantColor = false;
576 } 587 }
577 } 588 }
578 589
579 // The grcolor is automatically set when calling asFragmentProcessor. 590 // The grcolor is automatically set when calling asFragmentProcessor.
580 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 591 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
581 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 592 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
582 } 593 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698