SkLinearBitmapPipelineTest.cpp revision 3eb4895ea1205a5a2dd1457bf67a1497a29ebc81
1/* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#include "SkLinearBitmapPipeline.h" 9#include "SkColor.h" 10#include "SkPM4f.h" 11#include "Test.h" 12 13struct SinkBilerpProcessor final : public PointProcessorInterface { 14 void pointListFew(int n, Sk4fArg xs, Sk4fArg ys) override { fXs = xs; fYs = ys; } 15 void pointList4(Sk4fArg Xs, Sk4fArg Ys) override { fXs = Xs; fYs = Ys; } 16 void pointSpan(SkPoint start, SkScalar length, int count) override { } 17 Sk4f fXs; 18 Sk4f fYs; 19}; 20 21using Pixel = float[4]; 22DEF_TEST(SkBitmapFP, reporter) { 23 24 int width = 10; 25 int height = 10; 26 uint32_t* bitmap = new uint32_t[width * height]; 27 for (int y = 0; y < height; y++) { 28 for (int x = 0; x < width; x++) { 29 bitmap[y * width + x] = (y << 8) + x + (128<<24); 30 } 31 } 32 33 SkPM4f* FPbuffer = new SkPM4f[width * height]; 34 35 SkMatrix m = SkMatrix::I(); 36 //m.setRotate(30.0f, 1.0f, 1.0f); 37 SkMatrix invert; 38 bool trash = m.invert(&invert); 39 sk_ignore_unused_variable(trash); 40 41 const SkImageInfo info = 42 SkImageInfo::MakeN32Premul(width, height, kLinear_SkColorProfileType); 43 44 SkPixmap srcPixmap{info, bitmap, static_cast<size_t>(4 * width)}; 45 46 SkLinearBitmapPipeline pipeline{invert, kNone_SkFilterQuality, SkShader::kClamp_TileMode, 47 SkShader::kClamp_TileMode, srcPixmap}; 48 49 int count = 10; 50 51 pipeline.shadeSpan4f(3, 6, FPbuffer, count); 52#if 0 53 Pixel* pixelBuffer = (Pixel*)FPbuffer; 54 for (int i = 0; i < count; i++) { 55 printf("i: %d - (%g, %g, %g, %g)\n", i, 56 pixelBuffer[i][0] * 255.0f, 57 pixelBuffer[i][1] * 255.0f, 58 pixelBuffer[i][2] * 255.0f, 59 pixelBuffer[i][3] * 255.0f); 60 } 61#endif 62 63 delete [] bitmap; 64 delete [] FPbuffer; 65} 66 67