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

Side by Side Diff: src/core/SkColorShader.cpp

Issue 2334123003: Add SkColor4f serialization (Closed)
Patch Set: Switched to memcpy, rebased Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « include/core/SkWriteBuffer.h ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkColorShader.h" 8 #include "SkColorShader.h"
9 #include "SkColorSpace.h" 9 #include "SkColorSpace.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 SkColor4Shader::SkColor4Shader(const SkColor4f& color, sk_sp<SkColorSpace> space ) 125 SkColor4Shader::SkColor4Shader(const SkColor4f& color, sk_sp<SkColorSpace> space )
126 : fColorSpace(std::move(space)) 126 : fColorSpace(std::move(space))
127 , fColor4(color) 127 , fColor4(color)
128 , fCachedByteColor(unit_to_skcolor(color.pin(), space.get())) 128 , fCachedByteColor(unit_to_skcolor(color.pin(), space.get()))
129 {} 129 {}
130 130
131 sk_sp<SkFlattenable> SkColor4Shader::CreateProc(SkReadBuffer& buffer) { 131 sk_sp<SkFlattenable> SkColor4Shader::CreateProc(SkReadBuffer& buffer) {
132 SkColor4f color; 132 SkColor4f color;
133 color.fR = buffer.readScalar(); // readFloat() 133 buffer.readColor4f(&color);
134 color.fG = buffer.readScalar();
135 color.fB = buffer.readScalar();
136 color.fA = buffer.readScalar();
137 if (buffer.readBool()) { 134 if (buffer.readBool()) {
138 // TODO how do we unflatten colorspaces 135 // TODO how do we unflatten colorspaces
139 } 136 }
140 return SkShader::MakeColorShader(color, nullptr); 137 return SkShader::MakeColorShader(color, nullptr);
141 } 138 }
142 139
143 void SkColor4Shader::flatten(SkWriteBuffer& buffer) const { 140 void SkColor4Shader::flatten(SkWriteBuffer& buffer) const {
144 buffer.writeScalar(fColor4.fR); // writeFloat() 141 buffer.writeColor4f(fColor4);
145 buffer.writeScalar(fColor4.fG);
146 buffer.writeScalar(fColor4.fB);
147 buffer.writeScalar(fColor4.fA);
148 buffer.writeBool(false); // TODO how do we flatten colorspaces? 142 buffer.writeBool(false); // TODO how do we flatten colorspaces?
149 } 143 }
150 144
151 uint32_t SkColor4Shader::Color4Context::getFlags() const { 145 uint32_t SkColor4Shader::Color4Context::getFlags() const {
152 return fFlags; 146 return fFlags;
153 } 147 }
154 148
155 SkShader::Context* SkColor4Shader::onCreateContext(const ContextRec& rec, void* storage) const { 149 SkShader::Context* SkColor4Shader::onCreateContext(const ContextRec& rec, void* storage) const {
156 return new (storage) Color4Context(*this, rec); 150 return new (storage) Color4Context(*this, rec);
157 } 151 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 294 }
301 295
302 bool SkColorShader::ColorShaderContext::onChooseBlitProcs(const SkImageInfo& inf o, 296 bool SkColorShader::ColorShaderContext::onChooseBlitProcs(const SkImageInfo& inf o,
303 BlitState* state) { 297 BlitState* state) {
304 return choose_blitprocs(&fPM4f, info, state); 298 return choose_blitprocs(&fPM4f, info, state);
305 } 299 }
306 300
307 bool SkColor4Shader::Color4Context::onChooseBlitProcs(const SkImageInfo& info, B litState* state) { 301 bool SkColor4Shader::Color4Context::onChooseBlitProcs(const SkImageInfo& info, B litState* state) {
308 return choose_blitprocs(&fPM4f, info, state); 302 return choose_blitprocs(&fPM4f, info, state);
309 } 303 }
OLDNEW
« no previous file with comments | « include/core/SkWriteBuffer.h ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698