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