OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { | 65 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { |
66 public: | 66 public: |
67 FakeCanvas2DLayerBridge(WebGraphicsContext3D* context, PassOwnPtr<SkDeferred
Canvas> canvas, PassRefPtr<SkSurface> surface) | 67 FakeCanvas2DLayerBridge(WebGraphicsContext3D* context, PassOwnPtr<SkDeferred
Canvas> canvas, PassRefPtr<SkSurface> surface) |
68 : Canvas2DLayerBridge(adoptPtr(new MockWebGraphicsContext3DProvider(cont
ext)), canvas, surface, 0, NonOpaque) | 68 : Canvas2DLayerBridge(adoptPtr(new MockWebGraphicsContext3DProvider(cont
ext)), canvas, surface, 0, NonOpaque) |
69 , m_freeableBytes(0) | 69 , m_freeableBytes(0) |
70 , m_freeMemoryIfPossibleCount(0) | 70 , m_freeMemoryIfPossibleCount(0) |
71 , m_flushCount(0) | 71 , m_flushCount(0) |
72 { | 72 { |
73 } | 73 } |
74 | 74 |
75 virtual size_t storageAllocatedForRecording() OVERRIDE | 75 virtual size_t storageAllocatedForRecording() override |
76 { | 76 { |
77 // Because the fake layer has no canvas to query, just | 77 // Because the fake layer has no canvas to query, just |
78 // return status quo. Allocation changes that would normally be | 78 // return status quo. Allocation changes that would normally be |
79 // initiated by the canvas can be faked by invoking | 79 // initiated by the canvas can be faked by invoking |
80 // storageAllocatedForRecordingChanged directly from the test code. | 80 // storageAllocatedForRecordingChanged directly from the test code. |
81 return m_bytesAllocated; | 81 return m_bytesAllocated; |
82 } | 82 } |
83 | 83 |
84 void fakeFreeableBytes(size_t size) | 84 void fakeFreeableBytes(size_t size) |
85 { | 85 { |
86 m_freeableBytes = size; | 86 m_freeableBytes = size; |
87 } | 87 } |
88 | 88 |
89 virtual size_t freeMemoryIfPossible(size_t size) OVERRIDE | 89 virtual size_t freeMemoryIfPossible(size_t size) override |
90 { | 90 { |
91 m_freeMemoryIfPossibleCount++; | 91 m_freeMemoryIfPossibleCount++; |
92 size_t bytesFreed = size < m_freeableBytes ? size : m_freeableBytes; | 92 size_t bytesFreed = size < m_freeableBytes ? size : m_freeableBytes; |
93 m_freeableBytes -= bytesFreed; | 93 m_freeableBytes -= bytesFreed; |
94 if (bytesFreed) | 94 if (bytesFreed) |
95 storageAllocatedForRecordingChanged(m_bytesAllocated - bytesFreed); | 95 storageAllocatedForRecordingChanged(m_bytesAllocated - bytesFreed); |
96 return bytesFreed; | 96 return bytesFreed; |
97 } | 97 } |
98 | 98 |
99 virtual void flush() OVERRIDE | 99 virtual void flush() override |
100 { | 100 { |
101 flushedDrawCommands(); | 101 flushedDrawCommands(); |
102 m_freeableBytes = bytesAllocated(); | 102 m_freeableBytes = bytesAllocated(); |
103 m_flushCount++; | 103 m_flushCount++; |
104 } | 104 } |
105 | 105 |
106 public: | 106 public: |
107 size_t m_freeableBytes; | 107 size_t m_freeableBytes; |
108 int m_freeMemoryIfPossibleCount; | 108 int m_freeMemoryIfPossibleCount; |
109 int m_flushCount; | 109 int m_flushCount; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 class DeferredFrameTestTask : public WebThread::Task { | 251 class DeferredFrameTestTask : public WebThread::Task { |
252 public: | 252 public: |
253 DeferredFrameTestTask(Canvas2DLayerManagerTest* test, FakeCanvas2DLayerB
ridge* layer, bool skipCommands) | 253 DeferredFrameTestTask(Canvas2DLayerManagerTest* test, FakeCanvas2DLayerB
ridge* layer, bool skipCommands) |
254 { | 254 { |
255 m_test = test; | 255 m_test = test; |
256 m_layer = layer; | 256 m_layer = layer; |
257 m_skipCommands = skipCommands; | 257 m_skipCommands = skipCommands; |
258 } | 258 } |
259 | 259 |
260 virtual void run() OVERRIDE | 260 virtual void run() override |
261 { | 261 { |
262 m_test->doDeferredFrameTestTask(m_layer, m_skipCommands); | 262 m_test->doDeferredFrameTestTask(m_layer, m_skipCommands); |
263 } | 263 } |
264 private: | 264 private: |
265 Canvas2DLayerManagerTest* m_test; | 265 Canvas2DLayerManagerTest* m_test; |
266 FakeCanvas2DLayerBridge* m_layer; | 266 FakeCanvas2DLayerBridge* m_layer; |
267 bool m_skipCommands; | 267 bool m_skipCommands; |
268 }; | 268 }; |
269 | 269 |
270 void deferredFrameTest() | 270 void deferredFrameTest() |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 hiddenCanvasTest(); | 332 hiddenCanvasTest(); |
333 } | 333 } |
334 | 334 |
335 TEST_F(Canvas2DLayerManagerTest, testAddRemoveLayer) | 335 TEST_F(Canvas2DLayerManagerTest, testAddRemoveLayer) |
336 { | 336 { |
337 addRemoveLayerTest(); | 337 addRemoveLayerTest(); |
338 } | 338 } |
339 | 339 |
340 } // unnamed namespace | 340 } // unnamed namespace |
341 | 341 |
OLD | NEW |