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

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

Issue 1707883002: lcd blits for sRGB (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more clarity on names/docs for new flags 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
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 "SkCoreBlitters.h" 8 #include "SkCoreBlitters.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 } 74 }
75 } 75 }
76 device += count; 76 device += count;
77 runs += count; 77 runs += count;
78 antialias += count; 78 antialias += count;
79 x += count; 79 x += count;
80 } 80 }
81 } 81 }
82 82
83 void blitLCDMask(const SkMask& mask, const SkIRect& clip) {
84 auto proc = fState.getLCDProc(SkXfermode::kSrcIsSingle_LCDFlag);
85
86 const int x = clip.fLeft;
87 const int width = clip.width();
88 const int y = clip.fTop;
89 const int height = clip.height();
90
91 typename State::DstType* device = State::WritableAddr(fDevice, x, y);
92 const size_t dstRB = fDevice.rowBytes();
93 const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y);
94 const size_t maskRB = mask.fRowBytes;
95
96 for (int i = 0; i < height; ++i) {
97 proc(device, &fState.fPM4f, width, maskRow);
98 device = (typename State::DstType*)((char*)device + dstRB);
99 maskRow = (const uint16_t*)((const char*)maskRow + maskRB);
100 }
101 }
102
83 void blitMask(const SkMask& mask, const SkIRect& clip) override { 103 void blitMask(const SkMask& mask, const SkIRect& clip) override {
84 // we only handle kA8 104 if (SkMask::kLCD16_Format == mask.fFormat) {
105 this->blitLCDMask(mask, clip);
106 return;
107 }
85 if (SkMask::kA8_Format != mask.fFormat) { 108 if (SkMask::kA8_Format != mask.fFormat) {
86 this->INHERITED::blitMask(mask, clip); 109 this->INHERITED::blitMask(mask, clip);
87 return; 110 return;
88 } 111 }
89 112
90 SkASSERT(mask.fBounds.contains(clip)); 113 SkASSERT(mask.fBounds.contains(clip));
91 114
92 const int x = clip.fLeft; 115 const int x = clip.fLeft;
93 const int width = clip.width(); 116 const int width = clip.width();
94 const int y = clip.fTop; 117 const int y = clip.fTop;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 206 }
184 } 207 }
185 } 208 }
186 device += count; 209 device += count;
187 runs += count; 210 runs += count;
188 antialias += count; 211 antialias += count;
189 x += count; 212 x += count;
190 } 213 }
191 } 214 }
192 215
216 void blitLCDMask(const SkMask& mask, const SkIRect& clip) {
217 auto proc = fState.getLCDProc(0);
218
219 const int x = clip.fLeft;
220 const int width = clip.width();
221 int y = clip.fTop;
222
223 typename State::DstType* device = State::WritableAddr(fDevice, x, y);
224 const size_t deviceRB = fDevice.rowBytes();
225 const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y);
226 const size_t maskRB = mask.fRowBytes;
227
228 if (fConstInY) {
229 fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
230 }
231 for (; y < clip.fBottom; ++y) {
232 if (!fConstInY) {
233 fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
234 }
235 proc(device, fState.fBuffer, width, maskRow);
236 device = (typename State::DstType*)((char*)device + deviceRB);
237 maskRow = (const uint16_t*)((const char*)maskRow + maskRB);
238 }
239 }
240
193 void blitMask(const SkMask& mask, const SkIRect& clip) override { 241 void blitMask(const SkMask& mask, const SkIRect& clip) override {
194 // we only handle kA8 242 if (SkMask::kLCD16_Format == mask.fFormat) {
243 this->blitLCDMask(mask, clip);
244 return;
245 }
195 if (SkMask::kA8_Format != mask.fFormat) { 246 if (SkMask::kA8_Format != mask.fFormat) {
196 this->INHERITED::blitMask(mask, clip); 247 this->INHERITED::blitMask(mask, clip);
197 return; 248 return;
198 } 249 }
199 250
200 SkASSERT(mask.fBounds.contains(clip)); 251 SkASSERT(mask.fBounds.contains(clip));
201 252
202 const int x = clip.fLeft; 253 const int x = clip.fLeft;
203 const int width = clip.width(); 254 const int width = clip.width();
204 int y = clip.fTop; 255 int y = clip.fTop;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 fBuffer = new SkPM4f[info.width()]; 315 fBuffer = new SkPM4f[info.width()];
265 } else { 316 } else {
266 fPM4f = SkColor4f::FromColor(paint.getColor()).premul(); 317 fPM4f = SkColor4f::FromColor(paint.getColor()).premul();
267 } 318 }
268 } 319 }
269 320
270 ~State32() { 321 ~State32() {
271 SkSafeUnref(fXfer); 322 SkSafeUnref(fXfer);
272 delete[] fBuffer; 323 delete[] fBuffer;
273 } 324 }
274 325
326 SkXfermode::LCD32Proc getLCDProc(uint32_t oneOrManyFlag) const {
327 uint32_t flags = fFlags & 1;
328 if (!(fFlags & SkXfermode::kDstIsSRGB_PM4fFlag)) {
329 flags |= SkXfermode::kDstIsLinearInt_LCDFlag;
330 }
331 return SkXfermode::GetLCD32Proc(flags | oneOrManyFlag);
332 }
333
275 static DstType* WritableAddr(const SkPixmap& device, int x, int y) { 334 static DstType* WritableAddr(const SkPixmap& device, int x, int y) {
276 return device.writable_addr32(x, y); 335 return device.writable_addr32(x, y);
277 } 336 }
278 }; 337 };
279 338
280 struct State64 : SkXfermode::U64State { 339 struct State64 : SkXfermode::U64State {
281 typedef uint64_t DstType; 340 typedef uint64_t DstType;
282 341
283 SkXfermode::U64Proc1 fProc1; 342 SkXfermode::U64Proc1 fProc1;
284 SkXfermode::U64ProcN fProcN; 343 SkXfermode::U64ProcN fProcN;
(...skipping 23 matching lines...) Expand all
308 } else { 367 } else {
309 fPM4f = SkColor4f::FromColor(paint.getColor()).premul(); 368 fPM4f = SkColor4f::FromColor(paint.getColor()).premul();
310 } 369 }
311 } 370 }
312 371
313 ~State64() { 372 ~State64() {
314 SkSafeUnref(fXfer); 373 SkSafeUnref(fXfer);
315 delete[] fBuffer; 374 delete[] fBuffer;
316 } 375 }
317 376
377 SkXfermode::LCD64Proc getLCDProc(uint32_t oneOrManyFlag) const {
378 uint32_t flags = fFlags & 1;
379 if (!(fFlags & SkXfermode::kDstIsFloat16_U64Flag)) {
380 flags |= SkXfermode::kDstIsLinearInt_LCDFlag;
381 }
382 return SkXfermode::GetLCD64Proc(flags | oneOrManyFlag);
383 }
384
318 static DstType* WritableAddr(const SkPixmap& device, int x, int y) { 385 static DstType* WritableAddr(const SkPixmap& device, int x, int y) {
319 return device.writable_addr64(x, y); 386 return device.writable_addr64(x, y);
320 } 387 }
321 }; 388 };
322 389
323 template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain t& paint, 390 template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain t& paint,
324 SkShader::Context* shaderContext, 391 SkShader::Context* shaderContext,
325 SkTBlitterAllocator* allocator) { 392 SkTBlitterAllocator* allocator) {
326 SkASSERT(allocator != nullptr); 393 SkASSERT(allocator != nullptr);
327 394
(...skipping 12 matching lines...) Expand all
340 SkShader::Context* shaderContext, 407 SkShader::Context* shaderContext,
341 SkTBlitterAllocator* allocator) { 408 SkTBlitterAllocator* allocator) {
342 return create<State32>(device, paint, shaderContext, allocator); 409 return create<State32>(device, paint, shaderContext, allocator);
343 } 410 }
344 411
345 SkBlitter* SkBlitter_ARGB64_Create(const SkPixmap& device, const SkPaint& paint, 412 SkBlitter* SkBlitter_ARGB64_Create(const SkPixmap& device, const SkPaint& paint,
346 SkShader::Context* shaderContext, 413 SkShader::Context* shaderContext,
347 SkTBlitterAllocator* allocator) { 414 SkTBlitterAllocator* allocator) {
348 return create<State64>(device, paint, shaderContext, allocator); 415 return create<State64>(device, paint, shaderContext, allocator);
349 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698