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

Side by Side Diff: gm/mipmap.cpp

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 4 years, 6 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 | « gm/gamma.cpp ('k') | gm/showmiplevels.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 29 matching lines...) Expand all
40 // canvas->drawText(str.c_str(), str.size(), 300, 100, paint); 40 // canvas->drawText(str.c_str(), str.size(), 300, 100, paint);
41 41
42 canvas->translate(20, 20); 42 canvas->translate(20, 20);
43 for (int i = 0; i < 4; ++i) { 43 for (int i = 0; i < 4; ++i) {
44 paint.setFilterQuality(SkFilterQuality(i)); 44 paint.setFilterQuality(SkFilterQuality(i));
45 canvas->drawImageRect(img.get(), dst, &paint); 45 canvas->drawImageRect(img.get(), dst, &paint);
46 canvas->translate(0, 20); 46 canvas->translate(0, 20);
47 } 47 }
48 canvas->drawImage(img.get(), 20, 20, nullptr); 48 canvas->drawImage(img.get(), 20, 20, nullptr);
49 } 49 }
50
51 //////////////////////////////////////////////////////////////////////////////// ///////////////////
52
53 // create a circle image computed raw, so we can wrap it as a linear or srgb ima ge
54 static sk_sp<SkImage> make(sk_sp<SkColorSpace> cs) {
55 const int N = 100;
56 SkImageInfo info = SkImageInfo::Make(N, N, kN32_SkColorType, kPremul_SkAlpha Type, cs);
57 SkBitmap bm;
58 bm.allocPixels(info);
59
60 for (int y = 0; y < N; ++y) {
61 for (int x = 0; x < N; ++x) {
62 *bm.getAddr32(x, y) = (x ^ y) & 1 ? 0xFFFFFFFF : 0xFF000000;
63 }
64 }
65 bm.setImmutable();
66 return SkImage::MakeFromBitmap(bm);
67 }
68
69 static void show_mips(SkCanvas* canvas, SkImage* img) {
70 SkPaint paint;
71 paint.setFilterQuality(kMedium_SkFilterQuality);
72
73 SkRect dst = SkRect::MakeIWH(img->width(), img->height());
74 while (dst.width() > 5) {
75 canvas->drawImageRect(img, dst, &paint);
76 dst.offset(dst.width() + 10, 0);
77 dst.fRight = dst.fLeft + SkScalarHalf(dst.width());
78 dst.fBottom = dst.fTop + SkScalarHalf(dst.height());
79 }
80 }
81
82 /*
83 * Ensure that in L32 drawing mode, both images/mips look the same as each othe r, and
84 * their mips are darker than the original (since the mips should ignore the ga mma in L32).
85 *
86 * Ensure that in S32 drawing mode, all images/mips look the same, and look cor rect (i.e.
87 * the mip levels match the original in brightness).
88 */
89 DEF_SIMPLE_GM(mipmap_srgb, canvas, 260, 230) {
90 sk_sp<SkImage> limg = make(nullptr);
91 sk_sp<SkImage> simg = make(SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) );
92
93 canvas->translate(10, 10);
94 show_mips(canvas, limg.get());
95 canvas->translate(0, limg->height() + 10.0f);
96 show_mips(canvas, simg.get());
97 }
98
OLDNEW
« no previous file with comments | « gm/gamma.cpp ('k') | gm/showmiplevels.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698