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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "cc/video_layer_impl.h" | 38 #include "cc/video_layer_impl.h" |
39 #include "media/base/media.h" | 39 #include "media/base/media.h" |
40 #include "media/base/video_frame.h" | 40 #include "media/base/video_frame.h" |
41 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
42 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
43 #include "ui/gfx/size_conversions.h" | 43 #include "ui/gfx/size_conversions.h" |
44 #include "ui/gfx/vector2d_conversions.h" | 44 #include "ui/gfx/vector2d_conversions.h" |
45 #include <public/WebVideoFrame.h> | 45 #include <public/WebVideoFrame.h> |
46 #include <public/WebVideoFrameProvider.h> | 46 #include <public/WebVideoFrameProvider.h> |
47 | 47 |
48 using namespace LayerTestCommon; | |
49 using namespace WebKit; | |
50 using namespace WebKitTests; | |
51 | |
52 using media::VideoFrame; | 48 using media::VideoFrame; |
53 using ::testing::Mock; | 49 using ::testing::Mock; |
54 using ::testing::Return; | 50 using ::testing::Return; |
55 using ::testing::AnyNumber; | 51 using ::testing::AnyNumber; |
56 using ::testing::AtLeast; | 52 using ::testing::AtLeast; |
57 using ::testing::_; | 53 using ::testing::_; |
58 | 54 |
59 namespace cc { | 55 namespace cc { |
60 namespace { | 56 namespace { |
61 | 57 |
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 | 1602 |
1607 // The scale should not have been applied to the scroll delta. | 1603 // The scale should not have been applied to the scroll delta. |
1608 scrollInfo = m_hostImpl->processScrollDeltas(); | 1604 scrollInfo = m_hostImpl->processScrollDeltas(); |
1609 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1605 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1610 } | 1606 } |
1611 | 1607 |
1612 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { | 1608 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { |
1613 public: | 1609 public: |
1614 BlendStateTrackerContext() : m_blend(false) { } | 1610 BlendStateTrackerContext() : m_blend(false) { } |
1615 | 1611 |
1616 virtual void enable(WGC3Denum cap) | 1612 virtual void enable(WebKit::WGC3Denum cap) |
1617 { | 1613 { |
1618 if (cap == GL_BLEND) | 1614 if (cap == GL_BLEND) |
1619 m_blend = true; | 1615 m_blend = true; |
1620 } | 1616 } |
1621 | 1617 |
1622 virtual void disable(WGC3Denum cap) | 1618 virtual void disable(WebKit::WGC3Denum cap) |
1623 { | 1619 { |
1624 if (cap == GL_BLEND) | 1620 if (cap == GL_BLEND) |
1625 m_blend = false; | 1621 m_blend = false; |
1626 } | 1622 } |
1627 | 1623 |
1628 bool blend() const { return m_blend; } | 1624 bool blend() const { return m_blend; } |
1629 | 1625 |
1630 private: | 1626 private: |
1631 bool m_blend; | 1627 bool m_blend; |
1632 }; | 1628 }; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 LayerTreeHostImpl::FrameData frame; | 1906 LayerTreeHostImpl::FrameData frame; |
1911 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1907 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1912 ASSERT_EQ(1u, frame.renderPasses.size()); | 1908 ASSERT_EQ(1u, frame.renderPasses.size()); |
1913 | 1909 |
1914 size_t numGutterQuads = 0; | 1910 size_t numGutterQuads = 0; |
1915 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1911 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1916 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 1912 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
1917 EXPECT_EQ(0u, numGutterQuads); | 1913 EXPECT_EQ(0u, numGutterQuads); |
1918 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 1914 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
1919 | 1915 |
1920 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); | 1916 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); |
1921 m_hostImpl->didDrawAllLayers(frame); | 1917 m_hostImpl->didDrawAllLayers(frame); |
1922 } | 1918 } |
1923 | 1919 |
1924 // Empty visible content area (fullscreen gutter rect) | 1920 // Empty visible content area (fullscreen gutter rect) |
1925 { | 1921 { |
1926 gfx::Rect layerRect(0, 0, 0, 0); | 1922 gfx::Rect layerRect(0, 0, 0, 0); |
1927 child->setPosition(layerRect.origin()); | 1923 child->setPosition(layerRect.origin()); |
1928 child->setBounds(layerRect.size()); | 1924 child->setBounds(layerRect.size()); |
1929 child->setContentBounds(layerRect.size()); | 1925 child->setContentBounds(layerRect.size()); |
1930 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1926 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1931 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1927 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1932 | 1928 |
1933 LayerTreeHostImpl::FrameData frame; | 1929 LayerTreeHostImpl::FrameData frame; |
1934 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1930 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1935 ASSERT_EQ(1u, frame.renderPasses.size()); | 1931 ASSERT_EQ(1u, frame.renderPasses.size()); |
1936 | 1932 |
1937 size_t numGutterQuads = 0; | 1933 size_t numGutterQuads = 0; |
1938 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1934 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1939 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 1935 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
1940 EXPECT_EQ(1u, numGutterQuads); | 1936 EXPECT_EQ(1u, numGutterQuads); |
1941 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 1937 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
1942 | 1938 |
1943 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); | 1939 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); |
1944 m_hostImpl->didDrawAllLayers(frame); | 1940 m_hostImpl->didDrawAllLayers(frame); |
1945 } | 1941 } |
1946 | 1942 |
1947 // Content area in middle of clip rect (four surrounding gutter rects) | 1943 // Content area in middle of clip rect (four surrounding gutter rects) |
1948 { | 1944 { |
1949 gfx::Rect layerRect(500, 500, 200, 200); | 1945 gfx::Rect layerRect(500, 500, 200, 200); |
1950 child->setPosition(layerRect.origin()); | 1946 child->setPosition(layerRect.origin()); |
1951 child->setBounds(layerRect.size()); | 1947 child->setBounds(layerRect.size()); |
1952 child->setContentBounds(layerRect.size()); | 1948 child->setContentBounds(layerRect.size()); |
1953 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1949 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1954 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1950 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1955 | 1951 |
1956 LayerTreeHostImpl::FrameData frame; | 1952 LayerTreeHostImpl::FrameData frame; |
1957 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1953 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1958 ASSERT_EQ(1u, frame.renderPasses.size()); | 1954 ASSERT_EQ(1u, frame.renderPasses.size()); |
1959 | 1955 |
1960 size_t numGutterQuads = 0; | 1956 size_t numGutterQuads = 0; |
1961 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1957 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1962 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 1958 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
1963 EXPECT_EQ(4u, numGutterQuads); | 1959 EXPECT_EQ(4u, numGutterQuads); |
1964 EXPECT_EQ(5u, frame.renderPasses[0]->quad_list.size()); | 1960 EXPECT_EQ(5u, frame.renderPasses[0]->quad_list.size()); |
1965 | 1961 |
1966 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); | 1962 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); |
1967 m_hostImpl->didDrawAllLayers(frame); | 1963 m_hostImpl->didDrawAllLayers(frame); |
1968 } | 1964 } |
1969 | 1965 |
1970 } | 1966 } |
1971 | 1967 |
1972 | 1968 |
1973 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { | 1969 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { |
1974 public: | 1970 public: |
1975 ReshapeTrackerContext() : m_reshapeCalled(false) { } | 1971 ReshapeTrackerContext() : m_reshapeCalled(false) { } |
1976 | 1972 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 m_hostImpl->didDrawAllLayers(frame); | 2011 m_hostImpl->didDrawAllLayers(frame); |
2016 } | 2012 } |
2017 | 2013 |
2018 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { | 2014 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { |
2019 public: | 2015 public: |
2020 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) | 2016 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) |
2021 { | 2017 { |
2022 m_partialSwapRect = gfx::Rect(x, y, width, height); | 2018 m_partialSwapRect = gfx::Rect(x, y, width, height); |
2023 } | 2019 } |
2024 | 2020 |
2025 virtual WebString getString(WGC3Denum name) | 2021 virtual WebKit::WebString getString(WebKit::WGC3Denum name) |
2026 { | 2022 { |
2027 if (name == GL_EXTENSIONS) | 2023 if (name == GL_EXTENSIONS) |
2028 return WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibi
lity"); | 2024 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_se
t_visibility"); |
2029 | 2025 |
2030 return WebString(); | 2026 return WebKit::WebString(); |
2031 } | 2027 } |
2032 | 2028 |
2033 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } | 2029 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } |
2034 | 2030 |
2035 private: | 2031 private: |
2036 gfx::Rect m_partialSwapRect; | 2032 gfx::Rect m_partialSwapRect; |
2037 }; | 2033 }; |
2038 | 2034 |
2039 // Make sure damage tracking propagates all the way to the graphics context, | 2035 // Make sure damage tracking propagates all the way to the graphics context, |
2040 // where it should request to swap only the subBuffer that is damaged. | 2036 // where it should request to swap only the subBuffer that is damaged. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 m_hostImpl->setRootLayer(root.Pass()); | 2126 m_hostImpl->setRootLayer(root.Pass()); |
2131 | 2127 |
2132 LayerTreeHostImpl::FrameData frame; | 2128 LayerTreeHostImpl::FrameData frame; |
2133 | 2129 |
2134 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2130 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2135 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2131 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
2136 EXPECT_EQ(1u, frame.renderPasses.size()); | 2132 EXPECT_EQ(1u, frame.renderPasses.size()); |
2137 m_hostImpl->didDrawAllLayers(frame); | 2133 m_hostImpl->didDrawAllLayers(frame); |
2138 } | 2134 } |
2139 | 2135 |
2140 } // namespace | |
2141 | |
2142 class FakeLayerWithQuads : public LayerImpl { | 2136 class FakeLayerWithQuads : public LayerImpl { |
2143 public: | 2137 public: |
2144 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeLayerWithQuads(treeImpl, id)); } | 2138 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeLayerWithQuads(treeImpl, id)); } |
2145 | 2139 |
2146 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 2140 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE |
2147 { | 2141 { |
2148 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); | 2142 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); |
2149 | 2143 |
2150 SkColor gray = SkColorSetRGB(100, 100, 100); | 2144 SkColor gray = SkColorSetRGB(100, 100, 100); |
2151 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds()); | 2145 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds()); |
2152 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::Create(); | 2146 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::Create(); |
2153 myQuad->SetNew(sharedQuadState, quadRect, gray); | 2147 myQuad->SetNew(sharedQuadState, quadRect, gray); |
2154 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); | 2148 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); |
2155 } | 2149 } |
2156 | 2150 |
2157 private: | 2151 private: |
2158 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id) | 2152 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id) |
2159 : LayerImpl(treeImpl, id) | 2153 : LayerImpl(treeImpl, id) |
2160 { | 2154 { |
2161 } | 2155 } |
2162 }; | 2156 }; |
2163 | 2157 |
2164 namespace { | |
2165 | |
2166 class MockContext : public FakeWebGraphicsContext3D { | 2158 class MockContext : public FakeWebGraphicsContext3D { |
2167 public: | 2159 public: |
2168 MOCK_METHOD1(useProgram, void(WebGLId program)); | 2160 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); |
2169 MOCK_METHOD5(uniform4f, void(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y,
WGC3Dfloat z, WGC3Dfloat w)); | 2161 MOCK_METHOD5(uniform4f, void(WebKit::WGC3Dint location, WebKit::WGC3Dfloat x
, WebKit::WGC3Dfloat y, WebKit::WGC3Dfloat z, WebKit::WGC3Dfloat w)); |
2170 MOCK_METHOD4(uniformMatrix4fv, void(WGC3Dint location, WGC3Dsizei count, WGC
3Dboolean transpose, const WGC3Dfloat* value)); | 2162 MOCK_METHOD4(uniformMatrix4fv, void(WebKit::WGC3Dint location, WebKit::WGC3D
sizei count, WebKit::WGC3Dboolean transpose, const WebKit::WGC3Dfloat* value)); |
2171 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 2163 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); |
2172 MOCK_METHOD1(getString, WebString(WGC3Denum name)); | 2164 MOCK_METHOD1(getString, WebKit::WebString(WebKit::WGC3Denum name)); |
2173 MOCK_METHOD0(getRequestableExtensionsCHROMIUM, WebString()); | 2165 MOCK_METHOD0(getRequestableExtensionsCHROMIUM, WebKit::WebString()); |
2174 MOCK_METHOD1(enable, void(WGC3Denum cap)); | 2166 MOCK_METHOD1(enable, void(WebKit::WGC3Denum cap)); |
2175 MOCK_METHOD1(disable, void(WGC3Denum cap)); | 2167 MOCK_METHOD1(disable, void(WebKit::WGC3Denum cap)); |
2176 MOCK_METHOD4(scissor, void(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsi
zei height)); | 2168 MOCK_METHOD4(scissor, void(WebKit::WGC3Dint x, WebKit::WGC3Dint y, WebKit::W
GC3Dsizei width, WebKit::WGC3Dsizei height)); |
2177 }; | 2169 }; |
2178 | 2170 |
2179 class MockContextHarness { | 2171 class MockContextHarness { |
2180 private: | 2172 private: |
2181 MockContext* m_context; | 2173 MockContext* m_context; |
2182 public: | 2174 public: |
2183 MockContextHarness(MockContext* context) | 2175 MockContextHarness(MockContext* context) |
2184 : m_context(context) | 2176 : m_context(context) |
2185 { | 2177 { |
2186 // Catch "uninteresting" calls | 2178 // Catch "uninteresting" calls |
2187 EXPECT_CALL(*m_context, useProgram(_)) | 2179 EXPECT_CALL(*m_context, useProgram(_)) |
2188 .Times(0); | 2180 .Times(0); |
2189 | 2181 |
2190 EXPECT_CALL(*m_context, drawElements(_, _, _, _)) | 2182 EXPECT_CALL(*m_context, drawElements(_, _, _, _)) |
2191 .Times(0); | 2183 .Times(0); |
2192 | 2184 |
2193 // These are not asserted | 2185 // These are not asserted |
2194 EXPECT_CALL(*m_context, uniformMatrix4fv(_, _, _, _)) | 2186 EXPECT_CALL(*m_context, uniformMatrix4fv(_, _, _, _)) |
2195 .WillRepeatedly(Return()); | 2187 .WillRepeatedly(Return()); |
2196 | 2188 |
2197 EXPECT_CALL(*m_context, uniform4f(_, _, _, _, _)) | 2189 EXPECT_CALL(*m_context, uniform4f(_, _, _, _, _)) |
2198 .WillRepeatedly(Return()); | 2190 .WillRepeatedly(Return()); |
2199 | 2191 |
2200 // Any other strings are empty | 2192 // Any other strings are empty |
2201 EXPECT_CALL(*m_context, getString(_)) | 2193 EXPECT_CALL(*m_context, getString(_)) |
2202 .WillRepeatedly(Return(WebString())); | 2194 .WillRepeatedly(Return(WebKit::WebString())); |
2203 | 2195 |
2204 // Support for partial swap, if needed | 2196 // Support for partial swap, if needed |
2205 EXPECT_CALL(*m_context, getString(GL_EXTENSIONS)) | 2197 EXPECT_CALL(*m_context, getString(GL_EXTENSIONS)) |
2206 .WillRepeatedly(Return(WebString("GL_CHROMIUM_post_sub_buffer"))); | 2198 .WillRepeatedly(Return(WebKit::WebString("GL_CHROMIUM_post_sub_buffe
r"))); |
2207 | 2199 |
2208 EXPECT_CALL(*m_context, getRequestableExtensionsCHROMIUM()) | 2200 EXPECT_CALL(*m_context, getRequestableExtensionsCHROMIUM()) |
2209 .WillRepeatedly(Return(WebString("GL_CHROMIUM_post_sub_buffer"))); | 2201 .WillRepeatedly(Return(WebKit::WebString("GL_CHROMIUM_post_sub_buffe
r"))); |
2210 | 2202 |
2211 // Any un-sanctioned calls to enable() are OK | 2203 // Any un-sanctioned calls to enable() are OK |
2212 EXPECT_CALL(*m_context, enable(_)) | 2204 EXPECT_CALL(*m_context, enable(_)) |
2213 .WillRepeatedly(Return()); | 2205 .WillRepeatedly(Return()); |
2214 | 2206 |
2215 // Any un-sanctioned calls to disable() are OK | 2207 // Any un-sanctioned calls to disable() are OK |
2216 EXPECT_CALL(*m_context, disable(_)) | 2208 EXPECT_CALL(*m_context, disable(_)) |
2217 .WillRepeatedly(Return()); | 2209 .WillRepeatedly(Return()); |
2218 } | 2210 } |
2219 | 2211 |
(...skipping 28 matching lines...) Expand all Loading... |
2248 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) | 2240 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) |
2249 .Times(0); | 2241 .Times(0); |
2250 | 2242 |
2251 EXPECT_CALL(*m_context, scissor(_, _, _, _)) | 2243 EXPECT_CALL(*m_context, scissor(_, _, _, _)) |
2252 .Times(0); | 2244 .Times(0); |
2253 } | 2245 } |
2254 }; | 2246 }; |
2255 | 2247 |
2256 TEST_P(LayerTreeHostImplTest, noPartialSwap) | 2248 TEST_P(LayerTreeHostImplTest, noPartialSwap) |
2257 { | 2249 { |
2258 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2250 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
2259 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); | 2251 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); |
2260 MockContextHarness harness(mockContext); | 2252 MockContextHarness harness(mockContext); |
2261 | 2253 |
2262 // Run test case | 2254 // Run test case |
2263 createLayerTreeHost(false, outputSurface.Pass()); | 2255 createLayerTreeHost(false, outputSurface.Pass()); |
2264 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); | 2256 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); |
2265 | 2257 |
2266 // without partial swap, and no clipping, no scissor is set. | 2258 // without partial swap, and no clipping, no scissor is set. |
2267 harness.mustDrawSolidQuad(); | 2259 harness.mustDrawSolidQuad(); |
2268 harness.mustSetNoScissor(); | 2260 harness.mustSetNoScissor(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 LayerTreeHostImpl::FrameData frame; | 2309 LayerTreeHostImpl::FrameData frame; |
2318 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2310 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2319 m_hostImpl->drawLayers(frame); | 2311 m_hostImpl->drawLayers(frame); |
2320 m_hostImpl->didDrawAllLayers(frame); | 2312 m_hostImpl->didDrawAllLayers(frame); |
2321 } | 2313 } |
2322 Mock::VerifyAndClearExpectations(&mockContext); | 2314 Mock::VerifyAndClearExpectations(&mockContext); |
2323 } | 2315 } |
2324 | 2316 |
2325 class PartialSwapContext : public FakeWebGraphicsContext3D { | 2317 class PartialSwapContext : public FakeWebGraphicsContext3D { |
2326 public: | 2318 public: |
2327 WebString getString(WGC3Denum name) | 2319 WebKit::WebString getString(WebKit::WGC3Denum name) |
2328 { | 2320 { |
2329 if (name == GL_EXTENSIONS) | 2321 if (name == GL_EXTENSIONS) |
2330 return WebString("GL_CHROMIUM_post_sub_buffer"); | 2322 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer"); |
2331 return WebString(); | 2323 return WebKit::WebString(); |
2332 } | 2324 } |
2333 | 2325 |
2334 WebString getRequestableExtensionsCHROMIUM() | 2326 WebKit::WebString getRequestableExtensionsCHROMIUM() |
2335 { | 2327 { |
2336 return WebString("GL_CHROMIUM_post_sub_buffer"); | 2328 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer"); |
2337 } | 2329 } |
2338 | 2330 |
2339 // Unlimited texture size. | 2331 // Unlimited texture size. |
2340 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) | 2332 virtual void getIntegerv(WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) |
2341 { | 2333 { |
2342 if (pname == GL_MAX_TEXTURE_SIZE) | 2334 if (pname == GL_MAX_TEXTURE_SIZE) |
2343 *value = 8192; | 2335 *value = 8192; |
2344 } | 2336 } |
2345 }; | 2337 }; |
2346 | 2338 |
2347 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) | 2339 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) |
2348 { | 2340 { |
2349 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 2341 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
2350 | 2342 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2546 EXPECT_EQ(0, m_hostImpl->resourceProvider()); | 2538 EXPECT_EQ(0, m_hostImpl->resourceProvider()); |
2547 EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface())); | 2539 EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface())); |
2548 } | 2540 } |
2549 | 2541 |
2550 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scope
d_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails
Eventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<Outp
utSurface>())); | 2542 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scope
d_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails
Eventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<Outp
utSurface>())); |
2551 EXPECT_TRUE(m_hostImpl->outputSurface()); | 2543 EXPECT_TRUE(m_hostImpl->outputSurface()); |
2552 EXPECT_TRUE(m_hostImpl->renderer()); | 2544 EXPECT_TRUE(m_hostImpl->renderer()); |
2553 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2545 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
2554 } | 2546 } |
2555 | 2547 |
2556 // Fake WebGraphicsContext3D that will cause a failure if trying to use a | 2548 // Fake WebKit::WebGraphicsContext3D that will cause a failure if trying to use
a |
2557 // resource that wasn't created by it (resources created by | 2549 // resource that wasn't created by it (resources created by |
2558 // FakeWebGraphicsContext3D have an id of 1). | 2550 // FakeWebGraphicsContext3D have an id of 1). |
2559 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 2551 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
2560 public: | 2552 public: |
2561 StrictWebGraphicsContext3D() | 2553 StrictWebGraphicsContext3D() |
2562 : FakeWebGraphicsContext3D() | 2554 : FakeWebGraphicsContext3D() |
2563 { | 2555 { |
2564 m_nextTextureId = 8; // Start allocating texture ids larger than any oth
er resource IDs so we can tell if someone's mixing up their resource types. | 2556 m_nextTextureId = 8; // Start allocating texture ids larger than any oth
er resource IDs so we can tell if someone's mixing up their resource types. |
2565 } | 2557 } |
2566 | 2558 |
2567 virtual WebGLId createBuffer() { return 2; } | 2559 virtual WebKit::WebGLId createBuffer() { return 2; } |
2568 virtual WebGLId createFramebuffer() { return 3; } | 2560 virtual WebKit::WebGLId createFramebuffer() { return 3; } |
2569 virtual WebGLId createProgram() { return 4; } | 2561 virtual WebKit::WebGLId createProgram() { return 4; } |
2570 virtual WebGLId createRenderbuffer() { return 5; } | 2562 virtual WebKit::WebGLId createRenderbuffer() { return 5; } |
2571 virtual WebGLId createShader(WGC3Denum) { return 6; } | 2563 virtual WebKit::WebGLId createShader(WebKit::WGC3Denum) { return 6; } |
2572 | 2564 |
2573 static const WebGLId kExternalTextureId = 7; | 2565 static const WebKit::WebGLId kExternalTextureId = 7; |
2574 | 2566 |
2575 virtual void deleteBuffer(WebGLId id) | 2567 virtual void deleteBuffer(WebKit::WebGLId id) |
2576 { | 2568 { |
2577 if (id != 2) | 2569 if (id != 2) |
2578 ADD_FAILURE() << "Trying to delete buffer id " << id; | 2570 ADD_FAILURE() << "Trying to delete buffer id " << id; |
2579 } | 2571 } |
2580 | 2572 |
2581 virtual void deleteFramebuffer(WebGLId id) | 2573 virtual void deleteFramebuffer(WebKit::WebGLId id) |
2582 { | 2574 { |
2583 if (id != 3) | 2575 if (id != 3) |
2584 ADD_FAILURE() << "Trying to delete framebuffer id " << id; | 2576 ADD_FAILURE() << "Trying to delete framebuffer id " << id; |
2585 } | 2577 } |
2586 | 2578 |
2587 virtual void deleteProgram(WebGLId id) | 2579 virtual void deleteProgram(WebKit::WebGLId id) |
2588 { | 2580 { |
2589 if (id != 4) | 2581 if (id != 4) |
2590 ADD_FAILURE() << "Trying to delete program id " << id; | 2582 ADD_FAILURE() << "Trying to delete program id " << id; |
2591 } | 2583 } |
2592 | 2584 |
2593 virtual void deleteRenderbuffer(WebGLId id) | 2585 virtual void deleteRenderbuffer(WebKit::WebGLId id) |
2594 { | 2586 { |
2595 if (id != 5) | 2587 if (id != 5) |
2596 ADD_FAILURE() << "Trying to delete renderbuffer id " << id; | 2588 ADD_FAILURE() << "Trying to delete renderbuffer id " << id; |
2597 } | 2589 } |
2598 | 2590 |
2599 virtual void deleteShader(WebGLId id) | 2591 virtual void deleteShader(WebKit::WebGLId id) |
2600 { | 2592 { |
2601 if (id != 6) | 2593 if (id != 6) |
2602 ADD_FAILURE() << "Trying to delete shader id " << id; | 2594 ADD_FAILURE() << "Trying to delete shader id " << id; |
2603 } | 2595 } |
2604 | 2596 |
2605 virtual WebGLId createTexture() | 2597 virtual WebKit::WebGLId createTexture() |
2606 { | 2598 { |
2607 unsigned textureId = FakeWebGraphicsContext3D::createTexture(); | 2599 unsigned textureId = FakeWebGraphicsContext3D::createTexture(); |
2608 m_allocatedTextureIds.insert(textureId); | 2600 m_allocatedTextureIds.insert(textureId); |
2609 return textureId; | 2601 return textureId; |
2610 } | 2602 } |
2611 virtual void deleteTexture(WebGLId id) | 2603 virtual void deleteTexture(WebKit::WebGLId id) |
2612 { | 2604 { |
2613 if (id == kExternalTextureId) | 2605 if (id == kExternalTextureId) |
2614 ADD_FAILURE() << "Trying to delete external texture"; | 2606 ADD_FAILURE() << "Trying to delete external texture"; |
2615 if (!ContainsKey(m_allocatedTextureIds, id)) | 2607 if (!ContainsKey(m_allocatedTextureIds, id)) |
2616 ADD_FAILURE() << "Trying to delete texture id " << id; | 2608 ADD_FAILURE() << "Trying to delete texture id " << id; |
2617 m_allocatedTextureIds.erase(id); | 2609 m_allocatedTextureIds.erase(id); |
2618 } | 2610 } |
2619 | 2611 |
2620 virtual void bindBuffer(WGC3Denum, WebGLId id) | 2612 virtual void bindBuffer(WebKit::WGC3Denum, WebKit::WebGLId id) |
2621 { | 2613 { |
2622 if (id != 2 && id) | 2614 if (id != 2 && id) |
2623 ADD_FAILURE() << "Trying to bind buffer id " << id; | 2615 ADD_FAILURE() << "Trying to bind buffer id " << id; |
2624 } | 2616 } |
2625 | 2617 |
2626 virtual void bindFramebuffer(WGC3Denum, WebGLId id) | 2618 virtual void bindFramebuffer(WebKit::WGC3Denum, WebKit::WebGLId id) |
2627 { | 2619 { |
2628 if (id != 3 && id) | 2620 if (id != 3 && id) |
2629 ADD_FAILURE() << "Trying to bind framebuffer id " << id; | 2621 ADD_FAILURE() << "Trying to bind framebuffer id " << id; |
2630 } | 2622 } |
2631 | 2623 |
2632 virtual void useProgram(WebGLId id) | 2624 virtual void useProgram(WebKit::WebGLId id) |
2633 { | 2625 { |
2634 if (id != 4) | 2626 if (id != 4) |
2635 ADD_FAILURE() << "Trying to use program id " << id; | 2627 ADD_FAILURE() << "Trying to use program id " << id; |
2636 } | 2628 } |
2637 | 2629 |
2638 virtual void bindRenderbuffer(WGC3Denum, WebGLId id) | 2630 virtual void bindRenderbuffer(WebKit::WGC3Denum, WebKit::WebGLId id) |
2639 { | 2631 { |
2640 if (id != 5 && id) | 2632 if (id != 5 && id) |
2641 ADD_FAILURE() << "Trying to bind renderbuffer id " << id; | 2633 ADD_FAILURE() << "Trying to bind renderbuffer id " << id; |
2642 } | 2634 } |
2643 | 2635 |
2644 virtual void attachShader(WebGLId program, WebGLId shader) | 2636 virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader) |
2645 { | 2637 { |
2646 if ((program != 4) || (shader != 6)) | 2638 if ((program != 4) || (shader != 6)) |
2647 ADD_FAILURE() << "Trying to attach shader id " << shader << " to pro
gram id " << program; | 2639 ADD_FAILURE() << "Trying to attach shader id " << shader << " to pro
gram id " << program; |
2648 } | 2640 } |
2649 | 2641 |
2650 virtual void bindTexture(WGC3Denum, WebGLId id) | 2642 virtual void bindTexture(WebKit::WGC3Denum, WebKit::WebGLId id) |
2651 { | 2643 { |
2652 if (id && id != kExternalTextureId && !ContainsKey(m_allocatedTextureIds
, id)) | 2644 if (id && id != kExternalTextureId && !ContainsKey(m_allocatedTextureIds
, id)) |
2653 ADD_FAILURE() << "Trying to bind texture id " << id; | 2645 ADD_FAILURE() << "Trying to bind texture id " << id; |
2654 } | 2646 } |
2655 | 2647 |
2656 private: | 2648 private: |
2657 base::hash_set<unsigned> m_allocatedTextureIds; | 2649 base::hash_set<unsigned> m_allocatedTextureIds; |
2658 }; | 2650 }; |
2659 | 2651 |
2660 // Fake WebVideoFrame wrapper of media::VideoFrame. | 2652 // Fake WebKit::WebVideoFrame wrapper of media::VideoFrame. |
2661 class FakeVideoFrame: public WebVideoFrame { | 2653 class FakeVideoFrame: public WebKit::WebVideoFrame { |
2662 public: | 2654 public: |
2663 explicit FakeVideoFrame(const scoped_refptr<VideoFrame>& frame) : m_frame(fr
ame) { } | 2655 explicit FakeVideoFrame(const scoped_refptr<VideoFrame>& frame) : m_frame(fr
ame) { } |
2664 virtual ~FakeVideoFrame() { } | 2656 virtual ~FakeVideoFrame() { } |
2665 | 2657 |
2666 virtual Format format() const { NOTREACHED(); return FormatInvalid; } | 2658 virtual Format format() const { NOTREACHED(); return FormatInvalid; } |
2667 virtual unsigned width() const { NOTREACHED(); return 0; } | 2659 virtual unsigned width() const { NOTREACHED(); return 0; } |
2668 virtual unsigned height() const { NOTREACHED(); return 0; } | 2660 virtual unsigned height() const { NOTREACHED(); return 0; } |
2669 virtual unsigned planes() const { NOTREACHED(); return 0; } | 2661 virtual unsigned planes() const { NOTREACHED(); return 0; } |
2670 virtual int stride(unsigned plane) const { NOTREACHED(); return 0; } | 2662 virtual int stride(unsigned plane) const { NOTREACHED(); return 0; } |
2671 virtual const void* data(unsigned plane) const { NOTREACHED(); return NULL;
} | 2663 virtual const void* data(unsigned plane) const { NOTREACHED(); return NULL;
} |
2672 virtual unsigned textureId() const { NOTREACHED(); return 0; } | 2664 virtual unsigned textureId() const { NOTREACHED(); return 0; } |
2673 virtual unsigned textureTarget() const { NOTREACHED(); return 0; } | 2665 virtual unsigned textureTarget() const { NOTREACHED(); return 0; } |
2674 virtual WebKit::WebRect visibleRect() const { NOTREACHED(); return WebKit::W
ebRect(0, 0, 0, 0); } | 2666 virtual WebKit::WebRect visibleRect() const { NOTREACHED(); return WebKit::W
ebRect(0, 0, 0, 0); } |
2675 virtual WebKit::WebSize textureSize() const { NOTREACHED(); return WebKit::W
ebSize(4, 4); } | 2667 virtual WebKit::WebSize textureSize() const { NOTREACHED(); return WebKit::W
ebSize(4, 4); } |
2676 | 2668 |
2677 static VideoFrame* toVideoFrame(WebVideoFrame* web_video_frame) { | 2669 static VideoFrame* toVideoFrame(WebKit::WebVideoFrame* web_video_frame) { |
2678 FakeVideoFrame* wrapped_frame = | 2670 FakeVideoFrame* wrapped_frame = |
2679 static_cast<FakeVideoFrame*>(web_video_frame); | 2671 static_cast<FakeVideoFrame*>(web_video_frame); |
2680 if (wrapped_frame) | 2672 if (wrapped_frame) |
2681 return wrapped_frame->m_frame.get(); | 2673 return wrapped_frame->m_frame.get(); |
2682 return NULL; | 2674 return NULL; |
2683 } | 2675 } |
2684 | 2676 |
2685 private: | 2677 private: |
2686 scoped_refptr<VideoFrame> m_frame; | 2678 scoped_refptr<VideoFrame> m_frame; |
2687 }; | 2679 }; |
2688 | 2680 |
2689 // Fake video frame provider that always provides the same FakeVideoFrame. | 2681 // Fake video frame provider that always provides the same FakeVideoFrame. |
2690 class FakeVideoFrameProvider: public WebVideoFrameProvider { | 2682 class FakeVideoFrameProvider: public WebKit::WebVideoFrameProvider { |
2691 public: | 2683 public: |
2692 FakeVideoFrameProvider() : m_frame(0), m_client(0) { } | 2684 FakeVideoFrameProvider() : m_frame(0), m_client(0) { } |
2693 virtual ~FakeVideoFrameProvider() | 2685 virtual ~FakeVideoFrameProvider() |
2694 { | 2686 { |
2695 if (m_client) | 2687 if (m_client) |
2696 m_client->stopUsingProvider(); | 2688 m_client->stopUsingProvider(); |
2697 } | 2689 } |
2698 | 2690 |
2699 virtual void setVideoFrameProviderClient(Client* client) { m_client = client
; } | 2691 virtual void setVideoFrameProviderClient(Client* client) { m_client = client
; } |
2700 virtual WebVideoFrame* getCurrentFrame() { return m_frame; } | 2692 virtual WebKit::WebVideoFrame* getCurrentFrame() { return m_frame; } |
2701 virtual void putCurrentFrame(WebVideoFrame*) { } | 2693 virtual void putCurrentFrame(WebKit::WebVideoFrame*) { } |
2702 | 2694 |
2703 void setFrame(WebVideoFrame* frame) { m_frame = frame; } | 2695 void setFrame(WebKit::WebVideoFrame* frame) { m_frame = frame; } |
2704 | 2696 |
2705 private: | 2697 private: |
2706 WebVideoFrame* m_frame; | 2698 WebKit::WebVideoFrame* m_frame; |
2707 Client* m_client; | 2699 Client* m_client; |
2708 }; | 2700 }; |
2709 | 2701 |
2710 class StrictWebGraphicsContext3DWithIOSurface : public StrictWebGraphicsContext3
D { | 2702 class StrictWebGraphicsContext3DWithIOSurface : public StrictWebGraphicsContext3
D { |
2711 public: | 2703 public: |
2712 virtual WebString getString(WGC3Denum name) OVERRIDE | 2704 virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE |
2713 { | 2705 { |
2714 if (name == GL_EXTENSIONS) | 2706 if (name == GL_EXTENSIONS) |
2715 return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"); | 2707 return WebKit::WebString("GL_CHROMIUM_iosurface GL_ARB_texture_recta
ngle"); |
2716 | 2708 |
2717 return WebString(); | 2709 return WebKit::WebString(); |
2718 } | 2710 } |
2719 }; | 2711 }; |
2720 | 2712 |
2721 class FakeWebGraphicsContext3DWithIOSurface : public FakeWebGraphicsContext3D { | 2713 class FakeWebGraphicsContext3DWithIOSurface : public FakeWebGraphicsContext3D { |
2722 public: | 2714 public: |
2723 virtual WebString getString(WGC3Denum name) OVERRIDE | 2715 virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE |
2724 { | 2716 { |
2725 if (name == GL_EXTENSIONS) | 2717 if (name == GL_EXTENSIONS) |
2726 return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"); | 2718 return WebKit::WebString("GL_CHROMIUM_iosurface GL_ARB_texture_recta
ngle"); |
2727 | 2719 |
2728 return WebString(); | 2720 return WebKit::WebString(); |
2729 } | 2721 } |
2730 }; | 2722 }; |
2731 | 2723 |
2732 class FakeWebScrollbarThemeGeometryNonEmpty : public FakeWebScrollbarThemeGeomet
ry { | 2724 class FakeWebScrollbarThemeGeometryNonEmpty : public FakeWebScrollbarThemeGeomet
ry { |
2733 virtual WebRect trackRect(WebScrollbar*) OVERRIDE { return WebRect(0, 0, 10,
10); } | 2725 virtual WebKit::WebRect trackRect(WebKit::WebScrollbar*) OVERRIDE { return W
ebKit::WebRect(0, 0, 10, 10); } |
2734 virtual WebRect thumbRect(WebScrollbar*) OVERRIDE { return WebRect(0, 5, 5,
2); } | 2726 virtual WebKit::WebRect thumbRect(WebKit::WebScrollbar*) OVERRIDE { return W
ebKit::WebRect(0, 5, 5, 2); } |
2735 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT
rack, WebRect& thumb, WebRect& endTrack) OVERRIDE | 2727 virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& track,
WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTrack)
OVERRIDE |
2736 { | 2728 { |
2737 thumb = WebRect(0, 5, 5, 2); | 2729 thumb = WebKit::WebRect(0, 5, 5, 2); |
2738 startTrack = WebRect(0, 5, 0, 5); | 2730 startTrack = WebKit::WebRect(0, 5, 0, 5); |
2739 endTrack = WebRect(0, 0, 0, 5); | 2731 endTrack = WebKit::WebRect(0, 0, 0, 5); |
2740 } | 2732 } |
2741 }; | 2733 }; |
2742 | 2734 |
2743 class FakeScrollbarLayerImpl : public ScrollbarLayerImpl { | 2735 class FakeScrollbarLayerImpl : public ScrollbarLayerImpl { |
2744 public: | 2736 public: |
2745 static scoped_ptr<FakeScrollbarLayerImpl> create(LayerTreeImpl* treeImpl, in
t id) | 2737 static scoped_ptr<FakeScrollbarLayerImpl> create(LayerTreeImpl* treeImpl, in
t id) |
2746 { | 2738 { |
2747 return make_scoped_ptr(new FakeScrollbarLayerImpl(treeImpl, id)); | 2739 return make_scoped_ptr(new FakeScrollbarLayerImpl(treeImpl, id)); |
2748 } | 2740 } |
2749 | 2741 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2907 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2916 | 2908 |
2917 LayerTreeHostImpl::FrameData frame; | 2909 LayerTreeHostImpl::FrameData frame; |
2918 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2910 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2919 m_hostImpl->drawLayers(frame); | 2911 m_hostImpl->drawLayers(frame); |
2920 m_hostImpl->didDrawAllLayers(frame); | 2912 m_hostImpl->didDrawAllLayers(frame); |
2921 m_hostImpl->swapBuffers(); | 2913 m_hostImpl->swapBuffers(); |
2922 | 2914 |
2923 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); | 2915 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); |
2924 | 2916 |
2925 // Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsConte
xt3DWithIOSurface, | 2917 // Lose the WebKit::WebGraphicsContext3D, replacing it with a StrictWebGraph
icsContext3DWithIOSurface, |
2926 // that will warn if any resource from the previous context gets used. | 2918 // that will warn if any resource from the previous context gets used. |
2927 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit
::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<Out
putSurface>()); | 2919 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit
::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<Out
putSurface>()); |
2928 | 2920 |
2929 // Create dummy resources so that looking up an old resource will get an | 2921 // Create dummy resources so that looking up an old resource will get an |
2930 // invalid texture id mapping. | 2922 // invalid texture id mapping. |
2931 for (unsigned i = 0; i < numResources; ++i) | 2923 for (unsigned i = 0; i < numResources; ++i) |
2932 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict
WebGraphicsContext3D::kExternalTextureId); | 2924 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict
WebGraphicsContext3D::kExternalTextureId); |
2933 | 2925 |
2934 // The WebVideoFrameProvider is expected to recreate its textures after a | 2926 // The WebKit::WebVideoFrameProvider is expected to recreate its textures af
ter a |
2935 // lost output surface (or not serve a frame). | 2927 // lost output surface (or not serve a frame). |
2936 hwProvider.setFrame(0); | 2928 hwProvider.setFrame(0); |
2937 providerScaled.setFrame(0); | 2929 providerScaled.setFrame(0); |
2938 | 2930 |
2939 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2931 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2940 m_hostImpl->drawLayers(frame); | 2932 m_hostImpl->drawLayers(frame); |
2941 m_hostImpl->didDrawAllLayers(frame); | 2933 m_hostImpl->didDrawAllLayers(frame); |
2942 m_hostImpl->swapBuffers(); | 2934 m_hostImpl->swapBuffers(); |
2943 | 2935 |
2944 FakeVideoFrame hwVideoFrame2( | 2936 FakeVideoFrame hwVideoFrame2( |
2945 VideoFrame::WrapNativeTexture( | 2937 VideoFrame::WrapNativeTexture( |
2946 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2938 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
2947 GL_TEXTURE_2D, | 2939 GL_TEXTURE_2D, |
2948 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), | 2940 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), |
2949 VideoFrame::ReadPixelsCB(), base::Closure())); | 2941 VideoFrame::ReadPixelsCB(), base::Closure())); |
2950 hwProvider.setFrame(&hwVideoFrame2); | 2942 hwProvider.setFrame(&hwVideoFrame2); |
2951 | 2943 |
2952 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2944 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2953 m_hostImpl->drawLayers(frame); | 2945 m_hostImpl->drawLayers(frame); |
2954 m_hostImpl->didDrawAllLayers(frame); | 2946 m_hostImpl->didDrawAllLayers(frame); |
2955 m_hostImpl->swapBuffers(); | 2947 m_hostImpl->swapBuffers(); |
2956 } | 2948 } |
2957 | 2949 |
2958 // Fake WebGraphicsContext3D that tracks the number of textures in use. | 2950 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use. |
2959 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 2951 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
2960 public: | 2952 public: |
2961 TrackingWebGraphicsContext3D() | 2953 TrackingWebGraphicsContext3D() |
2962 : FakeWebGraphicsContext3D() | 2954 : FakeWebGraphicsContext3D() |
2963 , m_numTextures(0) | 2955 , m_numTextures(0) |
2964 { } | 2956 { } |
2965 | 2957 |
2966 virtual WebGLId createTexture() OVERRIDE | 2958 virtual WebKit::WebGLId createTexture() OVERRIDE |
2967 { | 2959 { |
2968 WebGLId id = FakeWebGraphicsContext3D::createTexture(); | 2960 WebKit::WebGLId id = FakeWebGraphicsContext3D::createTexture(); |
2969 | 2961 |
2970 m_textures[id] = true; | 2962 m_textures[id] = true; |
2971 ++m_numTextures; | 2963 ++m_numTextures; |
2972 return id; | 2964 return id; |
2973 } | 2965 } |
2974 | 2966 |
2975 virtual void deleteTexture(WebGLId id) OVERRIDE | 2967 virtual void deleteTexture(WebKit::WebGLId id) OVERRIDE |
2976 { | 2968 { |
2977 if (m_textures.find(id) == m_textures.end()) | 2969 if (m_textures.find(id) == m_textures.end()) |
2978 return; | 2970 return; |
2979 | 2971 |
2980 m_textures[id] = false; | 2972 m_textures[id] = false; |
2981 --m_numTextures; | 2973 --m_numTextures; |
2982 } | 2974 } |
2983 | 2975 |
2984 virtual WebString getString(WGC3Denum name) OVERRIDE | 2976 virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE |
2985 { | 2977 { |
2986 if (name == GL_EXTENSIONS) | 2978 if (name == GL_EXTENSIONS) |
2987 return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"); | 2979 return WebKit::WebString("GL_CHROMIUM_iosurface GL_ARB_texture_recta
ngle"); |
2988 | 2980 |
2989 return WebString(); | 2981 return WebKit::WebString(); |
2990 } | 2982 } |
2991 | 2983 |
2992 unsigned numTextures() const { return m_numTextures; } | 2984 unsigned numTextures() const { return m_numTextures; } |
2993 | 2985 |
2994 private: | 2986 private: |
2995 base::hash_map<WebGLId, bool> m_textures; | 2987 base::hash_map<WebKit::WebGLId, bool> m_textures; |
2996 unsigned m_numTextures; | 2988 unsigned m_numTextures; |
2997 }; | 2989 }; |
2998 | 2990 |
2999 TEST_P(LayerTreeHostImplTest, layersFreeTextures) | 2991 TEST_P(LayerTreeHostImplTest, layersFreeTextures) |
3000 { | 2992 { |
3001 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(),
1)); | 2993 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(),
1)); |
3002 rootLayer->setBounds(gfx::Size(10, 10)); | 2994 rootLayer->setBounds(gfx::Size(10, 10)); |
3003 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2995 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3004 | 2996 |
3005 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(m_hostImpl->ac
tiveTree(), 2); | 2997 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(m_hostImpl->ac
tiveTree(), 2); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u); | 3048 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u); |
3057 | 3049 |
3058 // Kill the layer tree. | 3050 // Kill the layer tree. |
3059 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 100)); | 3051 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 100)); |
3060 // There should be no textures left in use after. | 3052 // There should be no textures left in use after. |
3061 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures()); | 3053 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures()); |
3062 } | 3054 } |
3063 | 3055 |
3064 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 3056 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
3065 public: | 3057 public: |
3066 MOCK_METHOD1(useProgram, void(WebGLId program)); | 3058 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); |
3067 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 3059 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); |
3068 }; | 3060 }; |
3069 | 3061 |
3070 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) | 3062 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) |
3071 { | 3063 { |
3072 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); | 3064 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); |
3073 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); | 3065 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); |
3074 | 3066 |
3075 // Run test case | 3067 // Run test case |
3076 createLayerTreeHost(false, outputSurface.Pass()); | 3068 createLayerTreeHost(false, outputSurface.Pass()); |
3077 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); | 3069 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); |
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4890 { | 4882 { |
4891 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4883 pinchZoomPanViewportAndScrollBoundaryTest(2); |
4892 } | 4884 } |
4893 | 4885 |
4894 class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest
{ | 4886 class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest
{ |
4895 protected: | 4887 protected: |
4896 virtual scoped_ptr<OutputSurface> createOutputSurface() | 4888 virtual scoped_ptr<OutputSurface> createOutputSurface() |
4897 { | 4889 { |
4898 // Creates an output surface with a parent to use a delegating renderer. | 4890 // Creates an output surface with a parent to use a delegating renderer. |
4899 WebKit::WebGraphicsContext3D::Attributes attrs; | 4891 WebKit::WebGraphicsContext3D::Attributes attrs; |
4900 return FakeOutputSurface::CreateDelegating3d(WebKit::CompositorFakeWebGr
aphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<Ou
tputSurface>(); | 4892 return FakeOutputSurface::CreateDelegating3d(CompositorFakeWebGraphicsCo
ntext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurf
ace>(); |
4901 } | 4893 } |
4902 | 4894 |
4903 void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) { | 4895 void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) { |
4904 LayerTreeHostImpl::FrameData frame; | 4896 LayerTreeHostImpl::FrameData frame; |
4905 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4897 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
4906 ASSERT_EQ(1u, frame.renderPasses.size()); | 4898 ASSERT_EQ(1u, frame.renderPasses.size()); |
4907 | 4899 |
4908 // Verify the damage rect for the root render pass. | 4900 // Verify the damage rect for the root render pass. |
4909 const RenderPass* rootRenderPass = frame.renderPasses.back(); | 4901 const RenderPass* rootRenderPass = frame.renderPasses.back(); |
4910 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); | 4902 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); |
(...skipping 18 matching lines...) Expand all Loading... |
4929 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4921 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4930 drawFrameAndTestDamage(noDamage); | 4922 drawFrameAndTestDamage(noDamage); |
4931 } | 4923 } |
4932 | 4924 |
4933 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4925 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4934 LayerTreeHostImplTest, | 4926 LayerTreeHostImplTest, |
4935 ::testing::Values(false, true)); | 4927 ::testing::Values(false, true)); |
4936 | 4928 |
4937 } // namespace | 4929 } // namespace |
4938 } // namespace cc | 4930 } // namespace cc |
OLD | NEW |