SkLinearBitmapPipeline::SkLinearBitmapPipeline( const SkMatrix& inverse, SkFilterQuality filterQuality, SkShader::TileMode xTile, SkShader::TileMode yTile, const SkPixmap& srcPixmap) { SkSize size = SkSize::Make(srcPixmap.width(), srcPixmap.height()); const SkImageInfo& srcImageInfo = srcPixmap.info(); // As the stages are built, the chooser function may skip a stage. For example, with the // identity matrix, the matrix stage is skipped, and the tilerStage is the first stage. auto placementStage = choose_pixel_placer(srcImageInfo.alphaType(), &fPixelStage); auto samplerStage = choose_pixel_sampler(placementStage, srcPixmap, &fSampleStage); auto tilerStage = choose_tiler(samplerStage, size, xTile, yTile, &fTileXOrBothStage, &fTileYStage); auto filterStage = choose_filter(tilerStage, filterQuality, &fFilterStage); fFirstStage = choose_matrix(filterStage, inverse, &fMatrixStage); }
SkLinearBitmapPipeline::SkLinearBitmapPipeline( const SkMatrix& inverse, SkFilterQuality filterQuality, SkShader::TileMode xTile, SkShader::TileMode yTile, SkColor paintColor, const SkPixmap& srcPixmap) { SkISize dimensions = srcPixmap.info().dimensions(); const SkImageInfo& srcImageInfo = srcPixmap.info(); SkMatrix adjustedInverse = inverse; if (filterQuality == kNone_SkFilterQuality) { if (inverse.getScaleX() >= 0.0f) { adjustedInverse.setTranslateX( nextafterf(inverse.getTranslateX(), std::floor(inverse.getTranslateX()))); } if (inverse.getScaleY() >= 0.0f) { adjustedInverse.setTranslateY( nextafterf(inverse.getTranslateY(), std::floor(inverse.getTranslateY()))); } } SkScalar dx = adjustedInverse.getScaleX(); // If it is an index 8 color type, the sampler converts to unpremul for better fidelity. SkAlphaType alphaType = srcImageInfo.alphaType(); if (srcPixmap.colorType() == kIndex_8_SkColorType) { alphaType = kUnpremul_SkAlphaType; } float postAlpha = SkColorGetA(paintColor) * (1.0f / 255.0f); // As the stages are built, the chooser function may skip a stage. For example, with the // identity matrix, the matrix stage is skipped, and the tilerStage is the first stage. auto blenderStage = choose_blender_for_shading(alphaType, postAlpha, &fBlenderStage); auto samplerStage = choose_pixel_sampler( blenderStage, filterQuality, xTile, yTile, srcPixmap, paintColor, &fSampleStage, &fAccessor); auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile, filterQuality, dx, &fTileStage); fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage); fLastStage = blenderStage; }
int SW (char *seq1, char *seq2, int alignment, int size,char* buff) { MatrixADT Matrix = (MatrixCDT *) malloc(sizeof(MatrixCDT)); PathADT max_cell; Score_Matrix *score_Matrix; int* codeSeq1; int* codeSeq2; int max_score; int temp_seq[size]; char seq[size+1]; int i,j; int smatrix_name = PAM47; /* score matrix */ score_Matrix = choose_matrix(smatrix_name); if (score_Matrix == NULL) { free_score_Matrix(score_Matrix); score_Matrix= NULL; return; } Matrix->row = size +1; Matrix->column = size+1; Matrix->grid = (Matrix_Cell ***) malloc(sizeof(Matrix_Cell **)*Matrix->row); for (i=0; i< Matrix->row; i++) { Matrix->grid[i] = (Matrix_Cell **) malloc(sizeof(Matrix_Cell *)*Matrix->column); } for (i=0; i< Matrix->row; i++) { for (j=0; j< Matrix->column; j++) { Matrix->grid[i][j] = (Matrix_Cell *) malloc (sizeof(Matrix_Cell)); } } //encode seq1 and seq2 codeSeq1 = Encode_Seq(seq1); codeSeq2 = Encode_Seq(seq2); for (i =0; i<strlen(seq1)-size+1; i++) { //reverse seq2 segment for (j =0; j<size; j++) { temp_seq[j] = (codeSeq2+i) [size-j-1]; } max_cell = (PathCDT *)malloc(sizeof(PathCDT)); max_cell->start = NULL; max_score = Smith_Waterman_Fill (codeSeq1+i, temp_seq, Matrix, max_cell,score_Matrix); if ((alignment) && (strlen(seq2) == size)) { for (i=0; i<size; i++) seq[i] = seq2[size-i-1]; seq[size] = '\0'; Output_Best_SW_Alignment(seq1, seq, Matrix, max_cell,buff); } free_PathADT(max_cell); sprintf (buff+strlen(buff),"%d\n", max_score); } free(codeSeq1); free(codeSeq2); free_MatrixADT(Matrix); //free score_Matrix memory free_score_Matrix(score_Matrix); score_Matrix = NULL; return max_score; }
int main(void) { int retval = 0; int choice = 0; short *prandom_data; #ifdef PATCHED_1 char m_result_data[MAX_ROWS * MAX_COLS * sizeof(int)]; #else char m_result_data[((MAX_ROWS * MAX_COLS) - 1) * sizeof(int)]; #endif prandom_data = create_random_shorts(); matrix_t *m; matrix_t *m1, *m2; matrix_t *m_result; m1 = create_matrix(SHORT, NULL); m2 = create_matrix(SHORT, NULL); m_result = create_matrix(INT, m_result_data); char *input = malloc(2048); printf("Matrix math is fun!\n"); printf("-------------------\n"); while (1) { choice = select_menu_choice(input, LINE_SIZE); switch(choice) { case 1: printf("Inputting Matrix Values:\n"); m = choose_matrix(m1, m2, input, LINE_SIZE); if (!m) goto cgc_exit; if (input_matrix(m, input, LINE_SIZE) == ERROR) goto cgc_exit; break; case 2: printf("Print Matrices:\n"); print_matrices(m1, m2, m_result); break; case 3: printf("Adding Matrices:\n"); add_matrices(m1, m2, m_result); break; case 4: printf("Subtracting Matrices:\n"); subtract_matrices(m1, m2, m_result); break; case 5: printf("Multiplying Matrices:\n"); multiply_matrices(m1, m2, m_result); break; case 6: printf("Swap Rows in a Matrix:\n"); m = choose_matrix(m1, m2, input, LINE_SIZE); if (!m) goto cgc_exit; retval = swap_matrix_row_col(m, SWAP_ROW, input, LINE_SIZE); if (retval == ERROR) goto cgc_exit; if (retval == SUCCESS) print_matrix("Swapped Rows", m); break; case 7: printf("Swap Columns in a Matrix:\n"); m = choose_matrix(m1, m2, input, LINE_SIZE); if (!m) goto cgc_exit; retval = swap_matrix_row_col(m, SWAP_COL, input, LINE_SIZE); if (retval == ERROR) goto cgc_exit; if (retval == SUCCESS) print_matrix("Swapped Columns", m); break; case 8: printf("Transpose a Matrix:\n"); m = choose_matrix(m1, m2, input, LINE_SIZE); if (!m) goto cgc_exit; transpose_matrix(m); break; case 9: printf("Perform Reduced Row Echelon Form on Matrix\n"); m = choose_matrix(m1, m2, input, LINE_SIZE); if (!m) goto cgc_exit; rref_matrix(m, m_result); break; case 10: printf("Create a Random Matrix:\n"); m = choose_matrix(m1, m2, input, LINE_SIZE); if (!m) goto cgc_exit; if (random_matrix(m, input, LINE_SIZE, prandom_data) == ERROR) goto cgc_exit; break; case 11: goto cgc_exit; default: printf("Bad Selection\n"); } } cgc_exit: printf("Exiting...\n"); return 0; }