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

Side by Side Diff: src/pipe/SkGPipeRead.cpp

Issue 26702002: force readbuffer clients to use specialized readFoo for flattenables (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/pipe/SkGPipePriv.h ('k') | tests/ColorFilterTest.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBitmapHeap.h" 10 #include "SkBitmapHeap.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkPaint.h" 12 #include "SkPaint.h"
13 #include "SkGPipe.h" 13 #include "SkGPipe.h"
14 #include "SkGPipePriv.h" 14 #include "SkGPipePriv.h"
15 #include "SkReader32.h" 15 #include "SkReader32.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 17
18 #include "SkAnnotation.h" 18 #include "SkAnnotation.h"
19 #include "SkColorFilter.h" 19 #include "SkColorFilter.h"
20 #include "SkDrawLooper.h" 20 #include "SkDrawLooper.h"
21 #include "SkImageFilter.h"
21 #include "SkMaskFilter.h" 22 #include "SkMaskFilter.h"
22 #include "SkOrderedReadBuffer.h" 23 #include "SkOrderedReadBuffer.h"
23 #include "SkPathEffect.h" 24 #include "SkPathEffect.h"
24 #include "SkRasterizer.h" 25 #include "SkRasterizer.h"
25 #include "SkRRect.h" 26 #include "SkRRect.h"
26 #include "SkShader.h" 27 #include "SkShader.h"
27 #include "SkTypeface.h" 28 #include "SkTypeface.h"
28 #include "SkXfermode.h" 29 #include "SkXfermode.h"
29 30
31 static SkEffectType paintflat_to_effecttype(PaintFlats pf) {
32 static const uint8_t gEffectTypesInPaintFlatsOrder[] = {
33 kColorFilter_SkEffectType,
34 kDrawLooper_SkEffectType,
35 kImageFilter_SkEffectType,
36 kMaskFilter_SkEffectType,
37 kPathEffect_SkEffectType,
38 kRasterizer_SkEffectType,
39 kShader_SkEffectType,
40 kXfermode_SkEffectType,
41 };
42
43 SkASSERT((size_t)pf < SK_ARRAY_COUNT(gEffectTypesInPaintFlatsOrder));
44 return (SkEffectType)gEffectTypesInPaintFlatsOrder[pf];
45 }
46
30 static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat ) { 47 static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat ) {
31 SkASSERT(paintFlat < kCount_PaintFlats); 48 SkASSERT(paintFlat < kCount_PaintFlats);
32 switch (paintFlat) { 49 switch (paintFlat) {
33 case kColorFilter_PaintFlat: 50 case kColorFilter_PaintFlat:
34 paint->setColorFilter((SkColorFilter*)obj); 51 paint->setColorFilter((SkColorFilter*)obj);
35 break; 52 break;
36 case kDrawLooper_PaintFlat: 53 case kDrawLooper_PaintFlat:
37 paint->setLooper((SkDrawLooper*)obj); 54 paint->setLooper((SkDrawLooper*)obj);
38 break; 55 break;
39 case kMaskFilter_PaintFlat: 56 case kMaskFilter_PaintFlat:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 115
99 SkFlattenable* getFlat(unsigned index) const { 116 SkFlattenable* getFlat(unsigned index) const {
100 if (0 == index) { 117 if (0 == index) {
101 return NULL; 118 return NULL;
102 } 119 }
103 return fFlatArray[index - 1]; 120 return fFlatArray[index - 1];
104 } 121 }
105 122
106 void defFlattenable(PaintFlats pf, int index) { 123 void defFlattenable(PaintFlats pf, int index) {
107 index--; 124 index--;
108 SkFlattenable* obj = fReader->readFlattenable(); 125 SkFlattenable* obj = fReader->readFlattenable(paintflat_to_effecttype(pf ));
109 if (fFlatArray.count() == index) { 126 if (fFlatArray.count() == index) {
110 *fFlatArray.append() = obj; 127 *fFlatArray.append() = obj;
111 } else { 128 } else {
112 SkSafeUnref(fFlatArray[index]); 129 SkSafeUnref(fFlatArray[index]);
113 fFlatArray[index] = obj; 130 fFlatArray[index] = obj;
114 } 131 }
115 } 132 }
116 133
117 void defFactory(const char* name) { 134 void defFactory(const char* name) {
118 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); 135 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name);
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 status = kReadAtom_Status; 886 status = kReadAtom_Status;
870 break; 887 break;
871 } 888 }
872 } 889 }
873 890
874 if (bytesRead) { 891 if (bytesRead) {
875 *bytesRead = reader.offset(); 892 *bytesRead = reader.offset();
876 } 893 }
877 return status; 894 return status;
878 } 895 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipePriv.h ('k') | tests/ColorFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698