Lines Matching +full:test +full:. +full:rgb
2 * Copyright 2015 Google Inc.
5 * found in the LICENSE file.
8 // This test only works with the GPU backend.
10 #include "gm.h"
14 #include "GrContext.h"
15 #include "GrGpu.h"
16 #include "GrTest.h"
17 #include "SkBitmap.h"
18 #include "SkGradientShader.h"
19 #include "SkImage.h"
38 // We create an RGB bitmap and then extract YUV bmps where the U and V bitmaps are in onOnceBeforeDraw()
39 // subsampled by 2 in both dimensions. in onOnceBeforeDraw()
43 paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(0,0), kBmpSize / 2.f, kColors, in onOnceBeforeDraw()
47 rgbBmp.allocN32Pixels(kBmpSize, kBmpSize, true); in onOnceBeforeDraw()
49 canvas.drawPaint(paint); in onOnceBeforeDraw()
50 SkPMColor* rgbColors = static_cast<SkPMColor*>(rgbBmp.getPixels()); in onOnceBeforeDraw()
53 fYUVBmps[0].allocPixels(yinfo); in onOnceBeforeDraw()
55 fYUVBmps[1].allocPixels(uinfo); in onOnceBeforeDraw()
57 fYUVBmps[2].allocPixels(vinfo); in onOnceBeforeDraw()
60 yPixels = static_cast<unsigned char*>(fYUVBmps[0].getPixels()); in onOnceBeforeDraw()
61 uvPixels[0] = static_cast<signed char*>(fYUVBmps[1].getPixels()); in onOnceBeforeDraw()
62 uvPixels[1] = static_cast<signed char*>(fYUVBmps[2].getPixels()); in onOnceBeforeDraw()
65 // yuv color spaces when converted back to RGB) in onOnceBeforeDraw()
73 // Average together 4 pixels of RGB. in onOnceBeforeDraw()
74 int rgb[] = { 0, 0, 0 }; in onOnceBeforeDraw() local
78 rgb[0] += SkGetPackedR32(rgbColors[rgbIndex]); in onOnceBeforeDraw()
79 rgb[1] += SkGetPackedG32(rgbColors[rgbIndex]); in onOnceBeforeDraw()
80 rgb[2] += SkGetPackedB32(rgbColors[rgbIndex]); in onOnceBeforeDraw()
84 rgb[c] /= 4; in onOnceBeforeDraw()
88 ((-38 * rgb[0] - 74 * rgb[1] + 112 * rgb[2] + 128) >> 8) + 128); in onOnceBeforeDraw()
90 ((112 * rgb[0] - 94 * rgb[1] - 18 * rgb[2] + 128) >> 8) + 128); in onOnceBeforeDraw()
93 fRGBImage = SkImage::MakeRasterCopy(SkPixmap(rgbBmp.info(), rgbColors, rgbBmp.rowBytes())); in onOnceBeforeDraw()
103 SkASSERT(fYUVBmps[i].width() == SkToInt(fYUVBmps[i].rowBytes())); in createYUVTextures()
104 yuvHandles[i] = gpu->createTestingOnlyBackendTexture(fYUVBmps[i].getPixels(), in createYUVTextures()
105 fYUVBmps[i].width(), in createYUVTextures()
106 fYUVBmps[i].height(), in createYUVTextures()
134 constexpr SkScalar kPad = 10.f; in onDraw()
137 { fYUVBmps[0].width(), fYUVBmps[0].height()}, in onDraw()
138 { fYUVBmps[1].width(), fYUVBmps[1].height()}, in onDraw()
139 { fYUVBmps[2].width(), fYUVBmps[2].height()}, in onDraw()
142 images.push_back(fRGBImage); in onDraw()
146 images.push_back(SkImage::MakeFromYUVTexturesCopy(context, in onDraw()
152 for (int i = 0; i < images.count(); ++ i) { in onDraw()
153 SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height(); in onDraw()
156 canvas->drawImage(images[i].get(), x, y); in onDraw()