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

Side by Side Diff: src/core/SkPaint.cpp

Issue 492963002: extend SkShader to report a luminance-color to be used for gamma correction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase, add SkShader::CreateColorShader(c) Created 6 years, 4 months 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkAutoKern.h" 10 #include "SkAutoKern.h"
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 SkPaint::Hinting h = paint.getHinting(); 1490 SkPaint::Hinting h = paint.getHinting();
1491 if (paint.isLinearText()) { 1491 if (paint.isLinearText()) {
1492 h = SkPaint::kNo_Hinting; 1492 h = SkPaint::kNo_Hinting;
1493 } 1493 }
1494 return h; 1494 return h;
1495 } 1495 }
1496 1496
1497 // return true if the paint is just a single color (i.e. not a shader). If its 1497 // return true if the paint is just a single color (i.e. not a shader). If its
1498 // a shader, then we can't compute a const luminance for it :( 1498 // a shader, then we can't compute a const luminance for it :(
1499 static bool justAColor(const SkPaint& paint, SkColor* color) { 1499 static bool justAColor(const SkPaint& paint, SkColor* color) {
1500 if (paint.getShader()) { 1500 SkColor c = paint.getColor();
1501
1502 SkShader* shader = paint.getShader();
1503 if (shader && !shader->asLuminanceColor(&c)) {
1501 return false; 1504 return false;
1502 } 1505 }
1503 SkColor c = paint.getColor();
1504 if (paint.getColorFilter()) { 1506 if (paint.getColorFilter()) {
1505 c = paint.getColorFilter()->filterColor(c); 1507 c = paint.getColorFilter()->filterColor(c);
1506 } 1508 }
1507 if (color) { 1509 if (color) {
1508 *color = c; 1510 *color = c;
1509 } 1511 }
1510 return true; 1512 return true;
1511 } 1513 }
1512 1514
1513 static SkColor computeLuminanceColor(const SkPaint& paint) { 1515 static SkColor computeLuminanceColor(const SkPaint& paint) {
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 F_UNREF(Looper, readDrawLooper); 2678 F_UNREF(Looper, readDrawLooper);
2677 F_UNREF(ImageFilter, readImageFilter); 2679 F_UNREF(ImageFilter, readImageFilter);
2678 F(Typeface, readTypeface); 2680 F(Typeface, readTypeface);
2679 #undef F 2681 #undef F
2680 #undef F_UNREF 2682 #undef F_UNREF
2681 if (dirty & kAnnotation_DirtyBit) { 2683 if (dirty & kAnnotation_DirtyBit) {
2682 paint->setAnnotation(SkAnnotation::Create(buffer))->unref(); 2684 paint->setAnnotation(SkAnnotation::Create(buffer))->unref();
2683 } 2685 }
2684 SkASSERT(dirty == paint->fDirtyBits); 2686 SkASSERT(dirty == paint->fDirtyBits);
2685 } 2687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698