herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 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 | */ |
reed | dd9ffea | 2016-02-18 12:39:14 -0800 | [diff] [blame] | 7 | |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 8 | #include "SkLinearBitmapPipeline.h" |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 9 | #include "SkColor.h" |
reed | dd9ffea | 2016-02-18 12:39:14 -0800 | [diff] [blame] | 10 | #include "SkPM4f.h" |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 11 | #include "Test.h" |
| 12 | |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 13 | using Pixel = float[4]; |
| 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 | |
herb | ed54504 | 2016-02-18 13:55:02 -0800 | [diff] [blame] | 36 | SkPixmap srcPixmap{info, bitmap, static_cast<size_t>(4 * width)}; |
| 37 | |
herb | c5eddd7 | 2016-02-17 19:50:05 -0800 | [diff] [blame] | 38 | SkLinearBitmapPipeline pipeline{invert, kNone_SkFilterQuality, SkShader::kClamp_TileMode, |
herb | ed54504 | 2016-02-18 13:55:02 -0800 | [diff] [blame] | 39 | SkShader::kClamp_TileMode, srcPixmap}; |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 40 | |
| 41 | int count = 10; |
| 42 | |
| 43 | pipeline.shadeSpan4f(3, 6, FPbuffer, count); |
herb | ed54504 | 2016-02-18 13:55:02 -0800 | [diff] [blame] | 44 | #if 0 |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 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 | } |
herb | ed54504 | 2016-02-18 13:55:02 -0800 | [diff] [blame] | 53 | #endif |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 54 | |
| 55 | delete [] bitmap; |
| 56 | delete [] FPbuffer; |
| 57 | } |
| 58 | |