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 12 matching lines...) Expand all Loading... |
23 #include "SkColorPriv.h" | 23 #include "SkColorPriv.h" |
24 #include "SkColorFilter.h" | 24 #include "SkColorFilter.h" |
25 #include "SkTime.h" | 25 #include "SkTime.h" |
26 #include "SkTypeface.h" | 26 #include "SkTypeface.h" |
27 #include "SkXfermode.h" | 27 #include "SkXfermode.h" |
28 | 28 |
29 #include "SkStream.h" | 29 #include "SkStream.h" |
30 #include "SkSurface.h" | 30 #include "SkSurface.h" |
31 #include "SkXMLParser.h" | 31 #include "SkXMLParser.h" |
32 | 32 |
| 33 #include "SkGlyphCache.h" |
| 34 |
33 class PictFileView : public SampleView { | 35 class PictFileView : public SampleView { |
34 public: | 36 public: |
35 PictFileView(const char name[] = NULL) | 37 PictFileView(const char name[] = NULL) |
36 : fFilename(name) | 38 : fFilename(name) |
37 , fBBox(kNo_BBoxType) | 39 , fBBox(kNo_BBoxType) |
38 , fTileSize(SkSize::Make(0, 0)) { | 40 , fTileSize(SkSize::Make(0, 0)) { |
39 for (int i = 0; i < kBBoxTypeCount; ++i) { | 41 for (int i = 0; i < kBBoxTypeCount; ++i) { |
40 fPictures[i] = NULL; | 42 fPictures[i] = NULL; |
41 } | 43 } |
42 } | 44 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 fBBox = (BBoxType)((fBBox + 1) % kBBoxTypeCount); | 84 fBBox = (BBoxType)((fBBox + 1) % kBBoxTypeCount); |
83 return true; | 85 return true; |
84 } | 86 } |
85 return this->INHERITED::onEvent(evt); | 87 return this->INHERITED::onEvent(evt); |
86 } | 88 } |
87 | 89 |
88 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 90 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
89 SkASSERT(static_cast<int>(fBBox) < kBBoxTypeCount); | 91 SkASSERT(static_cast<int>(fBBox) < kBBoxTypeCount); |
90 SkPicture** picture = fPictures + fBBox; | 92 SkPicture** picture = fPictures + fBBox; |
91 | 93 |
| 94 #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS |
| 95 SkGraphics::PurgeFontCache(); |
| 96 #endif |
| 97 |
92 if (!*picture) { | 98 if (!*picture) { |
93 *picture = LoadPicture(fFilename.c_str(), fBBox); | 99 *picture = LoadPicture(fFilename.c_str(), fBBox); |
94 } | 100 } |
95 if (*picture) { | 101 if (*picture) { |
96 canvas->drawPicture(*picture); | 102 canvas->drawPicture(*picture); |
97 } | 103 } |
| 104 |
| 105 #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS |
| 106 SkGlyphCache::Dump(); |
| 107 SkDebugf("\n"); |
| 108 #endif |
98 } | 109 } |
99 | 110 |
100 private: | 111 private: |
101 enum BBoxType { | 112 enum BBoxType { |
102 kNo_BBoxType, | 113 kNo_BBoxType, |
103 kRTree_BBoxType, | 114 kRTree_BBoxType, |
104 | 115 |
105 kLast_BBoxType = kRTree_BBoxType, | 116 kLast_BBoxType = kRTree_BBoxType, |
106 }; | 117 }; |
107 static const int kBBoxTypeCount = kLast_BBoxType + 1; | 118 static const int kBBoxTypeCount = kLast_BBoxType + 1; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 SampleView* CreateSamplePictFileView(const char filename[]) { | 186 SampleView* CreateSamplePictFileView(const char filename[]) { |
176 return new PictFileView(filename); | 187 return new PictFileView(filename); |
177 } | 188 } |
178 | 189 |
179 ////////////////////////////////////////////////////////////////////////////// | 190 ////////////////////////////////////////////////////////////////////////////// |
180 | 191 |
181 #if 0 | 192 #if 0 |
182 static SkView* MyFactory() { return new PictFileView; } | 193 static SkView* MyFactory() { return new PictFileView; } |
183 static SkViewRegister reg(MyFactory); | 194 static SkViewRegister reg(MyFactory); |
184 #endif | 195 #endif |
OLD | NEW |