Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: src/core/SkColorMatrixFilterRowMajor255.cpp

Issue 1513393002: Add ability to extract YUV planes from SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gm cleanup Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkColorMatrixFilterRowMajor255.h ('k') | src/gpu/GrTextureToYUVPlanes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorMatrixFilterRowMajor255.cpp
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index 6fdfa0b446195ee6792900e688ac608a75976126..9106a279c0802fc9830b6bf63038d10c7d58e429 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -32,10 +32,8 @@ static void transpose_to_pmorder(float dst[20], const float src[20]) {
}
}
-// src is [20] but some compilers won't accept __restrict__ on anything
-// but an raw pointer or reference
-void SkColorMatrixFilterRowMajor255::initState(const SkScalar* SK_RESTRICT src) {
- transpose_to_pmorder(fTranspose, src);
+void SkColorMatrixFilterRowMajor255::initState() {
+ transpose_to_pmorder(fTranspose, fMatrix);
const float* array = fMatrix;
@@ -55,7 +53,7 @@ void SkColorMatrixFilterRowMajor255::initState(const SkScalar* SK_RESTRICT src)
SkColorMatrixFilterRowMajor255::SkColorMatrixFilterRowMajor255(const SkScalar array[20]) {
memcpy(fMatrix, array, 20 * sizeof(SkScalar));
- this->initState(array);
+ this->initState();
}
uint32_t SkColorMatrixFilterRowMajor255::getFlags() const {
@@ -420,3 +418,16 @@ void SkColorMatrixFilterRowMajor255::toString(SkString* str) const {
SkColorFilter* SkColorFilter::CreateMatrixFilterRowMajor255(const SkScalar array[20]) {
return new SkColorMatrixFilterRowMajor255(array);
}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkColorFilter* SkColorMatrixFilterRowMajor255::CreateSingleChannelOutput(const SkScalar row[5]) {
+ SkASSERT(row);
+ SkColorMatrixFilterRowMajor255* cf = new SkColorMatrixFilterRowMajor255();
+ static_assert(sizeof(SkScalar) * 5 * 4 == sizeof(cf->fMatrix), "sizes don't match");
+ for (int i = 0; i < 4; ++i) {
+ memcpy(cf->fMatrix + 5 * i, row, sizeof(SkScalar) * 5);
+ }
+ cf->initState();
+ return cf;
+}
« no previous file with comments | « src/core/SkColorMatrixFilterRowMajor255.h ('k') | src/gpu/GrTextureToYUVPlanes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698