OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkDumpCanvas.h" | 9 #include "SkDumpCanvas.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SkString name("P:"); | 61 SkString name("P:"); |
62 const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR); | 62 const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR); |
63 name.append(basename ? basename+1: fFilename.c_str()); | 63 name.append(basename ? basename+1: fFilename.c_str()); |
64 switch (fBBox) { | 64 switch (fBBox) { |
65 case kNo_BBoxType: | 65 case kNo_BBoxType: |
66 // No name appended | 66 // No name appended |
67 break; | 67 break; |
68 case kRTree_BBoxType: | 68 case kRTree_BBoxType: |
69 name.append(" <bbox: R>"); | 69 name.append(" <bbox: R>"); |
70 break; | 70 break; |
71 case kQuadTree_BBoxType: | |
72 name.append(" <bbox: Q>"); | |
73 break; | |
74 case kTileGrid_BBoxType: | 71 case kTileGrid_BBoxType: |
75 name.append(" <bbox: T>"); | 72 name.append(" <bbox: T>"); |
76 break; | 73 break; |
77 default: | 74 default: |
78 SkASSERT(false); | 75 SkASSERT(false); |
79 break; | 76 break; |
80 } | 77 } |
81 SampleCode::TitleR(evt, name.c_str()); | 78 SampleCode::TitleR(evt, name.c_str()); |
82 return true; | 79 return true; |
83 } | 80 } |
(...skipping 16 matching lines...) Expand all Loading... |
100 *picture = LoadPicture(fFilename.c_str(), fBBox); | 97 *picture = LoadPicture(fFilename.c_str(), fBBox); |
101 } | 98 } |
102 if (*picture) { | 99 if (*picture) { |
103 canvas->drawPicture(*picture); | 100 canvas->drawPicture(*picture); |
104 } | 101 } |
105 } | 102 } |
106 | 103 |
107 private: | 104 private: |
108 enum BBoxType { | 105 enum BBoxType { |
109 kNo_BBoxType, | 106 kNo_BBoxType, |
110 kQuadTree_BBoxType, | |
111 kRTree_BBoxType, | 107 kRTree_BBoxType, |
112 kTileGrid_BBoxType, | 108 kTileGrid_BBoxType, |
113 | 109 |
114 kLast_BBoxType = kTileGrid_BBoxType | 110 kLast_BBoxType = kTileGrid_BBoxType |
115 }; | 111 }; |
116 static const int kBBoxTypeCount = kLast_BBoxType + 1; | 112 static const int kBBoxTypeCount = kLast_BBoxType + 1; |
117 | 113 |
118 SkString fFilename; | 114 SkString fFilename; |
119 SkPicture* fPictures[kBBoxTypeCount]; | 115 SkPicture* fPictures[kBBoxTypeCount]; |
120 BBoxType fBBox; | 116 BBoxType fBBox; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 156 } |
161 | 157 |
162 SkAutoTDelete<SkBBHFactory> factory; | 158 SkAutoTDelete<SkBBHFactory> factory; |
163 switch (bbox) { | 159 switch (bbox) { |
164 case kNo_BBoxType: | 160 case kNo_BBoxType: |
165 // no bbox playback necessary | 161 // no bbox playback necessary |
166 return pic.detach(); | 162 return pic.detach(); |
167 case kRTree_BBoxType: | 163 case kRTree_BBoxType: |
168 factory.reset(SkNEW(SkRTreeFactory)); | 164 factory.reset(SkNEW(SkRTreeFactory)); |
169 break; | 165 break; |
170 case kQuadTree_BBoxType: | |
171 factory.reset(SkNEW(SkQuadTreeFactory)); | |
172 break; | |
173 case kTileGrid_BBoxType: { | 166 case kTileGrid_BBoxType: { |
174 SkASSERT(!fTileSize.isEmpty()); | 167 SkASSERT(!fTileSize.isEmpty()); |
175 SkTileGridFactory::TileGridInfo gridInfo; | 168 SkTileGridFactory::TileGridInfo gridInfo; |
176 gridInfo.fMargin = SkISize::Make(0, 0); | 169 gridInfo.fMargin = SkISize::Make(0, 0); |
177 gridInfo.fOffset = SkIPoint::Make(0, 0); | 170 gridInfo.fOffset = SkIPoint::Make(0, 0); |
178 gridInfo.fTileInterval = fTileSize.toRound(); | 171 gridInfo.fTileInterval = fTileSize.toRound(); |
179 factory.reset(SkNEW_ARGS(SkTileGridFactory, (gridInfo))); | 172 factory.reset(SkNEW_ARGS(SkTileGridFactory, (gridInfo))); |
180 break; | 173 break; |
181 } | 174 } |
182 default: | 175 default: |
(...skipping 12 matching lines...) Expand all Loading... |
195 SampleView* CreateSamplePictFileView(const char filename[]) { | 188 SampleView* CreateSamplePictFileView(const char filename[]) { |
196 return new PictFileView(filename); | 189 return new PictFileView(filename); |
197 } | 190 } |
198 | 191 |
199 ////////////////////////////////////////////////////////////////////////////// | 192 ////////////////////////////////////////////////////////////////////////////// |
200 | 193 |
201 #if 0 | 194 #if 0 |
202 static SkView* MyFactory() { return new PictFileView; } | 195 static SkView* MyFactory() { return new PictFileView; } |
203 static SkViewRegister reg(MyFactory); | 196 static SkViewRegister reg(MyFactory); |
204 #endif | 197 #endif |
OLD | NEW |