blob: 9d12f1b465a83d81acc3260110ca3d60752986fb [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
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; }
herb3eb48952016-02-19 14:39:47 -080016 void pointSpan(SkPoint start, SkScalar length, int count) override { }
herbfeec8782016-02-17 10:00:07 -080017 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
herbed545042016-02-18 13:55:02 -080044 SkPixmap srcPixmap{info, bitmap, static_cast<size_t>(4 * width)};
45
herbc5eddd72016-02-17 19:50:05 -080046 SkLinearBitmapPipeline pipeline{invert, kNone_SkFilterQuality, SkShader::kClamp_TileMode,
herbed545042016-02-18 13:55:02 -080047 SkShader::kClamp_TileMode, srcPixmap};
herbfeec8782016-02-17 10:00:07 -080048
49 int count = 10;
50
51 pipeline.shadeSpan4f(3, 6, FPbuffer, count);
herbed545042016-02-18 13:55:02 -080052#if 0
herbfeec8782016-02-17 10:00:07 -080053 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 }
herbed545042016-02-18 13:55:02 -080061#endif
herbfeec8782016-02-17 10:00:07 -080062
63 delete [] bitmap;
64 delete [] FPbuffer;
65}
66