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

Side by Side Diff: src/effects/SkTableColorFilter.cpp

Issue 768183002: Revert of Remove SK_SUPPORT_LEGACY_DEEPFLATTENING. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « src/effects/SkRectShaderImageFilter.cpp ('k') | src/effects/SkTableMaskFilter.cpp » ('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 #include "SkBitmap.h" 2 #include "SkBitmap.h"
3 #include "SkTableColorFilter.h" 3 #include "SkTableColorFilter.h"
4 #include "SkColorPriv.h" 4 #include "SkColorPriv.h"
5 #include "SkReadBuffer.h" 5 #include "SkReadBuffer.h"
6 #include "SkWriteBuffer.h" 6 #include "SkWriteBuffer.h"
7 #include "SkUnPreMultiply.h" 7 #include "SkUnPreMultiply.h"
8 #include "SkString.h" 8 #include "SkString.h"
9 9
10 class SkTable_ColorFilter : public SkColorFilter { 10 class SkTable_ColorFilter : public SkColorFilter {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter) 54 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter)
55 55
56 enum { 56 enum {
57 kA_Flag = 1 << 0, 57 kA_Flag = 1 << 0,
58 kR_Flag = 1 << 1, 58 kR_Flag = 1 << 1,
59 kG_Flag = 1 << 2, 59 kG_Flag = 1 << 2,
60 kB_Flag = 1 << 3, 60 kB_Flag = 1 << 3,
61 }; 61 };
62 62
63 protected: 63 protected:
64 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
65 SkTable_ColorFilter(SkReadBuffer& buffer);
66 #endif
64 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 67 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
65 68
66 private: 69 private:
67 mutable const SkBitmap* fBitmap; // lazily allocated 70 mutable const SkBitmap* fBitmap; // lazily allocated
68 71
69 uint8_t fStorage[256 * 4]; 72 uint8_t fStorage[256 * 4];
70 unsigned fFlags; 73 unsigned fFlags;
71 74
72 friend class SkTableColorFilter; 75 friend class SkTableColorFilter;
73 76
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 g = ptr; 220 g = ptr;
218 ptr += 256; 221 ptr += 256;
219 } 222 }
220 if (flags & kB_Flag) { 223 if (flags & kB_Flag) {
221 b = ptr; 224 b = ptr;
222 ptr += 256; 225 ptr += 256;
223 } 226 }
224 return SkTableColorFilter::CreateARGB(a, r, g, b); 227 return SkTableColorFilter::CreateARGB(a, r, g, b);
225 } 228 }
226 229
230 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
231 SkTable_ColorFilter::SkTable_ColorFilter(SkReadBuffer& buffer) : INHERITED(buffe r) {
232 fBitmap = NULL;
233
234 uint8_t storage[5*256];
235
236 fFlags = buffer.readInt();
237
238 size_t size = buffer.getArrayCount();
239 SkASSERT(size <= sizeof(storage));
240 buffer.validate(size <= sizeof(storage));
241 buffer.readByteArray(storage, size);
242
243 SkDEBUGCODE(size_t raw = ) SkPackBits::Unpack8(storage, size, fStorage);
244
245 SkASSERT(raw <= sizeof(fStorage));
246 SkDEBUGCODE(size_t count = gCountNibBits[fFlags & 0xF]);
247 SkASSERT(raw == count * 256);
248 }
249 #endif
250
227 bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const { 251 bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
228 if (table) { 252 if (table) {
229 if (NULL == fBitmap) { 253 if (NULL == fBitmap) {
230 SkBitmap* bmp = SkNEW(SkBitmap); 254 SkBitmap* bmp = SkNEW(SkBitmap);
231 bmp->allocPixels(SkImageInfo::MakeA8(256, 4)); 255 bmp->allocPixels(SkImageInfo::MakeA8(256, 4));
232 uint8_t* bitmapPixels = bmp->getAddr8(0, 0); 256 uint8_t* bitmapPixels = bmp->getAddr8(0, 0);
233 int offset = 0; 257 int offset = 0;
234 static const unsigned kFlags[] = { kA_Flag, kR_Flag, kG_Flag, kB_Fla g }; 258 static const unsigned kFlags[] = { kA_Flag, kR_Flag, kG_Flag, kB_Fla g };
235 259
236 for (int x = 0; x < 4; ++x) { 260 for (int x = 0; x < 4; ++x) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 305
282 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE; 306 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE;
283 307
284 ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, un signed flags); 308 ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, un signed flags);
285 309
286 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 310 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
287 311
288 GrTextureAccess fTextureAccess; 312 GrTextureAccess fTextureAccess;
289 313
290 // currently not used in shader code, just to assist onComputeInvariantOutpu t(). 314 // currently not used in shader code, just to assist onComputeInvariantOutpu t().
291 unsigned fFlags; 315 unsigned fFlags;
292 316
293 GrTextureStripAtlas* fAtlas; 317 GrTextureStripAtlas* fAtlas;
294 int fRow; 318 int fRow;
295 319
296 typedef GrFragmentProcessor INHERITED; 320 typedef GrFragmentProcessor INHERITED;
297 }; 321 };
298 322
299 class GLColorTableEffect : public GrGLFragmentProcessor { 323 class GLColorTableEffect : public GrGLFragmentProcessor {
300 public: 324 public:
301 GLColorTableEffect(const GrBackendProcessorFactory&, const GrProcessor&); 325 GLColorTableEffect(const GrBackendProcessorFactory&, const GrProcessor&);
(...skipping 25 matching lines...) Expand all
327 if (cte.atlas()) { 351 if (cte.atlas()) {
328 SkScalar yDelta = cte.atlas()->getNormalizedTexelHeight(); 352 SkScalar yDelta = cte.atlas()->getNormalizedTexelHeight();
329 rgbaYValues[3] = cte.atlas()->getYOffset(cte.atlasRow()) + SK_ScalarHalf * yDelta; 353 rgbaYValues[3] = cte.atlas()->getYOffset(cte.atlasRow()) + SK_ScalarHalf * yDelta;
330 rgbaYValues[0] = rgbaYValues[3] + yDelta; 354 rgbaYValues[0] = rgbaYValues[3] + yDelta;
331 rgbaYValues[1] = rgbaYValues[0] + yDelta; 355 rgbaYValues[1] = rgbaYValues[0] + yDelta;
332 rgbaYValues[2] = rgbaYValues[1] + yDelta; 356 rgbaYValues[2] = rgbaYValues[1] + yDelta;
333 } else { 357 } else {
334 rgbaYValues[3] = 0.125; 358 rgbaYValues[3] = 0.125;
335 rgbaYValues[0] = 0.375; 359 rgbaYValues[0] = 0.375;
336 rgbaYValues[1] = 0.625; 360 rgbaYValues[1] = 0.625;
337 rgbaYValues[2] = 0.875; 361 rgbaYValues[2] = 0.875;
338 } 362 }
339 pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues); 363 pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues);
340 } 364 }
341 365
342 void GLColorTableEffect::emitCode(GrGLFPBuilder* builder, 366 void GLColorTableEffect::emitCode(GrGLFPBuilder* builder,
343 const GrFragmentProcessor&, 367 const GrFragmentProcessor&,
344 const char* outputColor, 368 const char* outputColor,
345 const char* inputColor, 369 const char* inputColor,
346 const TransformedCoordsArray&, 370 const TransformedCoordsArray&,
347 const TextureSamplerArray& samplers) { 371 const TextureSamplerArray& samplers) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], 546 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256],
523 const uint8_t tableR[256], 547 const uint8_t tableR[256],
524 const uint8_t tableG[256], 548 const uint8_t tableG[256],
525 const uint8_t tableB[256]) { 549 const uint8_t tableB[256]) {
526 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); 550 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB));
527 } 551 }
528 552
529 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) 553 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter)
530 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) 554 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter)
531 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 555 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkRectShaderImageFilter.cpp ('k') | src/effects/SkTableMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698