From 6ba8c83234ca371b3d26a9a812d09e53cad36e17 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Wed, 10 Oct 2018 11:43:01 -0400 Subject: [PATCH] Fix yuv_to_rgb_effect GM This bug was introduced in https://skia-review.googlesource.com/c/skia/+/160162 (Make GrYUVtoRGBEffect more flexible) I don't know why I wasn't seeing this locally! Change-Id: Ic4d9b88b70c6d691d1e30d5ee0dc592a00b9b4e7 Reviewed-on: https://skia-review.googlesource.com/c/161044 Reviewed-by: Jim Van Verth Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- gm/yuvtorgbeffect.cpp | 8 ++++---- include/core/SkYUVAIndex.h | 8 ++++++++ src/gpu/effects/GrYUVtoRGBEffect.cpp | 8 +++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index c234d6c8d6..2b5668cac9 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -113,9 +113,9 @@ protected: for (int i = 0; i < 6; ++i) { SkYUVAIndex yuvaIndices[4] = { - { indices[i][0], SkColorChannel::kA }, - { indices[i][1], SkColorChannel::kA }, - { indices[i][2], SkColorChannel::kA }, + { indices[i][0], SkColorChannel::kR }, + { indices[i][1], SkColorChannel::kR }, + { indices[i][2], SkColorChannel::kR }, { -1, SkColorChannel::kA } }; @@ -223,7 +223,7 @@ protected: } SkYUVAIndex yuvaIndices[4] = { - { 0, SkColorChannel::kA }, + { 0, SkColorChannel::kR }, { 1, SkColorChannel::kR }, { 1, SkColorChannel::kG }, { -1, SkColorChannel::kA } diff --git a/include/core/SkYUVAIndex.h b/include/core/SkYUVAIndex.h index 62d80bdc18..8f2c39deaa 100644 --- a/include/core/SkYUVAIndex.h +++ b/include/core/SkYUVAIndex.h @@ -29,6 +29,14 @@ enum class SkColorChannel { to read from. */ struct SK_API SkYUVAIndex { + bool operator==(const SkYUVAIndex& that) const { + return this->fIndex == that.fIndex && this->fChannel == that.fChannel; + } + + bool operator!=(const SkYUVAIndex& that) const { + return !(*this == that); + } + // Index in the array of SkYUVAIndex enum Index { kY_Index = 0, diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index 6d3bf1db0a..1862cfb3c4 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -182,6 +182,7 @@ void GrYUVtoRGBEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, uint8_t index = this->yuvaIndex(i).fIndex; uint8_t chann = (uint8_t) this->yuvaIndex(i).fChannel; + SkASSERT(index < 4 && chann < 4); packed |= (index | (chann << 2)) << (i * 4); @@ -190,7 +191,12 @@ void GrYUVtoRGBEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, } bool GrYUVtoRGBEffect::onIsEqual(const GrFragmentProcessor& other) const { const GrYUVtoRGBEffect& that = other.cast(); - (void)that; + + for (int i = 0; i < 4; ++i) { + if (fYUVAIndices[i] != that.fYUVAIndices[i]) { + return false; + } + } for (int i = 0; i < this->numTextureSamplers(); ++i) { // 'fSamplers' is checked by the base class