OLD | NEW |
---|---|
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 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkMessageBus.h" | 12 #include "SkMessageBus.h" |
13 #include "SkPixelRef.h" | 13 #include "SkPixelRef.h" |
14 #include "GrResourceCache.h" | 14 #include "GrResourceCache.h" |
15 #include "GrGpu.h" | 15 #include "GrGpu.h" |
16 #include "effects/GrDitherEffect.h" | |
16 #include "GrDrawTargetCaps.h" | 17 #include "GrDrawTargetCaps.h" |
17 | 18 |
18 #ifndef SK_IGNORE_ETC1_SUPPORT | 19 #ifndef SK_IGNORE_ETC1_SUPPORT |
19 # include "ktx.h" | 20 # include "ktx.h" |
20 # include "etc1.h" | 21 # include "etc1.h" |
21 #endif | 22 #endif |
22 | 23 |
23 /* Fill out buffer with the compressed format Ganesh expects from a colortable | 24 /* Fill out buffer with the compressed format Ganesh expects from a colortable |
24 based bitmap. [palette (colortable) + indices]. | 25 based bitmap. [palette (colortable) + indices]. |
25 | 26 |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 if (constantColor) { | 459 if (constantColor) { |
459 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); | 460 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); |
460 grPaint->setColor(SkColor2GrColor(filtered)); | 461 grPaint->setColor(SkColor2GrColor(filtered)); |
461 } else { | 462 } else { |
462 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(context)); | 463 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(context)); |
463 if (NULL != effect.get()) { | 464 if (NULL != effect.get()) { |
464 grPaint->addColorEffect(effect); | 465 grPaint->addColorEffect(effect); |
465 } | 466 } |
466 } | 467 } |
467 } | 468 } |
469 | |
robertphillips
2014/06/11 17:20:24
Wrap this in SK_IGNORE_GPU_DITHER and add it to gy
krajcevski
2014/06/11 22:33:18
Done.
| |
470 // If the dither flag is set, then we need to see if the underlying context | |
471 // supports it. If not, then install a dither effect. | |
472 if (skPaint.isDither()) { | |
473 // What are we rendering into? | |
474 const GrRenderTarget *target = context->getRenderTarget(); | |
475 if (NULL == target) { | |
476 target = context->getGpu()->getDrawState().getRenderTarget(); | |
477 } | |
478 SkASSERT(NULL != target); | |
479 | |
480 if (target->config() == kRGBA_8888_GrPixelConfig || | |
481 target->config() == kBGRA_8888_GrPixelConfig) { | |
482 // The dither flag is set and the target is likely | |
483 // not going to be dithered by the GPU. | |
484 SkAutoTUnref<GrEffectRef> effect(GrDitherEffect::Create()); | |
485 if (NULL != effect.get()) { | |
486 grPaint->addColorEffect(effect); | |
487 grPaint->setDither(false); | |
488 } | |
489 } | |
490 } | |
468 } | 491 } |
469 | 492 |
470 /** | 493 /** |
471 * Unlike GrContext::AutoMatrix, this doesn't require setting a new matrix. GrCo ntext::AutoMatrix | 494 * Unlike GrContext::AutoMatrix, this doesn't require setting a new matrix. GrCo ntext::AutoMatrix |
472 * likes to set the new matrix in its constructor because it is usually necessar y to simulataneously | 495 * likes to set the new matrix in its constructor because it is usually necessar y to simulataneously |
473 * update a GrPaint. This AutoMatrix is used while initially setting up GrPaint, however. | 496 * update a GrPaint. This AutoMatrix is used while initially setting up GrPaint, however. |
474 */ | 497 */ |
475 class AutoMatrix { | 498 class AutoMatrix { |
476 public: | 499 public: |
477 AutoMatrix(GrContext* context) { | 500 AutoMatrix(GrContext* context) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 copy.setShader(NULL); | 544 copy.setShader(NULL); |
522 // modulate the paint alpha by the shader's solid color alpha | 545 // modulate the paint alpha by the shader's solid color alpha |
523 U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); | 546 U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); |
524 copy.setColor(SkColorSetA(color, newA)); | 547 copy.setColor(SkColorSetA(color, newA)); |
525 SkPaint2GrPaintNoShader(context, copy, false, constantColor, grPaint ); | 548 SkPaint2GrPaintNoShader(context, copy, false, constantColor, grPaint ); |
526 } else { | 549 } else { |
527 SkPaint2GrPaintNoShader(context, skPaint, false, constantColor, grPa int); | 550 SkPaint2GrPaintNoShader(context, skPaint, false, constantColor, grPa int); |
528 } | 551 } |
529 } | 552 } |
530 } | 553 } |
OLD | NEW |