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

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: capitalization 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/GrDefaultXferProcessor.h"
21 #include "effects/GrPorterDuffXferProcessor.h"
18 #include "effects/GrYUVtoRGBEffect.h" 22 #include "effects/GrYUVtoRGBEffect.h"
19 23
20 #ifndef SK_IGNORE_ETC1_SUPPORT 24 #ifndef SK_IGNORE_ETC1_SUPPORT
21 # include "ktx.h" 25 # include "ktx.h"
22 # include "etc1.h" 26 # include "etc1.h"
23 #endif 27 #endif
24 28
25 /* Fill out buffer with the compressed format Ganesh expects from a colortable 29 /* Fill out buffer with the compressed format Ganesh expects from a colortable
26 based bitmap. [palette (colortable) + indices]. 30 based bitmap. [palette (colortable) + indices].
27 31
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor, 464 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
461 bool constantColor, GrPaint* grPaint) { 465 bool constantColor, GrPaint* grPaint) {
462 466
463 grPaint->setDither(skPaint.isDither()); 467 grPaint->setDither(skPaint.isDither());
464 grPaint->setAntiAlias(skPaint.isAntiAlias()); 468 grPaint->setAntiAlias(skPaint.isAntiAlias());
465 469
466 SkXfermode::Coeff sm; 470 SkXfermode::Coeff sm;
467 SkXfermode::Coeff dm; 471 SkXfermode::Coeff dm;
468 472
469 SkXfermode* mode = skPaint.getXfermode(); 473 SkXfermode* mode = skPaint.getXfermode();
470 GrFragmentProcessor* xferProcessor = NULL; 474 GrFragmentProcessor* fragmentProcessor = NULL;
471 if (SkXfermode::asFragmentProcessorOrCoeff(mode, &xferProcessor, &sm, &dm)) { 475 GrXPFactory* xpFactory = NULL;
472 if (xferProcessor) { 476 if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xp Factory,
473 grPaint->addColorProcessor(xferProcessor)->unref(); 477 &sm, &dm)) {
478 if (fragmentProcessor) {
479 SkASSERT(NULL == xpFactory);
480 grPaint->addColorProcessor(fragmentProcessor)->unref();
481 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff,
482 SkXfermode::kZero_Coeff);
474 sm = SkXfermode::kOne_Coeff; 483 sm = SkXfermode::kOne_Coeff;
475 dm = SkXfermode::kZero_Coeff; 484 dm = SkXfermode::kZero_Coeff;
476 } 485 }
477 } else { 486 } else {
478 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");)
479 // Fall back to src-over 487 // Fall back to src-over
488 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff,
489 SkXfermode::kISA_Coeff);
480 sm = SkXfermode::kOne_Coeff; 490 sm = SkXfermode::kOne_Coeff;
481 dm = SkXfermode::kISA_Coeff; 491 dm = SkXfermode::kISA_Coeff;
482 } 492 }
493 SkASSERT(xpFactory);
494 grPaint->setXPFactory(xpFactory)->unref();
483 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); 495 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));
484 496
485 //set the color of the paint to the one of the parameter 497 //set the color of the paint to the one of the parameter
486 grPaint->setColor(paintColor); 498 grPaint->setColor(paintColor);
487 499
488 SkColorFilter* colorFilter = skPaint.getColorFilter(); 500 SkColorFilter* colorFilter = skPaint.getColorFilter();
489 if (colorFilter) { 501 if (colorFilter) {
490 // if the source color is a constant then apply the filter here once rat her than per pixel 502 // if the source color is a constant then apply the filter here once rat her than per pixel
491 // in a shader. 503 // in a shader.
492 if (constantColor) { 504 if (constantColor) {
493 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); 505 SkColor filtered = colorFilter->filterColor(skPaint.getColor());
494 grPaint->setColor(SkColor2GrColor(filtered)); 506 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) { 585 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
574 grPaint->addColorProcessor(fp)->unref(); 586 grPaint->addColorProcessor(fp)->unref();
575 constantColor = false; 587 constantColor = false;
576 } 588 }
577 } 589 }
578 590
579 // The grcolor is automatically set when calling asFragmentProcessor. 591 // 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. 592 // 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 ); 593 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
582 } 594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698