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

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

Issue 1810383004: allow more options for shader blitprocs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gcc hates my curlies Created 4 years, 9 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 | « src/core/SkColorShader.h ('k') | src/effects/gradients/Sk4fLinearGradient.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 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 "SkAtomics.h" 8 #include "SkAtomics.h"
9 #include "SkBitmapProcShader.h" 9 #include "SkBitmapProcShader.h"
10 #include "SkColorShader.h" 10 #include "SkColorShader.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 str->appendHex(fColor); 354 str->appendHex(fColor);
355 355
356 this->INHERITED::toString(str); 356 this->INHERITED::toString(str);
357 357
358 str->append(")"); 358 str->append(")");
359 } 359 }
360 #endif 360 #endif
361 361
362 /////////////////////////////////////////////////////////////////////////////// 362 ///////////////////////////////////////////////////////////////////////////////
363 363
364 static void D32_BlitProc(SkShader::Context::BlitState* state, int x, int y, cons t SkPixmap& dst, 364 static void D32_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
365 int count, const SkAlpha aa[]) { 365 int count) {
366 SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
367 const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
368 proc(state->fXfer, dst.writable_addr32(x, y), src, count, nullptr);
369 }
370
371 static void D32_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
372 int count, const SkAlpha aa[]) {
366 SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0]; 373 SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
367 const SkPM4f* src = (const SkPM4f*)state->fStorage[1]; 374 const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
368 proc(state->fXfer, dst.writable_addr32(x, y), src, count, aa); 375 proc(state->fXfer, dst.writable_addr32(x, y), src, count, aa);
369 } 376 }
370 377
371 static void D64_BlitProc(SkShader::Context::BlitState* state, int x, int y, cons t SkPixmap& dst, 378 static void D64_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
372 int count, const SkAlpha aa[]) { 379 int count) {
380 SkXfermode::D64Proc proc = (SkXfermode::D64Proc)state->fStorage[0];
381 const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
382 proc(state->fXfer, dst.writable_addr64(x, y), src, count, nullptr);
383 }
384
385 static void D64_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
386 int count, const SkAlpha aa[]) {
373 SkXfermode::D64Proc proc = (SkXfermode::D64Proc)state->fStorage[0]; 387 SkXfermode::D64Proc proc = (SkXfermode::D64Proc)state->fStorage[0];
374 const SkPM4f* src = (const SkPM4f*)state->fStorage[1]; 388 const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
375 proc(state->fXfer, dst.writable_addr64(x, y), src, count, aa); 389 proc(state->fXfer, dst.writable_addr64(x, y), src, count, aa);
376 } 390 }
377 391
378 SkShader::Context::BlitProc 392 bool SkColorShader::ColorShaderContext::onChooseBlitProcs(const SkImageInfo& inf o,
379 SkColorShader::ColorShaderContext::onChooseBlitProc(const SkImageInfo& info, Bli tState* state) { 393 BlitState* state) {
380 uint32_t flags = SkXfermode::kSrcIsSingle_D32Flag; 394 uint32_t flags = SkXfermode::kSrcIsSingle_D32Flag;
381 if (fPM4f.a() == 1) { 395 if (fPM4f.a() == 1) {
382 flags |= SkXfermode::kSrcIsOpaque_D32Flag; 396 flags |= SkXfermode::kSrcIsOpaque_D32Flag;
383 } 397 }
384 switch (info.colorType()) { 398 switch (info.colorType()) {
385 case kN32_SkColorType: 399 case kN32_SkColorType:
386 if (info.isSRGB()) { 400 if (info.isSRGB()) {
387 flags |= SkXfermode::kDstIsSRGB_D32Flag; 401 flags |= SkXfermode::kDstIsSRGB_D32Flag;
388 } 402 }
389 state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fXfer, fla gs); 403 state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fXfer, fla gs);
390 state->fStorage[1] = &fPM4f; 404 state->fStorage[1] = &fPM4f;
391 return D32_BlitProc; 405 state->fBlitBW = D32_BlitBW;
406 state->fBlitAA = D32_BlitAA;
407 return true;
392 case kRGBA_F16_SkColorType: 408 case kRGBA_F16_SkColorType:
393 flags |= SkXfermode::kDstIsFloat16_D64Flag; 409 flags |= SkXfermode::kDstIsFloat16_D64Flag;
394 state->fStorage[0] = (void*)SkXfermode::GetD64Proc(state->fXfer, fla gs); 410 state->fStorage[0] = (void*)SkXfermode::GetD64Proc(state->fXfer, fla gs);
395 state->fStorage[1] = &fPM4f; 411 state->fStorage[1] = &fPM4f;
396 return D64_BlitProc; 412 state->fBlitBW = D64_BlitBW;
413 state->fBlitAA = D64_BlitAA;
414 return true;
397 default: 415 default:
398 return nullptr; 416 return false;
399 } 417 }
400 } 418 }
401 419
402 /////////////////////////////////////////////////////////////////////////////// 420 ///////////////////////////////////////////////////////////////////////////////
403 421
404 SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) { 422 SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) {
405 return SkShader::MakeEmptyShader().release(); 423 return SkShader::MakeEmptyShader().release();
406 } 424 }
407 425
408 #ifndef SK_IGNORE_TO_STRING 426 #ifndef SK_IGNORE_TO_STRING
(...skipping 16 matching lines...) Expand all
425 } 443 }
426 SkShader* SkShader::CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode * xfer) { 444 SkShader* SkShader::CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode * xfer) {
427 return MakeComposeShader(sk_ref_sp(dst), sk_ref_sp(src), xfer).release(); 445 return MakeComposeShader(sk_ref_sp(dst), sk_ref_sp(src), xfer).release();
428 } 446 }
429 SkShader* SkShader::CreatePictureShader(const SkPicture* src, TileMode tmx, Tile Mode tmy, 447 SkShader* SkShader::CreatePictureShader(const SkPicture* src, TileMode tmx, Tile Mode tmy,
430 const SkMatrix* localMatrix, const SkRect* tile) { 448 const SkMatrix* localMatrix, const SkRect* tile) {
431 return MakePictureShader(sk_ref_sp(const_cast<SkPicture*>(src)), tmx, tmy, 449 return MakePictureShader(sk_ref_sp(const_cast<SkPicture*>(src)), tmx, tmy,
432 localMatrix, tile).release(); 450 localMatrix, tile).release();
433 } 451 }
434 #endif 452 #endif
OLDNEW
« no previous file with comments | « src/core/SkColorShader.h ('k') | src/effects/gradients/Sk4fLinearGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698