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

Side by Side Diff: src/effects/SkGammaColorFilter.cpp

Issue 2190573002: Add SkGammaColorFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ?? Created 4 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
« no previous file with comments | « include/effects/SkGammaColorFilter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkGammaColorFilter.h"
9
10 #include "SkReadBuffer.h"
11 #include "SkString.h"
12
13 #if SK_SUPPORT_GPU
14 #include "effects/GrGammaEffect.h"
15 #endif
16
17 void SkGammaColorFilter::filterSpan(const SkPMColor src[], int count,
18 SkPMColor dst[]) const {
19 // Gamma-correcting bytes to bytes is pretty questionable.
20 SkASSERT(0);
21 for (int i = 0; i < count; ++i) {
22 SkPMColor c = src[i];
23
24 // TODO: implement cpu gamma correction?
25 dst[i] = c;
26 }
27 }
28
29 sk_sp<SkColorFilter> SkGammaColorFilter::Make(SkScalar gamma) {
30 return sk_sp<SkColorFilter>(new SkGammaColorFilter(gamma));
31 }
32
33 SkGammaColorFilter::SkGammaColorFilter(SkScalar gamma) : fGamma(gamma) {}
34
35 sk_sp<SkFlattenable> SkGammaColorFilter::CreateProc(SkReadBuffer& buffer) {
36 SkScalar gamma = buffer.readScalar();
37
38 return Make(gamma);
39 }
40
41 void SkGammaColorFilter::flatten(SkWriteBuffer& buffer) const {
42 this->INHERITED::flatten(buffer);
43 buffer.writeScalar(fGamma);
44 }
45
46 #ifndef SK_IGNORE_TO_STRING
47 void SkGammaColorFilter::toString(SkString* str) const {
48 str->appendf("SkGammaColorFilter (%.2f)", fGamma);
49 }
50 #endif
51
52 #if SK_SUPPORT_GPU
53 sk_sp<GrFragmentProcessor> SkGammaColorFilter::asFragmentProcessor(GrContext*) c onst {
54 return GrGammaEffect::Make(fGamma);
55 }
56 #endif
OLDNEW
« no previous file with comments | « include/effects/SkGammaColorFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698