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

Side by Side Diff: cc/texture_copier_unittest.cc

Issue 11368152: Disable scissor test during texture copies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « cc/texture_copier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/texture_copier.h" 7 #include "cc/texture_copier.h"
8 8
9 #include "cc/test/fake_web_graphics_context_3d.h" 9 #include "cc/test/fake_web_graphics_context_3d.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/khronos/GLES2/gl2.h" 12 #include "third_party/khronos/GLES2/gl2.h"
13 13
14 using namespace cc; 14 using namespace cc;
15 using namespace WebKit; 15 using namespace WebKit;
16 using testing::InSequence; 16 using testing::InSequence;
17 using testing::Test; 17 using testing::Test;
18 using testing::_; 18 using testing::_;
19 19
20 namespace { 20 namespace {
21 21
22 class MockContext : public FakeWebGraphicsContext3D { 22 class MockContext : public FakeWebGraphicsContext3D {
23 public: 23 public:
24 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum, WebGLId)); 24 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum, WebGLId));
25 MOCK_METHOD3(texParameteri, void(WGC3Denum target, WGC3Denum pname, WGC3Dint param)); 25 MOCK_METHOD3(texParameteri, void(WGC3Denum target, WGC3Denum pname, WGC3Dint param));
26 MOCK_METHOD1(disable, void(WGC3Denum cap));
27 MOCK_METHOD1(enable, void(WGC3Denum cap));
26 28
27 MOCK_METHOD3(drawArrays, void(WGC3Denum mode, WGC3Dint first, WGC3Dsizei cou nt)); 29 MOCK_METHOD3(drawArrays, void(WGC3Denum mode, WGC3Dint first, WGC3Dsizei cou nt));
28 }; 30 };
29 31
30 TEST(TextureCopierTest, testDrawArraysCopy) 32 TEST(TextureCopierTest, testDrawArraysCopy)
31 { 33 {
32 scoped_ptr<MockContext> mockContext(new MockContext); 34 scoped_ptr<MockContext> mockContext(new MockContext);
33 35
34 { 36 {
35 InSequence sequence; 37 InSequence sequence;
36 38
39 EXPECT_CALL(*mockContext, disable(GL_SCISSOR_TEST));
40
37 // Here we check just some essential properties of copyTexture() to avoi d mirroring the full implementation. 41 // Here we check just some essential properties of copyTexture() to avoi d mirroring the full implementation.
38 EXPECT_CALL(*mockContext, bindFramebuffer(GL_FRAMEBUFFER, _)); 42 EXPECT_CALL(*mockContext, bindFramebuffer(GL_FRAMEBUFFER, _));
39 43
40 // Make sure linear filtering is disabled during the copy. 44 // Make sure linear filtering is disabled during the copy.
41 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FI LTER, GL_NEAREST)); 45 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FI LTER, GL_NEAREST));
42 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FI LTER, GL_NEAREST)); 46 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FI LTER, GL_NEAREST));
43 47
48 EXPECT_CALL(*mockContext, disable(GL_BLEND));
49
44 EXPECT_CALL(*mockContext, drawArrays(_, _, _)); 50 EXPECT_CALL(*mockContext, drawArrays(_, _, _));
45 51
46 // Linear filtering should be restored. 52 // Linear filtering, default framebuffer and scissor test should be rest ored.
47 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FI LTER, GL_LINEAR)); 53 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FI LTER, GL_LINEAR));
48 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FI LTER, GL_LINEAR)); 54 EXPECT_CALL(*mockContext, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FI LTER, GL_LINEAR));
49
50 // Default framebuffer should be restored
51 EXPECT_CALL(*mockContext, bindFramebuffer(GL_FRAMEBUFFER, 0)); 55 EXPECT_CALL(*mockContext, bindFramebuffer(GL_FRAMEBUFFER, 0));
56 EXPECT_CALL(*mockContext, enable(GL_SCISSOR_TEST));
52 } 57 }
53 58
54 int sourceTextureId = 1; 59 int sourceTextureId = 1;
55 int destTextureId = 2; 60 int destTextureId = 2;
56 gfx::Size size(256, 128); 61 gfx::Size size(256, 128);
57 scoped_ptr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create (mockContext.get(), false)); 62 scoped_ptr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create (mockContext.get(), false));
58 TextureCopier::Parameters copy = { sourceTextureId, destTextureId, size }; 63 TextureCopier::Parameters copy = { sourceTextureId, destTextureId, size };
59 copier->copyTexture(copy); 64 copier->copyTexture(copy);
60 } 65 }
61 66
62 } // anonymous namespace 67 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/texture_copier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698