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 "../src/image/SkImagePriv.h" | 8 #include "../src/image/SkImagePriv.h" |
9 #include "../src/image/SkSurface_Base.h" | 9 #include "../src/image/SkSurface_Base.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return pixel; | 49 return pixel; |
50 } | 50 } |
51 | 51 |
52 class MockSurface : public SkSurface_Base { | 52 class MockSurface : public SkSurface_Base { |
53 public: | 53 public: |
54 MockSurface(int width, int height) : SkSurface_Base(width, height, NULL) { | 54 MockSurface(int width, int height) : SkSurface_Base(width, height, NULL) { |
55 clearCounts(); | 55 clearCounts(); |
56 fBitmap.allocN32Pixels(width, height); | 56 fBitmap.allocN32Pixels(width, height); |
57 } | 57 } |
58 | 58 |
59 SkCanvas* onNewCanvas() SK_OVERRIDE { | 59 SkCanvas* onNewCanvas() override { |
60 return SkNEW_ARGS(SkCanvas, (fBitmap)); | 60 return SkNEW_ARGS(SkCanvas, (fBitmap)); |
61 } | 61 } |
62 | 62 |
63 SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE { | 63 SkSurface* onNewSurface(const SkImageInfo&) override { |
64 return NULL; | 64 return NULL; |
65 } | 65 } |
66 | 66 |
67 SkImage* onNewImageSnapshot(Budgeted) SK_OVERRIDE { | 67 SkImage* onNewImageSnapshot(Budgeted) override { |
68 return SkNewImageFromBitmap(fBitmap, true, &this->props()); | 68 return SkNewImageFromBitmap(fBitmap, true, &this->props()); |
69 } | 69 } |
70 | 70 |
71 void onCopyOnWrite(ContentChangeMode mode) SK_OVERRIDE { | 71 void onCopyOnWrite(ContentChangeMode mode) override { |
72 if (mode == SkSurface::kDiscard_ContentChangeMode) { | 72 if (mode == SkSurface::kDiscard_ContentChangeMode) { |
73 fCOWDiscardCount++; | 73 fCOWDiscardCount++; |
74 } else { | 74 } else { |
75 fCOWRetainCount++; | 75 fCOWRetainCount++; |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 void onDiscard() SK_OVERRIDE { | 79 void onDiscard() override { |
80 fDiscardCount++; | 80 fDiscardCount++; |
81 } | 81 } |
82 | 82 |
83 void clearCounts() { | 83 void clearCounts() { |
84 fCOWDiscardCount = 0; | 84 fCOWDiscardCount = 0; |
85 fCOWRetainCount = 0; | 85 fCOWRetainCount = 0; |
86 fDiscardCount = 0; | 86 fDiscardCount = 0; |
87 } | 87 } |
88 | 88 |
89 int fCOWDiscardCount; | 89 int fCOWDiscardCount; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 REPORTER_ASSERT(reporter, canvas->isFreshFrame()); | 439 REPORTER_ASSERT(reporter, canvas->isFreshFrame()); |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 class MockDevice : public SkBitmapDevice { | 443 class MockDevice : public SkBitmapDevice { |
444 public: | 444 public: |
445 MockDevice(const SkBitmap& bm) : SkBitmapDevice(bm) { | 445 MockDevice(const SkBitmap& bm) : SkBitmapDevice(bm) { |
446 fDrawBitmapCallCount = 0; | 446 fDrawBitmapCallCount = 0; |
447 } | 447 } |
448 virtual void drawBitmap(const SkDraw&, const SkBitmap&, | 448 virtual void drawBitmap(const SkDraw&, const SkBitmap&, |
449 const SkMatrix&, const SkPaint&) SK_OVERRIDE { | 449 const SkMatrix&, const SkPaint&) override { |
450 fDrawBitmapCallCount++; | 450 fDrawBitmapCallCount++; |
451 } | 451 } |
452 | 452 |
453 int fDrawBitmapCallCount; | 453 int fDrawBitmapCallCount; |
454 }; | 454 }; |
455 | 455 |
456 class NotificationCounter : public SkDeferredCanvas::NotificationClient { | 456 class NotificationCounter : public SkDeferredCanvas::NotificationClient { |
457 public: | 457 public: |
458 NotificationCounter() { | 458 NotificationCounter() { |
459 fPrepareForDrawCount = fStorageAllocatedChangedCount = | 459 fPrepareForDrawCount = fStorageAllocatedChangedCount = |
460 fFlushedDrawCommandsCount = fSkippedPendingDrawCommandsCount = 0; | 460 fFlushedDrawCommandsCount = fSkippedPendingDrawCommandsCount = 0; |
461 } | 461 } |
462 | 462 |
463 void prepareForDraw() SK_OVERRIDE { | 463 void prepareForDraw() override { |
464 fPrepareForDrawCount++; | 464 fPrepareForDrawCount++; |
465 } | 465 } |
466 void storageAllocatedForRecordingChanged(size_t) SK_OVERRIDE { | 466 void storageAllocatedForRecordingChanged(size_t) override { |
467 fStorageAllocatedChangedCount++; | 467 fStorageAllocatedChangedCount++; |
468 } | 468 } |
469 void flushedDrawCommands() SK_OVERRIDE { | 469 void flushedDrawCommands() override { |
470 fFlushedDrawCommandsCount++; | 470 fFlushedDrawCommandsCount++; |
471 } | 471 } |
472 void skippedPendingDrawCommands() SK_OVERRIDE { | 472 void skippedPendingDrawCommands() override { |
473 fSkippedPendingDrawCommandsCount++; | 473 fSkippedPendingDrawCommandsCount++; |
474 } | 474 } |
475 | 475 |
476 int fPrepareForDrawCount; | 476 int fPrepareForDrawCount; |
477 int fStorageAllocatedChangedCount; | 477 int fStorageAllocatedChangedCount; |
478 int fFlushedDrawCommandsCount; | 478 int fFlushedDrawCommandsCount; |
479 int fSkippedPendingDrawCommandsCount; | 479 int fSkippedPendingDrawCommandsCount; |
480 | 480 |
481 private: | 481 private: |
482 typedef SkDeferredCanvas::NotificationClient INHERITED; | 482 typedef SkDeferredCanvas::NotificationClient INHERITED; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 TestDeferredCanvasSurface(reporter, NULL); | 936 TestDeferredCanvasSurface(reporter, NULL); |
937 TestDeferredCanvasSetSurface(reporter, NULL); | 937 TestDeferredCanvasSetSurface(reporter, NULL); |
938 } | 938 } |
939 | 939 |
940 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { | 940 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { |
941 if (factory != NULL) { | 941 if (factory != NULL) { |
942 TestDeferredCanvasSurface(reporter, factory); | 942 TestDeferredCanvasSurface(reporter, factory); |
943 TestDeferredCanvasSetSurface(reporter, factory); | 943 TestDeferredCanvasSetSurface(reporter, factory); |
944 } | 944 } |
945 } | 945 } |
OLD | NEW |