implement serialization for tosrgb

Bug: skia:
Change-Id: I365f3398f74dbaaeb22c9246255c03b078386877
Reviewed-on: https://skia-review.googlesource.com/26507
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Mike Reed 2017-07-25 11:57:23 -04:00 committed by Skia Commit-Bot
parent a1fc47169a
commit 205c69d489
2 changed files with 11 additions and 4 deletions

View File

@ -8,8 +8,10 @@
#include "SkColorSpace_Base.h"
#include "SkPM4fPriv.h"
#include "SkRasterPipeline.h"
#include "SkReadBuffer.h"
#include "SkString.h"
#include "SkToSRGBColorFilter.h"
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
#include "effects/GrNonlinearColorSpaceXformEffect.h"
@ -58,13 +60,16 @@ sk_sp<SkColorFilter> SkToSRGBColorFilter::Make(sk_sp<SkColorSpace> srcColorSpace
SkToSRGBColorFilter::SkToSRGBColorFilter(sk_sp<SkColorSpace> srcColorSpace)
: fSrcColorSpace(std::move(srcColorSpace)) {}
sk_sp<SkFlattenable> SkToSRGBColorFilter::CreateProc(SkReadBuffer&) {
// TODO
sk_sp<SkFlattenable> SkToSRGBColorFilter::CreateProc(SkReadBuffer& buffer) {
auto data = buffer.readByteArrayAsData();
if (data) {
return Make(SkColorSpace::Deserialize(data->data(), data->size()));
}
return nullptr;
}
void SkToSRGBColorFilter::flatten(SkWriteBuffer&) const {
// TODO
void SkToSRGBColorFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeDataAsByteArray(fSrcColorSpace->serialize().get());
}
#ifndef SK_IGNORE_TO_STRING

View File

@ -42,6 +42,7 @@
#include "SkRRectsGaussianEdgeMaskFilter.h"
#include "SkTableColorFilter.h"
#include "SkTileImageFilter.h"
#include "SkToSRGBColorFilter.h"
#include "SkXfermodeImageFilter.h"
// Security note:
@ -78,6 +79,7 @@ void SkFlattenable::PrivateInitializer::InitEffects() {
// ColorFilter
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilterRowMajor255)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkToSRGBColorFilter)
SkAlphaThresholdFilter::InitializeFlattenables();
SkTableColorFilter::InitializeFlattenables();
SkOverdrawColorFilter::InitializeFlattenables();