Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp

Issue 413313002: Treat calls to CanvasRenderingContext2D.clearRect as operations that clear the canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/graphics/RecordingImageBufferSurface.h" 7 #include "platform/graphics/RecordingImageBufferSurface.h"
8 8
9 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/graphics/ImageBuffer.h" 10 #include "platform/graphics/ImageBuffer.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkPictureRecorder.h" 12 #include "third_party/skia/include/core/SkPictureRecorder.h"
12 #include "wtf/OwnPtr.h" 13 #include "wtf/OwnPtr.h"
13 #include "wtf/PassOwnPtr.h" 14 #include "wtf/PassOwnPtr.h"
14 #include "wtf/RefPtr.h" 15 #include "wtf/RefPtr.h"
15 16
16 #include <gmock/gmock.h> 17 #include <gmock/gmock.h>
17 #include <gtest/gtest.h> 18 #include <gtest/gtest.h>
18 19
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 m_testSurface->didClearCanvas(); 74 m_testSurface->didClearCanvas();
74 m_testSurface->willUse(); 75 m_testSurface->willUse();
75 m_testSurface->getPicture(); 76 m_testSurface->getPicture();
76 expectDisplayListEnabled(true); 77 expectDisplayListEnabled(true);
77 // clear after use 78 // clear after use
78 m_testSurface->willUse(); 79 m_testSurface->willUse();
79 m_testSurface->didClearCanvas(); 80 m_testSurface->didClearCanvas();
80 m_testSurface->getPicture(); 81 m_testSurface->getPicture();
81 expectDisplayListEnabled(true); 82 expectDisplayListEnabled(true);
82 } 83 }
84
85 void testClearRect()
86 {
87 m_testSurface->initializeCurrentFrame();
88 m_testSurface->getPicture();
89 m_imageBuffer->context()->clearRect(FloatRect(FloatPoint(0, 0), FloatSiz e(m_testSurface->size())));
90 m_testSurface->willUse();
91 m_testSurface->getPicture();
92 expectDisplayListEnabled(true);
93 }
83 private: 94 private:
84 void expectDisplayListEnabled(bool displayListEnabled) 95 void expectDisplayListEnabled(bool displayListEnabled)
85 { 96 {
86 EXPECT_EQ(displayListEnabled, (bool)m_testSurface->m_currentFrame.get()) ; 97 EXPECT_EQ(displayListEnabled, (bool)m_testSurface->m_currentFrame.get()) ;
87 EXPECT_EQ(!displayListEnabled, (bool)m_testSurface->m_rasterCanvas.get() ); 98 EXPECT_EQ(!displayListEnabled, (bool)m_testSurface->m_rasterCanvas.get() );
88 } 99 }
89 100
90 RecordingImageBufferSurface* m_testSurface; 101 RecordingImageBufferSurface* m_testSurface;
91 OwnPtr<ImageBuffer> m_imageBuffer; 102 OwnPtr<ImageBuffer> m_imageBuffer;
92 }; 103 };
(...skipping 18 matching lines...) Expand all
111 TEST_F(RecordingImageBufferSurfaceTest, testAnimatedWithoutClear) 122 TEST_F(RecordingImageBufferSurfaceTest, testAnimatedWithoutClear)
112 { 123 {
113 testAnimatedWithoutClear(); 124 testAnimatedWithoutClear();
114 } 125 }
115 126
116 TEST_F(RecordingImageBufferSurfaceTest, testAnimatedWithClear) 127 TEST_F(RecordingImageBufferSurfaceTest, testAnimatedWithClear)
117 { 128 {
118 testAnimatedWithClear(); 129 testAnimatedWithClear();
119 } 130 }
120 131
132 TEST_F(RecordingImageBufferSurfaceTest, testClearRect)
133 {
134 testClearRect();
135 }
136
121 } // namespace 137 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698