OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 ++discarded_; | 1023 ++discarded_; |
1024 } | 1024 } |
1025 | 1025 |
1026 int discarded() const { return discarded_; } | 1026 int discarded() const { return discarded_; } |
1027 void reset_discarded() { discarded_ = 0; } | 1027 void reset_discarded() { discarded_ = 0; } |
1028 | 1028 |
1029 private: | 1029 private: |
1030 int discarded_ = 0; | 1030 int discarded_ = 0; |
1031 }; | 1031 }; |
1032 | 1032 |
1033 class NonReshapableOutputSurface : public FakeOutputSurface { | |
1034 public: | |
1035 explicit NonReshapableOutputSurface(std::unique_ptr<TestGLES2Interface> gl) | |
1036 : FakeOutputSurface(TestContextProvider::Create(std::move(gl))) { | |
1037 surface_size_ = gfx::Size(500, 500); | |
1038 } | |
1039 void Reshape(const gfx::Size& size, | |
1040 float scale_factor, | |
1041 const gfx::ColorSpace& color_space, | |
1042 bool has_alpha) override {} | |
1043 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } | |
1044 }; | |
1045 | |
1046 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { | 1033 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { |
1047 auto gl_owned = base::MakeUnique<DiscardCheckingGLES2Interface>(); | 1034 auto gl_owned = base::MakeUnique<DiscardCheckingGLES2Interface>(); |
1048 auto* gl = gl_owned.get(); | 1035 auto* gl = gl_owned.get(); |
1049 | 1036 |
1050 FakeOutputSurfaceClient output_surface_client; | 1037 FakeOutputSurfaceClient output_surface_client; |
1051 std::unique_ptr<NonReshapableOutputSurface> output_surface( | 1038 auto output_surface = FakeOutputSurface::Create3d(std::move(gl_owned)); |
1052 new NonReshapableOutputSurface(std::move(gl_owned))); | |
1053 CHECK(output_surface->BindToClient(&output_surface_client)); | 1039 CHECK(output_surface->BindToClient(&output_surface_client)); |
1054 output_surface->set_fixed_size(gfx::Size(100, 100)); | |
1055 | 1040 |
1056 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 1041 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
1057 new TestSharedBitmapManager()); | 1042 new TestSharedBitmapManager()); |
1058 std::unique_ptr<ResourceProvider> resource_provider = | 1043 std::unique_ptr<ResourceProvider> resource_provider = |
1059 FakeResourceProvider::Create(output_surface->context_provider(), | 1044 FakeResourceProvider::Create(output_surface->context_provider(), |
1060 shared_bitmap_manager.get()); | 1045 shared_bitmap_manager.get()); |
1061 | 1046 |
1062 RendererSettings settings; | 1047 RendererSettings settings; |
1063 settings.partial_swap_enabled = true; | 1048 settings.partial_swap_enabled = true; |
1064 FakeRendererGL renderer(&settings, output_surface.get(), | 1049 FakeRendererGL renderer(&settings, output_surface.get(), |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 MOCK_METHOD3(reshapeWithScaleFactor, | 1448 MOCK_METHOD3(reshapeWithScaleFactor, |
1464 void(int width, int height, float scale_factor)); | 1449 void(int width, int height, float scale_factor)); |
1465 MOCK_METHOD4(drawElements, | 1450 MOCK_METHOD4(drawElements, |
1466 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); | 1451 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
1467 }; | 1452 }; |
1468 | 1453 |
1469 class MockOutputSurface : public OutputSurface { | 1454 class MockOutputSurface : public OutputSurface { |
1470 public: | 1455 public: |
1471 MockOutputSurface() | 1456 MockOutputSurface() |
1472 : OutputSurface(TestContextProvider::Create( | 1457 : OutputSurface(TestContextProvider::Create( |
1473 base::MakeUnique<StrictMock<OutputSurfaceMockContext>>())) { | 1458 base::MakeUnique<StrictMock<OutputSurfaceMockContext>>())) {} |
1474 surface_size_ = gfx::Size(100, 100); | |
1475 } | |
1476 virtual ~MockOutputSurface() {} | 1459 virtual ~MockOutputSurface() {} |
1477 | 1460 |
1478 MOCK_METHOD0(EnsureBackbuffer, void()); | 1461 MOCK_METHOD0(EnsureBackbuffer, void()); |
1479 MOCK_METHOD0(DiscardBackbuffer, void()); | 1462 MOCK_METHOD0(DiscardBackbuffer, void()); |
1480 MOCK_METHOD4(Reshape, | 1463 MOCK_METHOD4(Reshape, |
1481 void(const gfx::Size& size, | 1464 void(const gfx::Size& size, |
1482 float scale_factor, | 1465 float scale_factor, |
1483 const gfx::ColorSpace& color_space, | 1466 const gfx::ColorSpace& color_space, |
1484 bool has_alpha)); | 1467 bool has_alpha)); |
1485 MOCK_METHOD0(BindFramebuffer, void()); | 1468 MOCK_METHOD0(BindFramebuffer, void()); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 renderer_->SetVisible(true); | 1947 renderer_->SetVisible(true); |
1965 Mock::VerifyAndClearExpectations(context_support_ptr_); | 1948 Mock::VerifyAndClearExpectations(context_support_ptr_); |
1966 | 1949 |
1967 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); | 1950 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); |
1968 renderer_->SetVisible(false); | 1951 renderer_->SetVisible(false); |
1969 Mock::VerifyAndClearExpectations(context_support_ptr_); | 1952 Mock::VerifyAndClearExpectations(context_support_ptr_); |
1970 } | 1953 } |
1971 | 1954 |
1972 } // namespace | 1955 } // namespace |
1973 } // namespace cc | 1956 } // namespace cc |
OLD | NEW |