blob: 04f2e2783e8e053ac75713a3d68ccc5481511843 [file] [log] [blame]
herbfeec8782016-02-17 10:00:07 -08001/*
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 */
reeddd9ffea2016-02-18 12:39:14 -08007
herbfeec8782016-02-17 10:00:07 -08008#include "SkLinearBitmapPipeline.h"
herbfeec8782016-02-17 10:00:07 -08009#include "SkColor.h"
reeddd9ffea2016-02-18 12:39:14 -080010#include "SkPM4f.h"
herbfeec8782016-02-17 10:00:07 -080011#include "Test.h"
12
herbfeec8782016-02-17 10:00:07 -080013using Pixel = float[4];
14DEF_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
herbed545042016-02-18 13:55:02 -080036 SkPixmap srcPixmap{info, bitmap, static_cast<size_t>(4 * width)};
37
herbc5eddd72016-02-17 19:50:05 -080038 SkLinearBitmapPipeline pipeline{invert, kNone_SkFilterQuality, SkShader::kClamp_TileMode,
herbed545042016-02-18 13:55:02 -080039 SkShader::kClamp_TileMode, srcPixmap};
herbfeec8782016-02-17 10:00:07 -080040
41 int count = 10;
42
43 pipeline.shadeSpan4f(3, 6, FPbuffer, count);
herbed545042016-02-18 13:55:02 -080044#if 0
herbfeec8782016-02-17 10:00:07 -080045 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 }
herbed545042016-02-18 13:55:02 -080053#endif
herbfeec8782016-02-17 10:00:07 -080054
55 delete [] bitmap;
56 delete [] FPbuffer;
57}
58