| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkRGBAToYUV.h" | 8 #include "SkRGBAToYUV.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColorMatrixFilterRowMajor255.h" | 10 #include "SkColorMatrixFilterRowMajor255.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 -0.100672f, -0.338658f, 0.43933f, 0.f, 0.5f * 255.f, | 31 -0.100672f, -0.338658f, 0.43933f, 0.f, 0.5f * 255.f, |
| 32 0.439142f, -0.39891f, -0.040231f, 0.f, 0.5f * 255.f}, | 32 0.439142f, -0.39891f, -0.040231f, 0.f, 0.5f * 255.f}, |
| 33 }; | 33 }; |
| 34 static_assert(kLastEnum_SkYUVColorSpace == 2, "yuv color matrix array proble
m"); | 34 static_assert(kLastEnum_SkYUVColorSpace == 2, "yuv color matrix array proble
m"); |
| 35 static_assert(kJPEG_SkYUVColorSpace == 0, "yuv color matrix array proble
m"); | 35 static_assert(kJPEG_SkYUVColorSpace == 0, "yuv color matrix array proble
m"); |
| 36 static_assert(kRec601_SkYUVColorSpace == 1, "yuv color matrix array proble
m"); | 36 static_assert(kRec601_SkYUVColorSpace == 1, "yuv color matrix array proble
m"); |
| 37 static_assert(kRec709_SkYUVColorSpace == 2, "yuv color matrix array proble
m"); | 37 static_assert(kRec709_SkYUVColorSpace == 2, "yuv color matrix array proble
m"); |
| 38 | 38 |
| 39 for (int i = 0; i < 3; ++i) { | 39 for (int i = 0; i < 3; ++i) { |
| 40 size_t rb = rowBytes[i] ? rowBytes[i] : sizes[i].fWidth; | 40 size_t rb = rowBytes[i] ? rowBytes[i] : sizes[i].fWidth; |
| 41 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect( | 41 auto surface(SkSurface::MakeRasterDirect( |
| 42 SkImageInfo::MakeA8(sizes[i].fWidth, sizes[i].fHeight), planes[i
], rb)); | 42 SkImageInfo::MakeA8(sizes[i].fWidth, sizes[i].fHeight), planes[i
], rb)); |
| 43 if (!surface) { | 43 if (!surface) { |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 SkPaint paint; | 46 SkPaint paint; |
| 47 paint.setFilterQuality(kLow_SkFilterQuality); | 47 paint.setFilterQuality(kLow_SkFilterQuality); |
| 48 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 48 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 49 int rowStartIdx = 5 * i; | 49 int rowStartIdx = 5 * i; |
| 50 const SkScalar* row = kYUVColorSpaceInvMatrices[colorSpace] + rowStartId
x; | 50 const SkScalar* row = kYUVColorSpaceInvMatrices[colorSpace] + rowStartId
x; |
| 51 paint.setColorFilter( | 51 paint.setColorFilter( |
| 52 SkColorMatrixFilterRowMajor255::MakeSingleChannelOutput(row)); | 52 SkColorMatrixFilterRowMajor255::MakeSingleChannelOutput(row)); |
| 53 surface->getCanvas()->drawImageRect(image, SkIRect::MakeWH(image->width(
), image->height()), | 53 surface->getCanvas()->drawImageRect(image, SkIRect::MakeWH(image->width(
), image->height()), |
| 54 SkRect::MakeIWH(surface->width(), su
rface->height()), | 54 SkRect::MakeIWH(surface->width(), su
rface->height()), |
| 55 &paint); | 55 &paint); |
| 56 } | 56 } |
| 57 return true; | 57 return true; |
| 58 } | 58 } |
| OLD | NEW |