OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkDebuggerGUI.h" | 8 #include "SkDebuggerGUI.h" |
9 #include "PictureRenderer.h" | 9 #include "PictureRenderer.h" |
10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 | 348 |
349 void SkDebuggerGUI::drawComplete() { | 349 void SkDebuggerGUI::drawComplete() { |
350 SkString clipStack; | 350 SkString clipStack; |
351 fDebugger.getClipStackText(&clipStack); | 351 fDebugger.getClipStackText(&clipStack); |
352 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta bType); | 352 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta bType); |
353 | 353 |
354 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix()); | 354 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix()); |
355 fInspectorWidget.setClip(fDebugger.getCurrentClip()); | 355 fInspectorWidget.setClip(fDebugger.getCurrentClip()); |
356 } | 356 } |
357 | 357 |
358 // Encodes to PNG, unless there is already encoded data, in which case that gets | |
359 // used. | |
360 class PngPixelSerializer : public SkPixelSerializer { | |
scroggo
2015/03/20 17:21:41
I think this is the third instance of this. It may
| |
361 public: | |
362 bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true; } | |
363 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, | |
364 size_t rowBytes) SK_OVERRIDE { | |
365 return SkImageEncoder::EncodeData(info, pixels, rowBytes, SkImageEncoder ::kPNG_Type, 100); | |
366 } | |
367 }; | |
368 | |
358 void SkDebuggerGUI::saveToFile(const SkString& filename) { | 369 void SkDebuggerGUI::saveToFile(const SkString& filename) { |
359 SkFILEWStream file(filename.c_str()); | 370 SkFILEWStream file(filename.c_str()); |
360 SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture()); | 371 SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture()); |
361 | 372 |
362 copy->serialize(&file); | 373 PngPixelSerializer serializer; |
374 copy->serialize(&file, &serializer); | |
363 } | 375 } |
364 | 376 |
365 void SkDebuggerGUI::loadFile(QListWidgetItem *item) { | 377 void SkDebuggerGUI::loadFile(QListWidgetItem *item) { |
366 if (fDirectoryWidgetActive) { | 378 if (fDirectoryWidgetActive) { |
367 fFileName = fPath.toAscii().data(); | 379 fFileName = fPath.toAscii().data(); |
368 // don't add a '/' to files in the local directory | 380 // don't add a '/' to files in the local directory |
369 if (fFileName.size() > 0) { | 381 if (fFileName.size() > 0) { |
370 fFileName.append("/"); | 382 fFileName.append("/"); |
371 } | 383 } |
372 fFileName.append(item->text().toAscii().data()); | 384 fFileName.append(item->text().toAscii().data()); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 fCanvasWidget.drawTo(fPausedRow); | 864 fCanvasWidget.drawTo(fPausedRow); |
853 } else { | 865 } else { |
854 fCanvasWidget.drawTo(fListWidget.currentRow()); | 866 fCanvasWidget.drawTo(fListWidget.currentRow()); |
855 } | 867 } |
856 } | 868 } |
857 | 869 |
858 void SkDebuggerGUI::updateHit(int newHit) { | 870 void SkDebuggerGUI::updateHit(int newHit) { |
859 fCommandHitBox.setText(QString::number(newHit)); | 871 fCommandHitBox.setText(QString::number(newHit)); |
860 } | 872 } |
861 | 873 |
OLD | NEW |