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 
13 using Pixel = float[4];
DEF_TEST(SkBitmapFP,reporter)14 DEF_TEST(SkBitmapFP, reporter) {
15 
16     int width = 10;
17     int height = 10;
18     uint32_t* bitmap = new uint32_t[width * height];
19     for (int y = 0; y < height; y++) {
20         for (int x = 0; x < width; x++) {
21             bitmap[y * width + x] = (y << 8) + x + (128<<24);
22         }
23     }
24 
25     SkPM4f* FPbuffer = new SkPM4f[width * height];
26 
27     SkMatrix m = SkMatrix::I();
28     //m.setRotate(30.0f, 1.0f, 1.0f);
29     SkMatrix invert;
30     bool trash = m.invert(&invert);
31     sk_ignore_unused_variable(trash);
32 
33     const SkImageInfo info =
34         SkImageInfo::MakeN32Premul(width, height, kLinear_SkColorProfileType);
35 
36     SkPixmap srcPixmap{info, bitmap, static_cast<size_t>(4 * width)};
37 
38     SkLinearBitmapPipeline pipeline{invert, kNone_SkFilterQuality, SkShader::kClamp_TileMode,
39                                     SkShader::kClamp_TileMode, srcPixmap};
40 
41     int count = 10;
42 
43     pipeline.shadeSpan4f(3, 6, FPbuffer, count);
44 #if 0
45     Pixel* pixelBuffer = (Pixel*)FPbuffer;
46     for (int i = 0; i < count; i++) {
47         printf("i: %d - (%g, %g, %g, %g)\n", i,
48                pixelBuffer[i][0] * 255.0f,
49                pixelBuffer[i][1] * 255.0f,
50                pixelBuffer[i][2] * 255.0f,
51                pixelBuffer[i][3] * 255.0f);
52     }
53 #endif
54 
55     delete [] bitmap;
56     delete [] FPbuffer;
57 }
58 
59