skia2/include/core/SkICC.h
Mike Klein 5b58b7c14c Reland "strip down SkICC.cpp"
This reverts commit 27fe397bc0.

Reason for revert: time to fly.

Original change's description:
> Revert "strip down SkICC.cpp"
> 
> This reverts commit eab50eb9c6
> and this tiny bit of e61b969a07:
> 
>     https://skia-review.googlesource.com/c/skia/+/127122/3/tests/ICCTest.cpp
> 
> Change-Id: I4306e5118a4e5eb88c05078186a28bd443fd76f7
> Reviewed-on: https://skia-review.googlesource.com/127305
> Reviewed-by: Mike Klein <mtklein@chromium.org>
> Commit-Queue: Mike Klein <mtklein@chromium.org>

TBR=mtklein@chromium.org,brianosman@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I93a6cfb66f0da0e098fdcb77ac1cd619e41614b1
Reviewed-on: https://skia-review.googlesource.com/129446
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2018-05-22 14:17:15 +00:00

38 lines
1.0 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkICC_DEFINED
#define SkICC_DEFINED
#include "SkData.h"
#include "SkRefCnt.h"
struct SkColorSpaceTransferFn;
SK_API sk_sp<SkData> SkWriteICCProfile(const SkColorSpaceTransferFn&, const float toXYZD50[9]);
namespace SkICC {
static inline sk_sp<SkData> WriteToICC(const SkColorSpaceTransferFn& fn,
const SkMatrix44& toXYZD50) {
if (toXYZD50.get(3,0) == 0 && toXYZD50.get(3,1) == 0 && toXYZD50.get(3,2) == 0 &&
toXYZD50.get(3,3) == 1 &&
toXYZD50.get(0,3) == 0 && toXYZD50.get(1,3) == 0 && toXYZD50.get(2,3) == 0) {
float m33[9];
for (int r = 0; r < 3; r++)
for (int c = 0; c < 3; c++) {
m33[3*r+c] = toXYZD50.get(r,c);
}
return SkWriteICCProfile(fn, m33);
}
return nullptr;
}
}
#endif//SkICC_DEFINED