| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 | 42 |
| 43 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { | 43 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { |
| 44 public: | 44 public: |
| 45 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan
vas* canvas) | 45 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan
vas* canvas) |
| 46 : Canvas2DLayerBridge(context, canvas, NonOpaque, SingleThread) | 46 : Canvas2DLayerBridge(context, canvas, NonOpaque, SingleThread) |
| 47 , m_freeableBytes(0) | 47 , m_freeableBytes(0) |
| 48 , m_freeMemoryIfPossibleCount(0) | 48 , m_freeMemoryIfPossibleCount(0) |
| 49 , m_flushCount(0) | 49 , m_flushCount(0) |
| 50 { | 50 { |
| 51 m_fakeSharedContext = m_context; |
| 51 } | 52 } |
| 52 | 53 |
| 53 virtual size_t storageAllocatedForRecording() OVERRIDE | 54 virtual size_t storageAllocatedForRecording() OVERRIDE |
| 54 { | 55 { |
| 55 // Because the fake layer has no canvas to query, just | 56 // Because the fake layer has no canvas to query, just |
| 56 // return status quo. Allocation changes that would normally be | 57 // return status quo. Allocation changes that would normally be |
| 57 // initiated by the canvas can be faked by invoking | 58 // initiated by the canvas can be faked by invoking |
| 58 // storageAllocatedForRecordingChanged directly from the test code. | 59 // storageAllocatedForRecordingChanged directly from the test code. |
| 59 return m_bytesAllocated; | 60 return m_bytesAllocated; |
| 60 } | 61 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 m_bytesAllocated -= bytesFreed; | 75 m_bytesAllocated -= bytesFreed; |
| 75 return bytesFreed; | 76 return bytesFreed; |
| 76 } | 77 } |
| 77 | 78 |
| 78 virtual void flush() OVERRIDE | 79 virtual void flush() OVERRIDE |
| 79 { | 80 { |
| 80 flushedDrawCommands(); | 81 flushedDrawCommands(); |
| 81 m_flushCount++; | 82 m_flushCount++; |
| 82 } | 83 } |
| 83 | 84 |
| 85 protected: |
| 86 virtual PassRefPtr<GraphicsContext3D> getSharedContext() const OVERRIDE |
| 87 { |
| 88 return m_fakeSharedContext; |
| 89 } |
| 84 public: | 90 public: |
| 85 size_t m_freeableBytes; | 91 size_t m_freeableBytes; |
| 86 int m_freeMemoryIfPossibleCount; | 92 int m_freeMemoryIfPossibleCount; |
| 87 int m_flushCount; | 93 int m_flushCount; |
| 94 private: |
| 95 RefPtr<GraphicsContext3D> m_fakeSharedContext; |
| 88 }; | 96 }; |
| 89 | 97 |
| 90 static PassOwnPtr<SkDeferredCanvas> createCanvas(GraphicsContext3D* context) { | 98 static PassOwnPtr<SkDeferredCanvas> createCanvas(GraphicsContext3D* context) { |
| 91 SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, 1, 1
)); | 99 SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, 1, 1
)); |
| 92 return adoptPtr(new SkDeferredCanvas(device.get())); | 100 return adoptPtr(new SkDeferredCanvas(device.get())); |
| 93 } | 101 } |
| 94 | 102 |
| 95 class Canvas2DLayerManagerTest : public Test { | 103 class Canvas2DLayerManagerTest : public Test { |
| 96 protected: | 104 protected: |
| 97 void storageAllocationTrackingTest() | 105 void storageAllocationTrackingTest() |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 flushEvictionTest(); | 264 flushEvictionTest(); |
| 257 } | 265 } |
| 258 | 266 |
| 259 TEST_F(Canvas2DLayerManagerTest, testDeferredFrame) | 267 TEST_F(Canvas2DLayerManagerTest, testDeferredFrame) |
| 260 { | 268 { |
| 261 deferredFrameTest(); | 269 deferredFrameTest(); |
| 262 } | 270 } |
| 263 | 271 |
| 264 } // namespace | 272 } // namespace |
| 265 | 273 |
| OLD | NEW |