| 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 | 9 |
| 10 #include "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 SkDebugf("---- failed to create texture for cache [%d %d]\n", | 396 SkDebugf("---- failed to create texture for cache [%d %d]\n", |
| 397 bitmap.width(), bitmap.height()); | 397 bitmap.width(), bitmap.height()); |
| 398 } | 398 } |
| 399 return result; | 399 return result; |
| 400 } | 400 } |
| 401 | 401 |
| 402 /////////////////////////////////////////////////////////////////////////////// | 402 /////////////////////////////////////////////////////////////////////////////// |
| 403 | 403 |
| 404 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass | 404 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass |
| 405 // alpha info, that will be considered. | 405 // alpha info, that will be considered. |
| 406 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) { | 406 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf
ileType pt) { |
| 407 switch (ct) { | 407 switch (ct) { |
| 408 case kUnknown_SkColorType: | 408 case kUnknown_SkColorType: |
| 409 return kUnknown_GrPixelConfig; | 409 return kUnknown_GrPixelConfig; |
| 410 case kAlpha_8_SkColorType: | 410 case kAlpha_8_SkColorType: |
| 411 return kAlpha_8_GrPixelConfig; | 411 return kAlpha_8_GrPixelConfig; |
| 412 case kRGB_565_SkColorType: | 412 case kRGB_565_SkColorType: |
| 413 return kRGB_565_GrPixelConfig; | 413 return kRGB_565_GrPixelConfig; |
| 414 case kARGB_4444_SkColorType: | 414 case kARGB_4444_SkColorType: |
| 415 return kRGBA_4444_GrPixelConfig; | 415 return kRGBA_4444_GrPixelConfig; |
| 416 case kRGBA_8888_SkColorType: | 416 case kRGBA_8888_SkColorType: |
| 417 if (kSRGB_SkColorProfileType == pt) { |
| 418 return kSRGBA_8888_GrPixelConfig; |
| 419 } |
| 417 return kRGBA_8888_GrPixelConfig; | 420 return kRGBA_8888_GrPixelConfig; |
| 418 case kBGRA_8888_SkColorType: | 421 case kBGRA_8888_SkColorType: |
| 419 return kBGRA_8888_GrPixelConfig; | 422 return kBGRA_8888_GrPixelConfig; |
| 420 case kIndex_8_SkColorType: | 423 case kIndex_8_SkColorType: |
| 421 return kIndex_8_GrPixelConfig; | 424 return kIndex_8_GrPixelConfig; |
| 422 } | 425 } |
| 423 SkASSERT(0); // shouldn't get here | 426 SkASSERT(0); // shouldn't get here |
| 424 return kUnknown_GrPixelConfig; | 427 return kUnknown_GrPixelConfig; |
| 425 } | 428 } |
| 426 | 429 |
| 427 bool GrPixelConfig2ColorType(GrPixelConfig config, SkColorType* ctOut) { | 430 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut, |
| 431 SkColorProfileType* ptOut) { |
| 428 SkColorType ct; | 432 SkColorType ct; |
| 433 SkColorProfileType pt = kLinear_SkColorProfileType; |
| 429 switch (config) { | 434 switch (config) { |
| 430 case kAlpha_8_GrPixelConfig: | 435 case kAlpha_8_GrPixelConfig: |
| 431 ct = kAlpha_8_SkColorType; | 436 ct = kAlpha_8_SkColorType; |
| 432 break; | 437 break; |
| 433 case kIndex_8_GrPixelConfig: | 438 case kIndex_8_GrPixelConfig: |
| 434 ct = kIndex_8_SkColorType; | 439 ct = kIndex_8_SkColorType; |
| 435 break; | 440 break; |
| 436 case kRGB_565_GrPixelConfig: | 441 case kRGB_565_GrPixelConfig: |
| 437 ct = kRGB_565_SkColorType; | 442 ct = kRGB_565_SkColorType; |
| 438 break; | 443 break; |
| 439 case kRGBA_4444_GrPixelConfig: | 444 case kRGBA_4444_GrPixelConfig: |
| 440 ct = kARGB_4444_SkColorType; | 445 ct = kARGB_4444_SkColorType; |
| 441 break; | 446 break; |
| 442 case kRGBA_8888_GrPixelConfig: | 447 case kRGBA_8888_GrPixelConfig: |
| 443 ct = kRGBA_8888_SkColorType; | 448 ct = kRGBA_8888_SkColorType; |
| 444 break; | 449 break; |
| 445 case kBGRA_8888_GrPixelConfig: | 450 case kBGRA_8888_GrPixelConfig: |
| 446 ct = kBGRA_8888_SkColorType; | 451 ct = kBGRA_8888_SkColorType; |
| 447 break; | 452 break; |
| 453 case kSRGBA_8888_GrPixelConfig: |
| 454 ct = kRGBA_8888_SkColorType; |
| 455 pt = kSRGB_SkColorProfileType; |
| 456 break; |
| 448 default: | 457 default: |
| 449 return false; | 458 return false; |
| 450 } | 459 } |
| 451 if (ctOut) { | 460 if (ctOut) { |
| 452 *ctOut = ct; | 461 *ctOut = ct; |
| 453 } | 462 } |
| 463 if (ptOut) { |
| 464 *ptOut = pt; |
| 465 } |
| 454 return true; | 466 return true; |
| 455 } | 467 } |
| 456 | 468 |
| 457 /////////////////////////////////////////////////////////////////////////////// | 469 /////////////////////////////////////////////////////////////////////////////// |
| 458 | 470 |
| 459 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
paintColor, | 471 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
paintColor, |
| 460 bool constantColor, GrPaint* grPaint) { | 472 bool constantColor, GrPaint* grPaint) { |
| 461 | 473 |
| 462 grPaint->setDither(skPaint.isDither()); | 474 grPaint->setDither(skPaint.isDither()); |
| 463 grPaint->setAntiAlias(skPaint.isAntiAlias()); | 475 grPaint->setAntiAlias(skPaint.isAntiAlias()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { | 558 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { |
| 547 grPaint->addColorProcessor(fp)->unref(); | 559 grPaint->addColorProcessor(fp)->unref(); |
| 548 constantColor = false; | 560 constantColor = false; |
| 549 } | 561 } |
| 550 } | 562 } |
| 551 | 563 |
| 552 // The grcolor is automatically set when calling asFragmentProcessor. | 564 // The grcolor is automatically set when calling asFragmentProcessor. |
| 553 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 565 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
| 554 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
); | 566 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
); |
| 555 } | 567 } |
| OLD | NEW |