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

Side by Side Diff: Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

Issue 10690121: Merge 121076 - [chromium] LayerRendererChromium is not getting visibility messages in single thread… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); 72 m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
73 m_hostImpl->initializeLayerRenderer(createContext(), UnthrottledUploader ); 73 m_hostImpl->initializeLayerRenderer(createContext(), UnthrottledUploader );
74 m_hostImpl->setViewportSize(IntSize(10, 10)); 74 m_hostImpl->setViewportSize(IntSize(10, 10));
75 } 75 }
76 76
77 virtual void didLoseContextOnImplThread() OVERRIDE { } 77 virtual void didLoseContextOnImplThread() OVERRIDE { }
78 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } 78 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
79 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } 79 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; }
80 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } 80 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; }
81 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { } 81 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { }
82 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThre ad(size_t) OVERRIDE { }
83 82
84 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassRe fPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) 83 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassRe fPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
85 { 84 {
86 CCSettings::setPartialSwapEnabled(partialSwap); 85 CCSettings::setPartialSwapEnabled(partialSwap);
87 86
88 CCLayerTreeSettings settings; 87 CCLayerTreeSettings settings;
89 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(set tings, this); 88 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(set tings, this);
90 89
91 myHostImpl->initializeLayerRenderer(graphicsContext, UnthrottledUploader ); 90 myHostImpl->initializeLayerRenderer(graphicsContext, UnthrottledUploader );
92 myHostImpl->setViewportSize(IntSize(10, 10)); 91 myHostImpl->setViewportSize(IntSize(10, 10));
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 root->setUpdateRect(FloatRect(0, 0, 2, 2)); 1782 root->setUpdateRect(FloatRect(0, 0, 2, 2));
1784 1783
1785 // This draw should generate no new udpates 1784 // This draw should generate no new udpates
1786 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 1785 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
1787 myHostImpl->drawLayers(frame); 1786 myHostImpl->drawLayers(frame);
1788 myHostImpl->didDrawAllLayers(frame); 1787 myHostImpl->didDrawAllLayers(frame);
1789 1788
1790 Mock::VerifyAndClearExpectations(&mockContext); 1789 Mock::VerifyAndClearExpectations(&mockContext);
1791 } 1790 }
1792 1791
1793 class PartialSwapContext: public FakeWebGraphicsContext3D { 1792 class PartialSwapContext : public FakeWebGraphicsContext3D {
1794 public: 1793 public:
1795 WebString getString(WGC3Denum name) 1794 WebString getString(WGC3Denum name)
1796 { 1795 {
1797 if (name == GraphicsContext3D::EXTENSIONS) 1796 if (name == GraphicsContext3D::EXTENSIONS)
1798 return WebString("GL_CHROMIUM_post_sub_buffer"); 1797 return WebString("GL_CHROMIUM_post_sub_buffer");
1799 return WebString(); 1798 return WebString();
1800 } 1799 }
1801 1800
1802 WebString getRequestableExtensionsCHROMIUM() 1801 WebString getRequestableExtensionsCHROMIUM()
1803 { 1802 {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 2031
2033 private: 2032 private:
2034 ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { } 2033 ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { }
2035 }; 2034 };
2036 2035
2037 // Fake WebGraphicsContext3D that will cause a failure if trying to use a 2036 // Fake WebGraphicsContext3D that will cause a failure if trying to use a
2038 // resource that wasn't created by it (resources created by 2037 // resource that wasn't created by it (resources created by
2039 // FakeWebGraphicsContext3D have an id of 1). 2038 // FakeWebGraphicsContext3D have an id of 1).
2040 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { 2039 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D {
2041 public: 2040 public:
2041 StrictWebGraphicsContext3D()
2042 : FakeWebGraphicsContext3D()
2043 {
2044 m_nextTextureId = 7; // Start allocating texture ids larger than any oth er resource IDs so we can tell if someone's mixing up their resource types.
2045 }
2046
2042 virtual WebGLId createBuffer() { return 2; } 2047 virtual WebGLId createBuffer() { return 2; }
2043 virtual WebGLId createFramebuffer() { return 3; } 2048 virtual WebGLId createFramebuffer() { return 3; }
2044 virtual WebGLId createProgram() { return 4; } 2049 virtual WebGLId createProgram() { return 4; }
2045 virtual WebGLId createRenderbuffer() { return 5; } 2050 virtual WebGLId createRenderbuffer() { return 5; }
2046 virtual WebGLId createShader(WGC3Denum) { return 6; } 2051 virtual WebGLId createShader(WGC3Denum) { return 6; }
2047 virtual WebGLId createTexture() { return 7; }
2048 2052
2049 virtual void deleteBuffer(WebGLId id) 2053 virtual void deleteBuffer(WebGLId id)
2050 { 2054 {
2051 if (id != 2) 2055 if (id != 2)
2052 ADD_FAILURE() << "Trying to delete buffer id " << id; 2056 ADD_FAILURE() << "Trying to delete buffer id " << id;
2053 } 2057 }
2054 2058
2055 virtual void deleteFramebuffer(WebGLId id) 2059 virtual void deleteFramebuffer(WebGLId id)
2056 { 2060 {
2057 if (id != 3) 2061 if (id != 3)
(...skipping 11 matching lines...) Expand all
2069 if (id != 5) 2073 if (id != 5)
2070 ADD_FAILURE() << "Trying to delete renderbuffer id " << id; 2074 ADD_FAILURE() << "Trying to delete renderbuffer id " << id;
2071 } 2075 }
2072 2076
2073 virtual void deleteShader(WebGLId id) 2077 virtual void deleteShader(WebGLId id)
2074 { 2078 {
2075 if (id != 6) 2079 if (id != 6)
2076 ADD_FAILURE() << "Trying to delete shader id " << id; 2080 ADD_FAILURE() << "Trying to delete shader id " << id;
2077 } 2081 }
2078 2082
2083 virtual WebGLId createTexture()
2084 {
2085 unsigned textureId = FakeWebGraphicsContext3D::createTexture();
2086 m_allocatedTextureIds.add(textureId);
2087 return textureId;
2088 }
2079 virtual void deleteTexture(WebGLId id) 2089 virtual void deleteTexture(WebGLId id)
2080 { 2090 {
2081 if (id != 7) 2091 if (!m_allocatedTextureIds.contains(id))
2082 ADD_FAILURE() << "Trying to delete texture id " << id; 2092 ADD_FAILURE() << "Trying to delete texture id " << id;
2093 m_allocatedTextureIds.remove(id);
2083 } 2094 }
2084 2095
2085 virtual void bindBuffer(WGC3Denum, WebGLId id) 2096 virtual void bindBuffer(WGC3Denum, WebGLId id)
2086 { 2097 {
2087 if (id != 2 && id) 2098 if (id != 2 && id)
2088 ADD_FAILURE() << "Trying to bind buffer id " << id; 2099 ADD_FAILURE() << "Trying to bind buffer id " << id;
2089 } 2100 }
2090 2101
2091 virtual void bindFramebuffer(WGC3Denum, WebGLId id) 2102 virtual void bindFramebuffer(WGC3Denum, WebGLId id)
2092 { 2103 {
(...skipping 14 matching lines...) Expand all
2107 } 2118 }
2108 2119
2109 virtual void attachShader(WebGLId program, WebGLId shader) 2120 virtual void attachShader(WebGLId program, WebGLId shader)
2110 { 2121 {
2111 if ((program != 4) || (shader != 6)) 2122 if ((program != 4) || (shader != 6))
2112 ADD_FAILURE() << "Trying to attach shader id " << shader << " to pro gram id " << program; 2123 ADD_FAILURE() << "Trying to attach shader id " << shader << " to pro gram id " << program;
2113 } 2124 }
2114 2125
2115 virtual void bindTexture(WGC3Denum, WebGLId id) 2126 virtual void bindTexture(WGC3Denum, WebGLId id)
2116 { 2127 {
2117 if (id != 7 && id) 2128 if (id && !m_allocatedTextureIds.contains(id))
2118 ADD_FAILURE() << "Trying to bind texture id " << id; 2129 ADD_FAILURE() << "Trying to bind texture id " << id;
2119 } 2130 }
2120 2131
2121 static PassRefPtr<GraphicsContext3D> createGraphicsContext() 2132 static PassRefPtr<GraphicsContext3D> createGraphicsContext()
2122 { 2133 {
2123 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(ado ptPtr(new StrictWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHost Window); 2134 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(ado ptPtr(new StrictWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHost Window);
2124 } 2135 }
2136
2137 private:
2138 HashSet<unsigned> m_allocatedTextureIds;
2125 }; 2139 };
2126 2140
2127 // Fake video frame that represents a 4x4 YUV video frame. 2141 // Fake video frame that represents a 4x4 YUV video frame.
2128 class FakeVideoFrame: public WebVideoFrame { 2142 class FakeVideoFrame: public WebVideoFrame {
2129 public: 2143 public:
2130 FakeVideoFrame() { memset(m_data, 0x80, sizeof(m_data)); } 2144 FakeVideoFrame() { memset(m_data, 0x80, sizeof(m_data)); }
2131 virtual ~FakeVideoFrame() { } 2145 virtual ~FakeVideoFrame() { }
2132 virtual Format format() const { return FormatYV12; } 2146 virtual Format format() const { return FormatYV12; }
2133 virtual unsigned width() const { return 4; } 2147 virtual unsigned width() const { return 4; }
2134 virtual unsigned height() const { return 4; } 2148 virtual unsigned height() const { return 4; }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2268 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2255 m_hostImpl->drawLayers(frame); 2269 m_hostImpl->drawLayers(frame);
2256 m_hostImpl->didDrawAllLayers(frame); 2270 m_hostImpl->didDrawAllLayers(frame);
2257 m_hostImpl->swapBuffers(); 2271 m_hostImpl->swapBuffers();
2258 } 2272 }
2259 2273
2260 // Fake WebGraphicsContext3D that tracks the number of textures in use. 2274 // Fake WebGraphicsContext3D that tracks the number of textures in use.
2261 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D { 2275 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D {
2262 public: 2276 public:
2263 TrackingWebGraphicsContext3D() 2277 TrackingWebGraphicsContext3D()
2264 : m_nextTextureId(1) 2278 : FakeWebGraphicsContext3D()
2265 , m_numTextures(0) 2279 , m_numTextures(0)
2266 { } 2280 { }
2267 2281
2268 virtual WebGLId createTexture() OVERRIDE 2282 virtual WebGLId createTexture() OVERRIDE
2269 { 2283 {
2270 WebGLId id = m_nextTextureId; 2284 WebGLId id = FakeWebGraphicsContext3D::createTexture();
2271 ++m_nextTextureId;
2272 2285
2273 m_textures.set(id, true); 2286 m_textures.set(id, true);
2274 ++m_numTextures; 2287 ++m_numTextures;
2275 return id; 2288 return id;
2276 } 2289 }
2277 2290
2278 virtual void deleteTexture(WebGLId id) OVERRIDE 2291 virtual void deleteTexture(WebGLId id) OVERRIDE
2279 { 2292 {
2280 if (!m_textures.get(id)) 2293 if (!m_textures.get(id))
2281 return; 2294 return;
(...skipping 11 matching lines...) Expand all
2293 } 2306 }
2294 2307
2295 PassRefPtr<GraphicsContext3D> createGraphicsContext() 2308 PassRefPtr<GraphicsContext3D> createGraphicsContext()
2296 { 2309 {
2297 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(ado ptPtr(this), GraphicsContext3D::RenderDirectlyToHostWindow); 2310 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(ado ptPtr(this), GraphicsContext3D::RenderDirectlyToHostWindow);
2298 } 2311 }
2299 2312
2300 unsigned numTextures() const { return m_numTextures; } 2313 unsigned numTextures() const { return m_numTextures; }
2301 2314
2302 private: 2315 private:
2303 WebGLId m_nextTextureId;
2304 HashMap<WebGLId, bool> m_textures; 2316 HashMap<WebGLId, bool> m_textures;
2305 unsigned m_numTextures; 2317 unsigned m_numTextures;
2306 }; 2318 };
2307 2319
2308 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) 2320 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
2309 { 2321 {
2310 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); 2322 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
2311 rootLayer->setBounds(IntSize(10, 10)); 2323 rootLayer->setBounds(IntSize(10, 10));
2312 rootLayer->setAnchorPoint(FloatPoint(0, 0)); 2324 rootLayer->setAnchorPoint(FloatPoint(0, 0));
2313 2325
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 2414
2403 // Verify no quads are drawn when transparent background is set. 2415 // Verify no quads are drawn when transparent background is set.
2404 myHostImpl->setHasTransparentBackground(true); 2416 myHostImpl->setHasTransparentBackground(true);
2405 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2417 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
2406 myHostImpl->drawLayers(frame); 2418 myHostImpl->drawLayers(frame);
2407 myHostImpl->didDrawAllLayers(frame); 2419 myHostImpl->didDrawAllLayers(frame);
2408 Mock::VerifyAndClearExpectations(&mockContext); 2420 Mock::VerifyAndClearExpectations(&mockContext);
2409 } 2421 }
2410 2422
2411 } // namespace 2423 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698