| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "TiledLayerChromium.h" | 7 #include "TiledLayerChromium.h" |
| 8 | 8 |
| 9 #include "BitmapCanvasLayerTextureUpdater.h" | 9 #include "BitmapCanvasLayerTextureUpdater.h" |
| 10 #include "CCAnimationTestCommon.h" | 10 #include "CCAnimationTestCommon.h" |
| 11 #include "CCGeometryTestUtils.h" | 11 #include "CCGeometryTestUtils.h" |
| 12 #include "CCOverdrawMetrics.h" | 12 #include "CCOverdrawMetrics.h" |
| 13 #include "CCRenderingStats.h" | 13 #include "CCRenderingStats.h" |
| 14 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread | 14 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread |
| 15 #include "CCTextureUpdateController.h" | 15 #include "CCTextureUpdateController.h" |
| 16 #include "CCTiledLayerTestCommon.h" | 16 #include "CCTiledLayerTestCommon.h" |
| 17 #include "FakeCCGraphicsContext.h" | 17 #include "FakeCCGraphicsContext.h" |
| 18 #include "FakeCCLayerTreeHostClient.h" | 18 #include "FakeCCLayerTreeHostClient.h" |
| 19 #include "LayerPainterChromium.h" | 19 #include "LayerPainterChromium.h" |
| 20 #include "WebCompositorInitializer.h" |
| 20 #include <gtest/gtest.h> | 21 #include <gtest/gtest.h> |
| 21 #include <public/WebCompositor.h> | |
| 22 #include <public/WebTransformationMatrix.h> | 22 #include <public/WebTransformationMatrix.h> |
| 23 | 23 |
| 24 using namespace WebCore; | 24 using namespace WebCore; |
| 25 using namespace WebKitTests; | 25 using namespace WebKitTests; |
| 26 using namespace WTF; | 26 using namespace WTF; |
| 27 using WebKit::WebTransformationMatrix; | 27 using WebKit::WebTransformationMatrix; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 class TestCCOcclusionTracker : public CCOcclusionTracker { | 31 class TestCCOcclusionTracker : public CCOcclusionTracker { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 protected: | 43 protected: |
| 44 virtual IntRect layerClipRectInTarget(const LayerChromium* layer) const OVER
RIDE { return m_layerClipRectInTarget; } | 44 virtual IntRect layerClipRectInTarget(const LayerChromium* layer) const OVER
RIDE { return m_layerClipRectInTarget; } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 IntRect m_layerClipRectInTarget; | 47 IntRect m_layerClipRectInTarget; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class TiledLayerChromiumTest : public testing::Test { | 50 class TiledLayerChromiumTest : public testing::Test { |
| 51 public: | 51 public: |
| 52 TiledLayerChromiumTest() | 52 TiledLayerChromiumTest() |
| 53 : m_context(WebKit::createFakeCCGraphicsContext()) | 53 : m_compositorInitializer(0) |
| 54 , m_context(WebKit::createFakeCCGraphicsContext()) |
| 54 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102
4, CCRenderer::ContentPool)) | 55 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102
4, CCRenderer::ContentPool)) |
| 55 , m_occlusion(0) | 56 , m_occlusion(0) |
| 56 { | 57 { |
| 57 WebKit::WebCompositor::initialize(0); | |
| 58 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 58 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 59 m_resourceProvider = CCResourceProvider::create(m_context.get()); | 59 m_resourceProvider = CCResourceProvider::create(m_context.get()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual ~TiledLayerChromiumTest() | 62 virtual ~TiledLayerChromiumTest() |
| 63 { | 63 { |
| 64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.
get()); | 64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.
get()); |
| 65 { | 65 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 66 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThread
Blocked; | 66 m_resourceProvider.clear(); |
| 67 m_resourceProvider.clear(); | |
| 68 } | |
| 69 WebKit::WebCompositor::shutdown(); | |
| 70 } | 67 } |
| 71 | 68 |
| 72 // Helper classes and functions that set the current thread to be the impl t
hread | 69 // Helper classes and functions that set the current thread to be the impl t
hread |
| 73 // before doing the action that they wrap. | 70 // before doing the action that they wrap. |
| 74 class ScopedFakeCCTiledLayerImpl { | 71 class ScopedFakeCCTiledLayerImpl { |
| 75 public: | 72 public: |
| 76 ScopedFakeCCTiledLayerImpl(int id) | 73 ScopedFakeCCTiledLayerImpl(int id) |
| 77 { | 74 { |
| 78 DebugScopedSetImplThread implThread; | 75 DebugScopedSetImplThread implThread; |
| 79 m_layerImpl = new FakeCCTiledLayerImpl(id); | 76 m_layerImpl = new FakeCCTiledLayerImpl(id); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 updateTextures(); | 141 updateTextures(); |
| 145 if (layer1) | 142 if (layer1) |
| 146 layerPushPropertiesTo(layer1, layerImpl1); | 143 layerPushPropertiesTo(layer1, layerImpl1); |
| 147 if (layer2) | 144 if (layer2) |
| 148 layerPushPropertiesTo(layer2, layerImpl2); | 145 layerPushPropertiesTo(layer2, layerImpl2); |
| 149 | 146 |
| 150 return needsUpdate; | 147 return needsUpdate; |
| 151 } | 148 } |
| 152 | 149 |
| 153 public: | 150 public: |
| 151 WebKitTests::WebCompositorInitializer m_compositorInitializer; |
| 154 OwnPtr<CCGraphicsContext> m_context; | 152 OwnPtr<CCGraphicsContext> m_context; |
| 155 OwnPtr<CCResourceProvider> m_resourceProvider; | 153 OwnPtr<CCResourceProvider> m_resourceProvider; |
| 156 CCTextureUpdateQueue m_queue; | 154 CCTextureUpdateQueue m_queue; |
| 157 CCRenderingStats m_stats; | 155 CCRenderingStats m_stats; |
| 158 FakeTextureCopier m_copier; | 156 FakeTextureCopier m_copier; |
| 159 FakeTextureUploader m_uploader; | 157 FakeTextureUploader m_uploader; |
| 160 CCPriorityCalculator m_priorityCalculator; | 158 CCPriorityCalculator m_priorityCalculator; |
| 161 OwnPtr<CCPrioritizedTextureManager> m_textureManager; | 159 OwnPtr<CCPrioritizedTextureManager> m_textureManager; |
| 162 TestCCOcclusionTracker* m_occlusion; | 160 TestCCOcclusionTracker* m_occlusion; |
| 163 }; | 161 }; |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 updateTextures(); | 1545 updateTextures(); |
| 1548 | 1546 |
| 1549 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1547 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
| 1550 layer->setNeedsDisplayRect(layerRect); | 1548 layer->setNeedsDisplayRect(layerRect); |
| 1551 layer->update(m_queue, 0, m_stats); | 1549 layer->update(m_queue, 0, m_stats); |
| 1552 | 1550 |
| 1553 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1551 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1554 } | 1552 } |
| 1555 | 1553 |
| 1556 } // namespace | 1554 } // namespace |
| OLD | NEW |