| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 fPictures[i] = NULL; | 42 fPictures[i] = NULL; |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~PictFileView() { | 46 virtual ~PictFileView() { |
| 47 for (int i = 0; i < kBBoxTypeCount; ++i) { | 47 for (int i = 0; i < kBBoxTypeCount; ++i) { |
| 48 SkSafeUnref(fPictures[i]); | 48 SkSafeUnref(fPictures[i]); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void onTileSizeChanged(const SkSize &tileSize) SK_OVERRIDE { | 52 void onTileSizeChanged(const SkSize &tileSize) override { |
| 53 if (tileSize != fTileSize) { | 53 if (tileSize != fTileSize) { |
| 54 fTileSize = tileSize; | 54 fTileSize = tileSize; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 // overrides from SkEventSink | 59 // overrides from SkEventSink |
| 60 bool onQuery(SkEvent* evt) SK_OVERRIDE { | 60 bool onQuery(SkEvent* evt) override { |
| 61 if (SampleCode::TitleQ(*evt)) { | 61 if (SampleCode::TitleQ(*evt)) { |
| 62 SkString name("P:"); | 62 SkString name("P:"); |
| 63 const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR); | 63 const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR); |
| 64 name.append(basename ? basename+1: fFilename.c_str()); | 64 name.append(basename ? basename+1: fFilename.c_str()); |
| 65 switch (fBBox) { | 65 switch (fBBox) { |
| 66 case kNo_BBoxType: | 66 case kNo_BBoxType: |
| 67 // No name appended | 67 // No name appended |
| 68 break; | 68 break; |
| 69 case kRTree_BBoxType: | 69 case kRTree_BBoxType: |
| 70 name.append(" <bbox: R>"); | 70 name.append(" <bbox: R>"); |
| 71 break; | 71 break; |
| 72 default: | 72 default: |
| 73 SkASSERT(false); | 73 SkASSERT(false); |
| 74 break; | 74 break; |
| 75 } | 75 } |
| 76 SampleCode::TitleR(evt, name.c_str()); | 76 SampleCode::TitleR(evt, name.c_str()); |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 return this->INHERITED::onQuery(evt); | 79 return this->INHERITED::onQuery(evt); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool onEvent(const SkEvent& evt) SK_OVERRIDE { | 82 bool onEvent(const SkEvent& evt) override { |
| 83 if (evt.isType("PictFileView::toggleBBox")) { | 83 if (evt.isType("PictFileView::toggleBBox")) { |
| 84 fBBox = (BBoxType)((fBBox + 1) % kBBoxTypeCount); | 84 fBBox = (BBoxType)((fBBox + 1) % kBBoxTypeCount); |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 return this->INHERITED::onEvent(evt); | 87 return this->INHERITED::onEvent(evt); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 90 void onDrawContent(SkCanvas* canvas) override { |
| 91 SkASSERT(static_cast<int>(fBBox) < kBBoxTypeCount); | 91 SkASSERT(static_cast<int>(fBBox) < kBBoxTypeCount); |
| 92 SkPicture** picture = fPictures + fBBox; | 92 SkPicture** picture = fPictures + fBBox; |
| 93 | 93 |
| 94 #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS | 94 #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS |
| 95 SkGraphics::PurgeFontCache(); | 95 SkGraphics::PurgeFontCache(); |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 if (!*picture) { | 98 if (!*picture) { |
| 99 *picture = LoadPicture(fFilename.c_str(), fBBox); | 99 *picture = LoadPicture(fFilename.c_str(), fBBox); |
| 100 } | 100 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 SampleView* CreateSamplePictFileView(const char filename[]) { | 186 SampleView* CreateSamplePictFileView(const char filename[]) { |
| 187 return new PictFileView(filename); | 187 return new PictFileView(filename); |
| 188 } | 188 } |
| 189 | 189 |
| 190 ////////////////////////////////////////////////////////////////////////////// | 190 ////////////////////////////////////////////////////////////////////////////// |
| 191 | 191 |
| 192 #if 0 | 192 #if 0 |
| 193 static SkView* MyFactory() { return new PictFileView; } | 193 static SkView* MyFactory() { return new PictFileView; } |
| 194 static SkViewRegister reg(MyFactory); | 194 static SkViewRegister reg(MyFactory); |
| 195 #endif | 195 #endif |
| OLD | NEW |