Revert "Reland "remove legacy 255-biased colormatrix""

This reverts commit b75be23bc4.

Reason for revert: Flutter also appears to be using this

third_party/flutter_engine/lib/ui/painting/paint.cc:95:32: error: no member named 'MatrixRowMajor255' in 'SkColorFilters'
        return SkColorFilters::MatrixRowMajor255(decoded.data());

Original change's description:
> Reland "remove legacy 255-biased colormatrix"
> 
> This reverts commit 34d286a6d7.
> 
> Reason for revert: google3 sites updated (hopefully)
> 
> Original change's description:
> > Revert "remove legacy 255-biased colormatrix"
> > 
> > This reverts commit ec654f7397.
> > 
> > Reason for revert: Seems to be breaking the Google3 roll
> > 
> > Original change's description:
> > > remove legacy 255-biased colormatrix
> > > 
> > > Bug: skia:4872
> > > Bug: skia:9012
> > > 
> > > Change-Id: I7c1ac4e94405404fcb13079b5b578a5a26aad02e
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210628
> > > Reviewed-by: Mike Reed <reed@google.com>
> > > Commit-Queue: Mike Reed <reed@google.com>
> > > Auto-Submit: Mike Reed <reed@google.com>
> > 
> > TBR=reed@google.com
> > 
> > Change-Id: Ib51de4f5a3f5d28b4870ca61fff43cce96e7426f
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:4872, skia:9012
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211587
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > Commit-Queue: Robert Phillips <robertphillips@google.com>
> 
> TBR=robertphillips@google.com,reed@google.com
> 
> Change-Id: I60e966eb05a092c2b590f819db5bacc1fe6db5db
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:4872, skia:9012
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211643
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=robertphillips@google.com,reed@google.com

Change-Id: I6f0852e6c6c7d7dc38e51112d9e01cd302447772
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:4872, skia:9012
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211655
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-05-01 22:28:52 +00:00 committed by Skia Commit-Bot
parent 62b501499a
commit 7cf4242f8a
3 changed files with 34 additions and 4 deletions

View File

@ -37,6 +37,7 @@ public:
bool asColorMode(SkColor* color, SkBlendMode* mode) const {
return this->onAsAColorMode(color, mode);
}
bool asColorMatrix(float rowMajor255[20]) const;
/** If the filter can be represented by a source color plus Mode, this
* returns true, and sets (if not NULL) the color and mode appropriately.
@ -139,6 +140,9 @@ private:
class SK_API SkColorFilters {
public:
// Deprecated: use Matrix(...) with 0...1 values for translate
static sk_sp<SkColorFilter> MatrixRowMajor255(const float array[20]);
static sk_sp<SkColorFilter> Compose(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner) {
return outer ? outer->makeComposed(inner) : inner;
}

View File

@ -32,6 +32,21 @@ bool SkColorFilter::onAsAColorMatrix(float matrix[20]) const {
return false;
}
// DEPRECATED
bool SkColorFilter::asColorMatrix(float rowMajor255[20]) const {
if (this->asAColorMatrix(rowMajor255)) {
if (rowMajor255) {
rowMajor255[ 4] *= 255;
rowMajor255[ 9] *= 255;
rowMajor255[14] *= 255;
rowMajor255[19] *= 255;
}
return true;
}
return false;
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const {

View File

@ -16,6 +16,12 @@
#include "src/core/SkReadBuffer.h"
#include "src/core/SkWriteBuffer.h"
static void scale_last_column(float rowMajor[20], float scale) {
for (int i = 0; i < 4; ++i) {
rowMajor[5*i + 4] *= scale;
}
}
void SkColorFilter_Matrix::initState() {
const float* srcA = fMatrix + 15;
fFlags = (srcA[0] == 0 && srcA[1] == 0 && srcA[2] == 0 && srcA[3] == 1 && srcA[4] == 0)
@ -197,6 +203,14 @@ sk_sp<SkColorFilter> SkColorFilters::Matrix(const SkColorMatrix& cm) {
return Matrix(cm.fMat);
}
// DEPRECATED
sk_sp<SkColorFilter> SkColorFilters::MatrixRowMajor255(const float array[20]) {
float tmp[20];
memcpy(tmp, array, sizeof(tmp));
scale_last_column(tmp, 1.0f/255);
return Matrix(tmp);
}
void SkColorFilter_Matrix::RegisterFlattenables() {
SK_REGISTER_FLATTENABLE(SkColorFilter_Matrix);
@ -205,10 +219,7 @@ void SkColorFilter_Matrix::RegisterFlattenables() {
[](SkReadBuffer& buffer) -> sk_sp<SkFlattenable> {
float matrix[20];
if (buffer.readScalarArray(matrix, 20)) {
matrix[ 4] *= (1.0f/255);
matrix[ 9] *= (1.0f/255);
matrix[14] *= (1.0f/255);
matrix[19] *= (1.0f/255);
scale_last_column(matrix, 1.0f/255);
return SkColorFilters::Matrix(matrix);
}
return nullptr;