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

Side by Side Diff: gm/SkLinearBitmapPipelineGM.cpp

Issue 1712653002: Switch to pixmap in API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « bench/SkLinearBitmapPipelineBench.cpp ('k') | src/core/SkLinearBitmapPipeline.h » ('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 2016 Google Inc. 2 * Copyright 2016 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 "SkColor.h" 10 #include "SkColor.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 SkPixmap pmsrc; 91 SkPixmap pmsrc;
92 bmsrc.peekPixels(&pmsrc); 92 bmsrc.peekPixels(&pmsrc);
93 93
94 SkBitmap bmdst; 94 SkBitmap bmdst;
95 bmdst.allocN32Pixels(ir.width(), ir.height()); 95 bmdst.allocN32Pixels(ir.width(), ir.height());
96 bmdst.eraseColor(0xFFFFFFFF); 96 bmdst.eraseColor(0xFFFFFFFF);
97 SkPixmap pmdst; 97 SkPixmap pmdst;
98 bmdst.peekPixels(&pmdst); 98 bmdst.peekPixels(&pmdst);
99 99
100 SkPM4f* dstBits = new SkPM4f[ir.width()]; 100 SkPM4f* dstBits = new SkPM4f[ir.width()];
101 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), kPremul_SkA lphaType);
102 101
103 SkMatrix inv; 102 SkMatrix inv;
104 bool trash = mat->invert(&inv); 103 bool trash = mat->invert(&inv);
105 sk_ignore_unused_variable(trash); 104 sk_ignore_unused_variable(trash);
106 105
107 SkFilterQuality filterQuality; 106 SkFilterQuality filterQuality;
108 if (useBilerp) { 107 if (useBilerp) {
109 filterQuality = SkFilterQuality::kLow_SkFilterQuality; 108 filterQuality = SkFilterQuality::kLow_SkFilterQuality;
110 } else { 109 } else {
111 filterQuality = SkFilterQuality::kNone_SkFilterQuality; 110 filterQuality = SkFilterQuality::kNone_SkFilterQuality;
112 } 111 }
113 112
114 uint32_t flags = 0; 113 uint32_t flags = 0;
115 //if (kSRGB_SkColorProfileType == profile) { 114 //if (kSRGB_SkColorProfileType == profile) {
116 //flags |= SkXfermode::kDstIsSRGB_PM4fFlag; 115 //flags |= SkXfermode::kDstIsSRGB_PM4fFlag;
117 //} 116 //}
118 const SkXfermode::PM4fState state { nullptr, flags }; 117 const SkXfermode::PM4fState state { nullptr, flags };
119 auto procN = SkXfermode::GetPM4fProcN(SkXfermode::kSrcOver_Mode, flags); 118 auto procN = SkXfermode::GetPM4fProcN(SkXfermode::kSrcOver_Mode, flags);
120 119
121 SkLinearBitmapPipeline pipeline{ 120 SkLinearBitmapPipeline pipeline{
122 inv, filterQuality, 121 inv, filterQuality,
123 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, 122 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, pmsrc};
124 info, pmsrc.addr32()};
125 123
126 for (int y = 0; y < ir.height(); y++) { 124 for (int y = 0; y < ir.height(); y++) {
127 pipeline.shadeSpan4f(0, y, dstBits, ir.width()); 125 pipeline.shadeSpan4f(0, y, dstBits, ir.width());
128 procN(state, pmdst.writable_addr32(0, y), dstBits, ir.width(), nullptr); 126 procN(state, pmdst.writable_addr32(0, y), dstBits, ir.width(), nullptr);
129 } 127 }
130 128
131 delete [] dstBits; 129 delete [] dstBits;
132 130
133 canvas->drawBitmap(bmdst, r.left(), r.top(), nullptr); 131 canvas->drawBitmap(bmdst, r.left(), r.top(), nullptr);
134 } 132 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 188 }
191 canvas->restore(); 189 canvas->restore();
192 canvas->translate(0, H + 20); 190 canvas->translate(0, H + 20);
193 } 191 }
194 canvas->restore(); 192 canvas->restore();
195 canvas->translate(0, (H + 20) * SK_ARRAY_COUNT(mats)); 193 canvas->translate(0, (H + 20) * SK_ARRAY_COUNT(mats));
196 if (useBilerp) break; 194 if (useBilerp) break;
197 useBilerp = true; 195 useBilerp = true;
198 } 196 }
199 } 197 }
OLDNEW
« no previous file with comments | « bench/SkLinearBitmapPipelineBench.cpp ('k') | src/core/SkLinearBitmapPipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698