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

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

Issue 1852613002: First blitter for linear pipeline. (Closed) Base URL: https://skia.googlesource.com/skia.git@clone-the-pipeline
Patch Set: Moved check and construction of blitter pipeline to SkLinearBitmapPipeline. Created 4 years, 8 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/SkLinearBitmapPipeline.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
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 "SkLinearBitmapPipeline.h" 8 #include "SkLinearBitmapPipeline.h"
9 9
10 #include "SkPM4f.h" 10 #include "SkPM4f.h"
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // As the stages are built, the chooser function may skip a stage. For examp le, with the 769 // As the stages are built, the chooser function may skip a stage. For examp le, with the
770 // identity matrix, the matrix stage is skipped, and the tilerStage is the f irst stage. 770 // identity matrix, the matrix stage is skipped, and the tilerStage is the f irst stage.
771 auto blenderStage = choose_blender(alphaType, postAlpha, &fBlenderStage); 771 auto blenderStage = choose_blender(alphaType, postAlpha, &fBlenderStage);
772 auto samplerStage = choose_pixel_sampler(blenderStage, filterQuality, srcPix map, &fSampleStage); 772 auto samplerStage = choose_pixel_sampler(blenderStage, filterQuality, srcPix map, &fSampleStage);
773 auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile, 773 auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile,
774 filterQuality, dx, &fTileStage); 774 filterQuality, dx, &fTileStage);
775 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage ); 775 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage );
776 fLastStage = blenderStage; 776 fLastStage = blenderStage;
777 } 777 }
778 778
779 bool SkLinearBitmapPipeline::ClonePipelineForBlitting(
780 void* blitterStorage,
781 const SkLinearBitmapPipeline& pipeline,
782 SkMatrix::TypeMask matrixMask,
783 SkShader::TileMode xTileMode,
784 SkShader::TileMode yTileMode,
785 SkFilterQuality filterQuality,
786 const SkPixmap& srcPixmap,
787 float finalAlpha,
788 SkXfermode::Mode xferMode,
789 const SkImageInfo& dstInfo)
790 {
791 if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return false; }
792 if (filterQuality != SkFilterQuality::kNone_SkFilterQuality) { return false; }
793 if (finalAlpha != 1.0f) { return false; }
794 if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType
795 || dstInfo.colorType() != kRGBA_8888_SkColorType) { return false; }
796
797 if (srcPixmap.info().profileType() != dstInfo.profileType()) { return false; }
798
799 if (xTileMode != SkShader::kRepeat_TileMode || yTileMode != SkShader::kRepea t_TileMode) {
800 return false;
801 }
802
803 if (xferMode == SkXfermode::kSrcOver_Mode
804 && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) {
805 xferMode = SkXfermode::kSrc_Mode;
806 }
807
808 if (xferMode != SkXfermode::kSrc_Mode) { return false; }
809
810 new (blitterStorage) SkLinearBitmapPipeline(pipeline, srcPixmap, xferMode, d stInfo);
811
812 return true;
813 }
814
815 SkLinearBitmapPipeline::SkLinearBitmapPipeline(
816 const SkLinearBitmapPipeline& pipeline,
817 const SkPixmap& srcPixmap,
818 SkXfermode::Mode mode,
819 const SkImageInfo& dstInfo)
820 {
821 SkASSERT(mode == SkXfermode::kSrc_Mode);
822 SkASSERT(srcPixmap.info().colorType() == dstInfo.colorType()
823 && srcPixmap.info().colorType() == kRGBA_8888_SkColorType);
824
825 fSampleStage.initSink<RGBA8888UnitRepeat>(srcPixmap.writable_addr32(0, 0), s rcPixmap.width());
826 auto sampleStage = fSampleStage.get();
827 auto tilerStage = pipeline.fTileStage.cloneStageTo(sampleStage, &fTileStage) ;
828 tilerStage = (tilerStage != nullptr) ? tilerStage : sampleStage;
829 auto matrixStage = pipeline.fMatrixStage.cloneStageTo(tilerStage, &fMatrixSt age);
830 matrixStage = (matrixStage != nullptr) ? matrixStage : tilerStage;
831 fFirstStage = matrixStage;
832 fLastStage = fSampleStage.getInterface<DestinationInterface, RGBA8888UnitRep eat>();
833 }
834
779 void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) { 835 void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) {
780 SkASSERT(count > 0); 836 SkASSERT(count > 0);
837 this->blitSpan(x, y, dst, count);
838 }
839
840 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) {
841 SkASSERT(count > 0);
781 fLastStage->setDestination(dst, count); 842 fLastStage->setDestination(dst, count);
782 843
783 // The count and length arguments start out in a precise relation in order t o keep the 844 // The count and length arguments start out in a precise relation in order t o keep the
784 // math correct through the different stages. Count is the number of pixel t o produce. 845 // math correct through the different stages. Count is the number of pixel t o produce.
785 // Since the code samples at pixel centers, length is the distance from the center of the 846 // Since the code samples at pixel centers, length is the distance from the center of the
786 // first pixel to the center of the last pixel. This implies that length is count-1. 847 // first pixel to the center of the last pixel. This implies that length is count-1.
787 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); 848 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count});
788 } 849 }
OLDNEW
« no previous file with comments | « src/core/SkLinearBitmapPipeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698