| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/canvas2d/CanvasRenderingContext2D.h" | 5 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 Persistent<MemoryCache> m_globalMemoryCache; | 93 Persistent<MemoryCache> m_globalMemoryCache; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 CanvasRenderingContextUsageTrackingTest::CanvasRenderingContextUsageTrackingTest
() | 96 CanvasRenderingContextUsageTrackingTest::CanvasRenderingContextUsageTrackingTest
() |
| 97 : m_opaqueBitmap(IntSize(10, 10), OpaqueBitmap) | 97 : m_opaqueBitmap(IntSize(10, 10), OpaqueBitmap) |
| 98 , m_alphaBitmap(IntSize(10, 10), TransparentBitmap) | 98 , m_alphaBitmap(IntSize(10, 10), TransparentBitmap) |
| 99 { } | 99 { } |
| 100 | 100 |
| 101 void CanvasRenderingContextUsageTrackingTest::TearDown() | 101 void CanvasRenderingContextUsageTrackingTest::TearDown() |
| 102 { | 102 { |
| 103 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink
GC::GCWithSweep, BlinkGC::ForcedGC); | 103 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw
eep, BlinkGC::ForcedGC); |
| 104 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 104 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 CanvasRenderingContext2D* CanvasRenderingContextUsageTrackingTest::context2d() c
onst | 107 CanvasRenderingContext2D* CanvasRenderingContextUsageTrackingTest::context2d() c
onst |
| 108 { | 108 { |
| 109 // If the following check fails, perhaps you forgot to call createContext | 109 // If the following check fails, perhaps you forgot to call createContext |
| 110 // in your test? | 110 // in your test? |
| 111 EXPECT_NE(nullptr, canvasElement().renderingContext()); | 111 EXPECT_NE(nullptr, canvasElement().renderingContext()); |
| 112 EXPECT_TRUE(canvasElement().renderingContext()->is2d()); | 112 EXPECT_TRUE(canvasElement().renderingContext()->is2d()); |
| 113 return static_cast<CanvasRenderingContext2D*>(canvasElement().renderingConte
xt()); | 113 return static_cast<CanvasRenderingContext2D*>(canvasElement().renderingConte
xt()); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 EXPECT_EQ(0, context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::Fi
llRect]); | 493 EXPECT_EQ(0, context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::Fi
llRect]); |
| 494 | 494 |
| 495 for (int i = 0; i < numReps; i++) { | 495 for (int i = 0; i < numReps; i++) { |
| 496 context2d()->fillRect(10, 10, 100, 100); | 496 context2d()->fillRect(10, 10, 100, 100); |
| 497 } | 497 } |
| 498 EXPECT_EQ(numReps, context2d()->getUsage().numDrawCalls[BaseRenderingContext
2D::FillRect]); | 498 EXPECT_EQ(numReps, context2d()->getUsage().numDrawCalls[BaseRenderingContext
2D::FillRect]); |
| 499 } | 499 } |
| 500 | 500 |
| 501 } // namespace UsageTrackingTests | 501 } // namespace UsageTrackingTests |
| 502 } // namespace blink | 502 } // namespace blink |
| OLD | NEW |