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

Side by Side Diff: cc/gl_renderer.cc

Issue 11196014: Revert "cc: Switch to Chromium DCHECKs LOGs" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "CCRendererGL.h" 7 #include "CCRendererGL.h"
8 8
9 #include "CCDamageTracker.h" 9 #include "CCDamageTracker.h"
10 #include "CCLayerQuad.h" 10 #include "CCLayerQuad.h"
11 #include "CCMathUtil.h" 11 #include "CCMathUtil.h"
12 #include "CCProxy.h" 12 #include "CCProxy.h"
13 #include "CCRenderPass.h" 13 #include "CCRenderPass.h"
14 #include "CCRenderSurfaceFilters.h" 14 #include "CCRenderSurfaceFilters.h"
15 #include "CCScopedTexture.h" 15 #include "CCScopedTexture.h"
16 #include "CCSettings.h" 16 #include "CCSettings.h"
17 #include "CCSingleThreadProxy.h" 17 #include "CCSingleThreadProxy.h"
18 #include "CCVideoLayerImpl.h" 18 #include "CCVideoLayerImpl.h"
19 #include "Extensions3D.h" 19 #include "Extensions3D.h"
20 #include "FloatQuad.h" 20 #include "FloatQuad.h"
21 #include "GrTexture.h" 21 #include "GrTexture.h"
22 #include "NotImplemented.h" 22 #include "NotImplemented.h"
23 #include "TraceEvent.h" 23 #include "TraceEvent.h"
24 #ifdef LOG
25 #undef LOG
26 #endif
24 #include "base/string_split.h" 27 #include "base/string_split.h"
25 #include "base/string_util.h" 28 #include "base/string_util.h"
26 #include "cc/dcheck.h"
27 #include "cc/geometry_binding.h" 29 #include "cc/geometry_binding.h"
28 #include "cc/platform_color.h" 30 #include "cc/platform_color.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 31 #include "third_party/skia/include/core/SkBitmap.h"
30 #include "third_party/skia/include/core/SkColor.h" 32 #include "third_party/skia/include/core/SkColor.h"
31 #include <public/WebGraphicsContext3D.h> 33 #include <public/WebGraphicsContext3D.h>
32 #include <public/WebSharedGraphicsContext3D.h> 34 #include <public/WebSharedGraphicsContext3D.h>
33 #include <public/WebVideoFrame.h> 35 #include <public/WebVideoFrame.h>
34 #include <set> 36 #include <set>
35 #include <string> 37 #include <string>
36 #include <vector> 38 #include <vector>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 CCResourceProvider* resourceProvider) 72 CCResourceProvider* resourceProvider)
71 : CCDirectRenderer(client, resourceProvider) 73 : CCDirectRenderer(client, resourceProvider)
72 , m_offscreenFramebufferId(0) 74 , m_offscreenFramebufferId(0)
73 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) 75 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f))
74 , m_context(resourceProvider->graphicsContext3D()) 76 , m_context(resourceProvider->graphicsContext3D())
75 , m_isViewportChanged(false) 77 , m_isViewportChanged(false)
76 , m_isFramebufferDiscarded(false) 78 , m_isFramebufferDiscarded(false)
77 , m_isUsingBindUniform(false) 79 , m_isUsingBindUniform(false)
78 , m_visible(true) 80 , m_visible(true)
79 { 81 {
80 DCHECK(m_context); 82 ASSERT(m_context);
81 } 83 }
82 84
83 bool CCRendererGL::initialize() 85 bool CCRendererGL::initialize()
84 { 86 {
85 if (!m_context->makeContextCurrent()) 87 if (!m_context->makeContextCurrent())
86 return false; 88 return false;
87 89
88 m_context->setContextLostCallback(this); 90 m_context->setContextLostCallback(this);
89 m_context->pushGroupMarkerEXT("CompositorContext"); 91 m_context->pushGroupMarkerEXT("CompositorContext");
90 92
(...skipping 15 matching lines...) Expand all
106 108
107 // Use the swapBuffers callback only with the threaded proxy. 109 // Use the swapBuffers callback only with the threaded proxy.
108 if (CCProxy::hasImplThread()) 110 if (CCProxy::hasImplThread())
109 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback"); 111 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback");
110 if (m_capabilities.usingSwapCompleteCallback) 112 if (m_capabilities.usingSwapCompleteCallback)
111 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); 113 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
112 114
113 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity"); 115 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity");
114 116
115 if (extensions.count("GL_CHROMIUM_iosurface")) 117 if (extensions.count("GL_CHROMIUM_iosurface"))
116 DCHECK(extensions.count("GL_ARB_texture_rectangle")); 118 ASSERT(extensions.count("GL_ARB_texture_rectangle"));
117 119
118 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager"); 120 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager");
119 if (m_capabilities.usingGpuMemoryManager) 121 if (m_capabilities.usingGpuMemoryManager)
120 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); 122 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this);
121 123
122 m_capabilities.usingDiscardFramebuffer = extensions.count("GL_CHROMIUM_disca rd_framebuffer"); 124 m_capabilities.usingDiscardFramebuffer = extensions.count("GL_CHROMIUM_disca rd_framebuffer");
123 125
124 m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external") ; 126 m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external") ;
125 127
126 GLC(m_context, m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, & m_capabilities.maxTextureSize)); 128 GLC(m_context, m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, & m_capabilities.maxTextureSize));
127 m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_contex t, extensions.count("GL_EXT_texture_format_BGRA8888")); 129 m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_contex t, extensions.count("GL_EXT_texture_format_BGRA8888"));
128 130
129 m_isUsingBindUniform = extensions.count("GL_CHROMIUM_bind_uniform_location") ; 131 m_isUsingBindUniform = extensions.count("GL_CHROMIUM_bind_uniform_location") ;
130 132
131 if (!initializeSharedObjects()) 133 if (!initializeSharedObjects())
132 return false; 134 return false;
133 135
134 // Make sure the viewport and context gets initialized, even if it is to zer o. 136 // Make sure the viewport and context gets initialized, even if it is to zer o.
135 viewportChanged(); 137 viewportChanged();
136 return true; 138 return true;
137 } 139 }
138 140
139 CCRendererGL::~CCRendererGL() 141 CCRendererGL::~CCRendererGL()
140 { 142 {
141 DCHECK(CCProxy::isImplThread()); 143 ASSERT(CCProxy::isImplThread());
142 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); 144 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
143 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); 145 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
144 m_context->setContextLostCallback(0); 146 m_context->setContextLostCallback(0);
145 cleanupSharedObjects(); 147 cleanupSharedObjects();
146 } 148 }
147 149
148 const RendererCapabilities& CCRendererGL::capabilities() const 150 const RendererCapabilities& CCRendererGL::capabilities() const
149 { 151 {
150 return m_capabilities; 152 return m_capabilities;
151 } 153 }
152 154
153 WebGraphicsContext3D* CCRendererGL::context() 155 WebGraphicsContext3D* CCRendererGL::context()
154 { 156 {
155 return m_context; 157 return m_context;
156 } 158 }
157 159
158 void CCRendererGL::debugGLCall(WebGraphicsContext3D* context, const char* comman d, const char* file, int line) 160 void CCRendererGL::debugGLCall(WebGraphicsContext3D* context, const char* comman d, const char* file, int line)
159 { 161 {
160 unsigned long error = context->getError(); 162 unsigned long error = context->getError();
161 if (error != GraphicsContext3D::NO_ERROR) 163 if (error != GraphicsContext3D::NO_ERROR)
162 LOG(ERROR) << "GL command failed: File: " << file << "\n\tLine " << line << "\n\tcommand: " << command << ", error " << static_cast<int>(error) << "\n"; 164 LOG_ERROR("GL command failed: File: %s\n\tLine %d\n\tcommand: %s, error %x\n", file, line, command, static_cast<int>(error));
163 } 165 }
164 166
165 void CCRendererGL::setVisible(bool visible) 167 void CCRendererGL::setVisible(bool visible)
166 { 168 {
167 if (m_visible == visible) 169 if (m_visible == visible)
168 return; 170 return;
169 m_visible = visible; 171 m_visible = visible;
170 172
171 // TODO: Replace setVisibilityCHROMIUM with an extension to explicitly manag e front/backbuffers 173 // TODO: Replace setVisibilityCHROMIUM with an extension to explicitly manag e front/backbuffers
172 // crbug.com/116049 174 // crbug.com/116049
(...skipping 12 matching lines...) Expand all
185 } 187 }
186 188
187 void CCRendererGL::clearFramebuffer(DrawingFrame& frame) 189 void CCRendererGL::clearFramebuffer(DrawingFrame& frame)
188 { 190 {
189 // On DEBUG builds, opaque render passes are cleared to blue to easily see r egions that were not drawn on the screen. 191 // On DEBUG builds, opaque render passes are cleared to blue to easily see r egions that were not drawn on the screen.
190 if (frame.currentRenderPass->hasTransparentBackground()) 192 if (frame.currentRenderPass->hasTransparentBackground())
191 GLC(m_context, m_context->clearColor(0, 0, 0, 0)); 193 GLC(m_context, m_context->clearColor(0, 0, 0, 0));
192 else 194 else
193 GLC(m_context, m_context->clearColor(0, 0, 1, 1)); 195 GLC(m_context, m_context->clearColor(0, 0, 1, 1));
194 196
195 #if !CC_DCHECK_ENABLED() 197 #if defined(NDEBUG)
196 if (frame.currentRenderPass->hasTransparentBackground()) 198 if (frame.currentRenderPass->hasTransparentBackground())
197 #endif 199 #endif
198 m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT); 200 m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
199 } 201 }
200 202
201 void CCRendererGL::beginDrawingFrame(DrawingFrame& frame) 203 void CCRendererGL::beginDrawingFrame(DrawingFrame& frame)
202 { 204 {
203 // FIXME: Remove this once framebuffer is automatically recreated on first u se 205 // FIXME: Remove this once framebuffer is automatically recreated on first u se
204 ensureFramebuffer(); 206 ensureFramebuffer();
205 207
(...skipping 28 matching lines...) Expand all
234 236
235 void CCRendererGL::drawQuad(DrawingFrame& frame, const CCDrawQuad* quad) 237 void CCRendererGL::drawQuad(DrawingFrame& frame, const CCDrawQuad* quad)
236 { 238 {
237 if (quad->needsBlending()) 239 if (quad->needsBlending())
238 GLC(m_context, m_context->enable(GraphicsContext3D::BLEND)); 240 GLC(m_context, m_context->enable(GraphicsContext3D::BLEND));
239 else 241 else
240 GLC(m_context, m_context->disable(GraphicsContext3D::BLEND)); 242 GLC(m_context, m_context->disable(GraphicsContext3D::BLEND));
241 243
242 switch (quad->material()) { 244 switch (quad->material()) {
243 case CCDrawQuad::Invalid: 245 case CCDrawQuad::Invalid:
244 NOTREACHED(); 246 ASSERT_NOT_REACHED();
245 break; 247 break;
246 case CCDrawQuad::Checkerboard: 248 case CCDrawQuad::Checkerboard:
247 drawCheckerboardQuad(frame, CCCheckerboardDrawQuad::materialCast(quad)); 249 drawCheckerboardQuad(frame, CCCheckerboardDrawQuad::materialCast(quad));
248 break; 250 break;
249 case CCDrawQuad::DebugBorder: 251 case CCDrawQuad::DebugBorder:
250 drawDebugBorderQuad(frame, CCDebugBorderDrawQuad::materialCast(quad)); 252 drawDebugBorderQuad(frame, CCDebugBorderDrawQuad::materialCast(quad));
251 break; 253 break;
252 case CCDrawQuad::IOSurfaceContent: 254 case CCDrawQuad::IOSurfaceContent:
253 drawIOSurfaceQuad(frame, CCIOSurfaceDrawQuad::materialCast(quad)); 255 drawIOSurfaceQuad(frame, CCIOSurfaceDrawQuad::materialCast(quad));
254 break; 256 break;
(...skipping 14 matching lines...) Expand all
269 break; 271 break;
270 case CCDrawQuad::YUVVideoContent: 272 case CCDrawQuad::YUVVideoContent:
271 drawYUVVideoQuad(frame, CCYUVVideoDrawQuad::materialCast(quad)); 273 drawYUVVideoQuad(frame, CCYUVVideoDrawQuad::materialCast(quad));
272 break; 274 break;
273 } 275 }
274 } 276 }
275 277
276 void CCRendererGL::drawCheckerboardQuad(const DrawingFrame& frame, const CCCheck erboardDrawQuad* quad) 278 void CCRendererGL::drawCheckerboardQuad(const DrawingFrame& frame, const CCCheck erboardDrawQuad* quad)
277 { 279 {
278 const TileCheckerboardProgram* program = tileCheckerboardProgram(); 280 const TileCheckerboardProgram* program = tileCheckerboardProgram();
279 DCHECK(program && program->initialized()); 281 ASSERT(program && program->initialized());
280 GLC(context(), context()->useProgram(program->program())); 282 GLC(context(), context()->useProgram(program->program()));
281 283
282 SkColor color = quad->color(); 284 SkColor color = quad->color();
283 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), SkColorGetR(color) / 255.0, SkColorGetG(color) / 255.0, SkColorGetB(color) / 255.0, 1)); 285 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), SkColorGetR(color) / 255.0, SkColorGetG(color) / 255.0, SkColorGetB(color) / 255.0, 1));
284 286
285 const int checkerboardWidth = 16; 287 const int checkerboardWidth = 16;
286 float frequency = 1.0 / checkerboardWidth; 288 float frequency = 1.0 / checkerboardWidth;
287 289
288 IntRect tileRect = quad->quadRect(); 290 IntRect tileRect = quad->quadRect();
289 float texOffsetX = tileRect.x() % checkerboardWidth; 291 float texOffsetX = tileRect.x() % checkerboardWidth;
290 float texOffsetY = tileRect.y() % checkerboardWidth; 292 float texOffsetY = tileRect.y() % checkerboardWidth;
291 float texScaleX = tileRect.width(); 293 float texScaleX = tileRect.width();
292 float texScaleY = tileRect.height(); 294 float texScaleY = tileRect.height();
293 GLC(context(), context()->uniform4f(program->fragmentShader().texTransformLo cation(), texOffsetX, texOffsetY, texScaleX, texScaleY)); 295 GLC(context(), context()->uniform4f(program->fragmentShader().texTransformLo cation(), texOffsetX, texOffsetY, texScaleX, texScaleY));
294 296
295 GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocat ion(), frequency)); 297 GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocat ion(), frequency));
296 298
297 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ; 299 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ;
298 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), program->ve rtexShader().matrixLocation()); 300 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), program->ve rtexShader().matrixLocation());
299 } 301 }
300 302
301 void CCRendererGL::drawDebugBorderQuad(const DrawingFrame& frame, const CCDebugB orderDrawQuad* quad) 303 void CCRendererGL::drawDebugBorderQuad(const DrawingFrame& frame, const CCDebugB orderDrawQuad* quad)
302 { 304 {
303 static float glMatrix[16]; 305 static float glMatrix[16];
304 const SolidColorProgram* program = solidColorProgram(); 306 const SolidColorProgram* program = solidColorProgram();
305 DCHECK(program && program->initialized()); 307 ASSERT(program && program->initialized());
306 GLC(context(), context()->useProgram(program->program())); 308 GLC(context(), context()->useProgram(program->program()));
307 309
308 // Use the full quadRect for debug quads to not move the edges based on part ial swaps. 310 // Use the full quadRect for debug quads to not move the edges based on part ial swaps.
309 const IntRect& layerRect = quad->quadRect(); 311 const IntRect& layerRect = quad->quadRect();
310 WebTransformationMatrix renderMatrix = quad->quadTransform(); 312 WebTransformationMatrix renderMatrix = quad->quadTransform();
311 renderMatrix.translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerR ect.height() + layerRect.y()); 313 renderMatrix.translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerR ect.height() + layerRect.y());
312 renderMatrix.scaleNonUniform(layerRect.width(), layerRect.height()); 314 renderMatrix.scaleNonUniform(layerRect.width(), layerRect.height());
313 CCRendererGL::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix ); 315 CCRendererGL::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix );
314 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLoc ation(), 1, false, &glMatrix[0])); 316 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLoc ation(), 1, false, &glMatrix[0]));
315 317
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 362
361 // FIXME: When this algorithm changes, update CCLayerTreeHost::prioritizeTex tures() accordingly. 363 // FIXME: When this algorithm changes, update CCLayerTreeHost::prioritizeTex tures() accordingly.
362 364
363 if (filters.isEmpty()) 365 if (filters.isEmpty())
364 return scoped_ptr<CCScopedTexture>(); 366 return scoped_ptr<CCScopedTexture>();
365 367
366 // FIXME: We only allow background filters on an opaque render surface becau se other surfaces may contain 368 // FIXME: We only allow background filters on an opaque render surface becau se other surfaces may contain
367 // translucent pixels, and the contents behind those translucent pixels woul dn't have the filter applied. 369 // translucent pixels, and the contents behind those translucent pixels woul dn't have the filter applied.
368 if (frame.currentRenderPass->hasTransparentBackground()) 370 if (frame.currentRenderPass->hasTransparentBackground())
369 return scoped_ptr<CCScopedTexture>(); 371 return scoped_ptr<CCScopedTexture>();
370 DCHECK(!frame.currentTexture); 372 ASSERT(!frame.currentTexture);
371 373
372 // FIXME: Do a single readback for both the surface and replica and cache th e filtered results (once filter textures are not reused). 374 // FIXME: Do a single readback for both the surface and replica and cache th e filtered results (once filter textures are not reused).
373 IntRect deviceRect = enclosingIntRect(CCMathUtil::mapClippedRect(contentsDev iceTransform, sharedGeometryQuad().boundingBox())); 375 IntRect deviceRect = enclosingIntRect(CCMathUtil::mapClippedRect(contentsDev iceTransform, sharedGeometryQuad().boundingBox()));
374 376
375 int top, right, bottom, left; 377 int top, right, bottom, left;
376 filters.getOutsets(top, right, bottom, left); 378 filters.getOutsets(top, right, bottom, left);
377 deviceRect.move(-left, -top); 379 deviceRect.move(-left, -top);
378 deviceRect.expand(left + right, top + bottom); 380 deviceRect.expand(left + right, top + bottom);
379 381
380 deviceRect.intersect(frame.currentRenderPass->outputRect()); 382 deviceRect.intersect(frame.currentRenderPass->outputRect());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return backgroundTexture.Pass(); 415 return backgroundTexture.Pass();
414 } 416 }
415 417
416 void CCRendererGL::drawRenderPassQuad(DrawingFrame& frame, const CCRenderPassDra wQuad* quad) 418 void CCRendererGL::drawRenderPassQuad(DrawingFrame& frame, const CCRenderPassDra wQuad* quad)
417 { 419 {
418 CachedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId ()); 420 CachedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId ());
419 if (!contentsTexture || !contentsTexture->id()) 421 if (!contentsTexture || !contentsTexture->id())
420 return; 422 return;
421 423
422 const CCRenderPass* renderPass = frame.renderPassesById->get(quad->renderPas sId()); 424 const CCRenderPass* renderPass = frame.renderPassesById->get(quad->renderPas sId());
423 DCHECK(renderPass); 425 ASSERT(renderPass);
424 if (!renderPass) 426 if (!renderPass)
425 return; 427 return;
426 428
427 WebTransformationMatrix quadRectMatrix; 429 WebTransformationMatrix quadRectMatrix;
428 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->quadRect()); 430 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->quadRect());
429 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); 431 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform();
430 432
431 // Can only draw surface if device matrix is invertible. 433 // Can only draw surface if device matrix is invertible.
432 if (!contentsDeviceTransform.isInvertible()) 434 if (!contentsDeviceTransform.isInvertible())
433 return; 435 return;
434 436
435 scoped_ptr<CCScopedTexture> backgroundTexture = drawBackgroundFilters(frame, quad, renderPass->backgroundFilters(), contentsDeviceTransform); 437 scoped_ptr<CCScopedTexture> backgroundTexture = drawBackgroundFilters(frame, quad, renderPass->backgroundFilters(), contentsDeviceTransform);
436 438
437 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica. 439 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica.
438 // Apply filters to the contents texture. 440 // Apply filters to the contents texture.
439 SkBitmap filterBitmap = applyFilters(this, renderPass->filters(), contentsTe xture); 441 SkBitmap filterBitmap = applyFilters(this, renderPass->filters(), contentsTe xture);
440 scoped_ptr<CCResourceProvider::ScopedReadLockGL> contentsResourceLock; 442 scoped_ptr<CCResourceProvider::ScopedReadLockGL> contentsResourceLock;
441 unsigned contentsTextureId = 0; 443 unsigned contentsTextureId = 0;
442 if (filterBitmap.getTexture()) { 444 if (filterBitmap.getTexture()) {
443 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e()); 445 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e());
444 contentsTextureId = texture->getTextureHandle(); 446 contentsTextureId = texture->getTextureHandle();
445 } else { 447 } else {
446 contentsResourceLock = make_scoped_ptr(new CCResourceProvider::ScopedRea dLockGL(m_resourceProvider, contentsTexture->id())); 448 contentsResourceLock = make_scoped_ptr(new CCResourceProvider::ScopedRea dLockGL(m_resourceProvider, contentsTexture->id()));
447 contentsTextureId = contentsResourceLock->textureId(); 449 contentsTextureId = contentsResourceLock->textureId();
448 } 450 }
449 451
450 // Draw the background texture if there is one. 452 // Draw the background texture if there is one.
451 if (backgroundTexture) { 453 if (backgroundTexture) {
452 DCHECK(backgroundTexture->size() == quad->quadRect().size()); 454 ASSERT(backgroundTexture->size() == quad->quadRect().size());
453 CCResourceProvider::ScopedReadLockGL lock(m_resourceProvider, background Texture->id()); 455 CCResourceProvider::ScopedReadLockGL lock(m_resourceProvider, background Texture->id());
454 copyTextureToFramebuffer(frame, lock.textureId(), quad->quadRect(), quad ->quadTransform()); 456 copyTextureToFramebuffer(frame, lock.textureId(), quad->quadRect(), quad ->quadTransform());
455 } 457 }
456 458
457 bool clipped = false; 459 bool clipped = false;
458 FloatQuad deviceQuad = CCMathUtil::mapQuad(contentsDeviceTransform, sharedGe ometryQuad(), clipped); 460 FloatQuad deviceQuad = CCMathUtil::mapQuad(contentsDeviceTransform, sharedGe ometryQuad(), clipped);
459 DCHECK(!clipped); 461 ASSERT(!clipped);
460 CCLayerQuad deviceLayerBounds = CCLayerQuad(FloatQuad(deviceQuad.boundingBox ())); 462 CCLayerQuad deviceLayerBounds = CCLayerQuad(FloatQuad(deviceQuad.boundingBox ()));
461 CCLayerQuad deviceLayerEdges = CCLayerQuad(deviceQuad); 463 CCLayerQuad deviceLayerEdges = CCLayerQuad(deviceQuad);
462 464
463 // Use anti-aliasing programs only when necessary. 465 // Use anti-aliasing programs only when necessary.
464 bool useAA = (!deviceQuad.isRectilinear() || !deviceQuad.boundingBox().isExp ressibleAsIntRect()); 466 bool useAA = (!deviceQuad.isRectilinear() || !deviceQuad.boundingBox().isExp ressibleAsIntRect());
465 if (useAA) { 467 if (useAA) {
466 deviceLayerBounds.inflateAntiAliasingDistance(); 468 deviceLayerBounds.inflateAntiAliasingDistance();
467 deviceLayerEdges.inflateAntiAliasingDistance(); 469 deviceLayerEdges.inflateAntiAliasingDistance();
468 } 470 }
469 471
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } else { 522 } else {
521 const RenderPassProgram* program = renderPassProgram(); 523 const RenderPassProgram* program = renderPassProgram();
522 GLC(context(), context()->useProgram(program->program())); 524 GLC(context(), context()->useProgram(program->program()));
523 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); 525 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0));
524 526
525 shaderMatrixLocation = program->vertexShader().matrixLocation(); 527 shaderMatrixLocation = program->vertexShader().matrixLocation();
526 shaderAlphaLocation = program->fragmentShader().alphaLocation(); 528 shaderAlphaLocation = program->fragmentShader().alphaLocation();
527 } 529 }
528 530
529 if (shaderMaskSamplerLocation != -1) { 531 if (shaderMaskSamplerLocation != -1) {
530 DCHECK(shaderMaskTexCoordScaleLocation != 1); 532 ASSERT(shaderMaskTexCoordScaleLocation != 1);
531 DCHECK(shaderMaskTexCoordOffsetLocation != 1); 533 ASSERT(shaderMaskTexCoordOffsetLocation != 1);
532 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE1)); 534 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE1));
533 GLC(context(), context()->uniform1i(shaderMaskSamplerLocation, 1)); 535 GLC(context(), context()->uniform1i(shaderMaskSamplerLocation, 1));
534 GLC(context(), context()->uniform2f(shaderMaskTexCoordScaleLocation, qua d->maskTexCoordScaleX(), quad->maskTexCoordScaleY())); 536 GLC(context(), context()->uniform2f(shaderMaskTexCoordScaleLocation, qua d->maskTexCoordScaleX(), quad->maskTexCoordScaleY()));
535 GLC(context(), context()->uniform2f(shaderMaskTexCoordOffsetLocation, qu ad->maskTexCoordOffsetX(), quad->maskTexCoordOffsetY())); 537 GLC(context(), context()->uniform2f(shaderMaskTexCoordOffsetLocation, qu ad->maskTexCoordOffsetX(), quad->maskTexCoordOffsetY()));
536 context()->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureId); 538 context()->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureId);
537 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0)); 539 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
538 } 540 }
539 541
540 if (shaderEdgeLocation != -1) { 542 if (shaderEdgeLocation != -1) {
541 float edge[24]; 543 float edge[24];
542 deviceLayerEdges.toFloatArray(edge); 544 deviceLayerEdges.toFloatArray(edge);
543 deviceLayerBounds.toFloatArray(&edge[12]); 545 deviceLayerBounds.toFloatArray(&edge[12]);
544 GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge)); 546 GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge));
545 } 547 }
546 548
547 // Map device space quad to surface space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to proje ct. 549 // Map device space quad to surface space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to proje ct.
548 FloatQuad surfaceQuad = CCMathUtil::mapQuad(contentsDeviceTransform.inverse( ), deviceLayerEdges.floatQuad(), clipped); 550 FloatQuad surfaceQuad = CCMathUtil::mapQuad(contentsDeviceTransform.inverse( ), deviceLayerEdges.floatQuad(), clipped);
549 DCHECK(!clipped); 551 ASSERT(!clipped);
550 552
551 setShaderOpacity(quad->opacity(), shaderAlphaLocation); 553 setShaderOpacity(quad->opacity(), shaderAlphaLocation);
552 setShaderFloatQuad(surfaceQuad, shaderQuadLocation); 554 setShaderFloatQuad(surfaceQuad, shaderQuadLocation);
553 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), shaderMatri xLocation); 555 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), shaderMatri xLocation);
554 } 556 }
555 557
556 void CCRendererGL::drawSolidColorQuad(const DrawingFrame& frame, const CCSolidCo lorDrawQuad* quad) 558 void CCRendererGL::drawSolidColorQuad(const DrawingFrame& frame, const CCSolidCo lorDrawQuad* quad)
557 { 559 {
558 const SolidColorProgram* program = solidColorProgram(); 560 const SolidColorProgram* program = solidColorProgram();
559 GLC(context(), context()->useProgram(program->program())); 561 GLC(context(), context()->useProgram(program->program()));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 float fragmentTexScaleY = clampRect.height() / textureSize.height(); 629 float fragmentTexScaleY = clampRect.height() / textureSize.height();
628 630
629 631
630 FloatQuad localQuad; 632 FloatQuad localQuad;
631 WebTransformationMatrix deviceTransform = WebTransformationMatrix(frame.wind owMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform(); 633 WebTransformationMatrix deviceTransform = WebTransformationMatrix(frame.wind owMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform();
632 if (!deviceTransform.isInvertible()) 634 if (!deviceTransform.isInvertible())
633 return; 635 return;
634 636
635 bool clipped = false; 637 bool clipped = false;
636 FloatQuad deviceLayerQuad = CCMathUtil::mapQuad(deviceTransform, FloatQuad(q uad->visibleContentRect()), clipped); 638 FloatQuad deviceLayerQuad = CCMathUtil::mapQuad(deviceTransform, FloatQuad(q uad->visibleContentRect()), clipped);
637 DCHECK(!clipped); 639 ASSERT(!clipped);
638 640
639 TileProgramUniforms uniforms; 641 TileProgramUniforms uniforms;
640 // For now, we simply skip anti-aliasing with the quad is clipped. This only happens 642 // For now, we simply skip anti-aliasing with the quad is clipped. This only happens
641 // on perspective transformed layers that go partially behind the camera. 643 // on perspective transformed layers that go partially behind the camera.
642 if (quad->isAntialiased() && !clipped) { 644 if (quad->isAntialiased() && !clipped) {
643 if (quad->swizzleContents()) 645 if (quad->swizzleContents())
644 tileUniformLocation(tileProgramSwizzleAA(), uniforms); 646 tileUniformLocation(tileProgramSwizzleAA(), uniforms);
645 else 647 else
646 tileUniformLocation(tileProgramAA(), uniforms); 648 tileUniformLocation(tileProgramAA(), uniforms);
647 } else { 649 } else {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation, vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); 684 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation, vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY));
683 GLC(context(), context()->uniform4f(uniforms.fragmentTexTransformLocatio n, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexS caleY)); 685 GLC(context(), context()->uniform4f(uniforms.fragmentTexTransformLocatio n, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexS caleY));
684 686
685 FloatPoint bottomRight(tileRect.maxX(), tileRect.maxY()); 687 FloatPoint bottomRight(tileRect.maxX(), tileRect.maxY());
686 FloatPoint bottomLeft(tileRect.x(), tileRect.maxY()); 688 FloatPoint bottomLeft(tileRect.x(), tileRect.maxY());
687 FloatPoint topLeft(tileRect.x(), tileRect.y()); 689 FloatPoint topLeft(tileRect.x(), tileRect.y());
688 FloatPoint topRight(tileRect.maxX(), tileRect.y()); 690 FloatPoint topRight(tileRect.maxX(), tileRect.y());
689 691
690 // Map points to device space. 692 // Map points to device space.
691 bottomRight = CCMathUtil::mapPoint(deviceTransform, bottomRight, clipped ); 693 bottomRight = CCMathUtil::mapPoint(deviceTransform, bottomRight, clipped );
692 DCHECK(!clipped); 694 ASSERT(!clipped);
693 bottomLeft = CCMathUtil::mapPoint(deviceTransform, bottomLeft, clipped); 695 bottomLeft = CCMathUtil::mapPoint(deviceTransform, bottomLeft, clipped);
694 DCHECK(!clipped); 696 ASSERT(!clipped);
695 topLeft = CCMathUtil::mapPoint(deviceTransform, topLeft, clipped); 697 topLeft = CCMathUtil::mapPoint(deviceTransform, topLeft, clipped);
696 DCHECK(!clipped); 698 ASSERT(!clipped);
697 topRight = CCMathUtil::mapPoint(deviceTransform, topRight, clipped); 699 topRight = CCMathUtil::mapPoint(deviceTransform, topRight, clipped);
698 DCHECK(!clipped); 700 ASSERT(!clipped);
699 701
700 CCLayerQuad::Edge bottomEdge(bottomRight, bottomLeft); 702 CCLayerQuad::Edge bottomEdge(bottomRight, bottomLeft);
701 CCLayerQuad::Edge leftEdge(bottomLeft, topLeft); 703 CCLayerQuad::Edge leftEdge(bottomLeft, topLeft);
702 CCLayerQuad::Edge topEdge(topLeft, topRight); 704 CCLayerQuad::Edge topEdge(topLeft, topRight);
703 CCLayerQuad::Edge rightEdge(topRight, bottomRight); 705 CCLayerQuad::Edge rightEdge(topRight, bottomRight);
704 706
705 // Only apply anti-aliasing to edges not clipped by culling or scissorin g. 707 // Only apply anti-aliasing to edges not clipped by culling or scissorin g.
706 if (quad->topEdgeAA() && tileRect.y() == quad->quadRect().y()) 708 if (quad->topEdgeAA() && tileRect.y() == quad->quadRect().y())
707 topEdge = deviceLayerEdges.top(); 709 topEdge = deviceLayerEdges.top();
708 if (quad->leftEdgeAA() && tileRect.x() == quad->quadRect().x()) 710 if (quad->leftEdgeAA() && tileRect.x() == quad->quadRect().x())
709 leftEdge = deviceLayerEdges.left(); 711 leftEdge = deviceLayerEdges.left();
710 if (quad->rightEdgeAA() && tileRect.maxX() == quad->quadRect().maxX()) 712 if (quad->rightEdgeAA() && tileRect.maxX() == quad->quadRect().maxX())
711 rightEdge = deviceLayerEdges.right(); 713 rightEdge = deviceLayerEdges.right();
712 if (quad->bottomEdgeAA() && tileRect.maxY() == quad->quadRect().maxY()) 714 if (quad->bottomEdgeAA() && tileRect.maxY() == quad->quadRect().maxY())
713 bottomEdge = deviceLayerEdges.bottom(); 715 bottomEdge = deviceLayerEdges.bottom();
714 716
715 float sign = FloatQuad(tileRect).isCounterclockwise() ? -1 : 1; 717 float sign = FloatQuad(tileRect).isCounterclockwise() ? -1 : 1;
716 bottomEdge.scale(sign); 718 bottomEdge.scale(sign);
717 leftEdge.scale(sign); 719 leftEdge.scale(sign);
718 topEdge.scale(sign); 720 topEdge.scale(sign);
719 rightEdge.scale(sign); 721 rightEdge.scale(sign);
720 722
721 // Create device space quad. 723 // Create device space quad.
722 CCLayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); 724 CCLayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge);
723 725
724 // Map device space quad to local space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to pro ject. 726 // Map device space quad to local space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to pro ject.
725 WebTransformationMatrix inverseDeviceTransform = deviceTransform.inverse (); 727 WebTransformationMatrix inverseDeviceTransform = deviceTransform.inverse ();
726 localQuad = CCMathUtil::mapQuad(inverseDeviceTransform, deviceQuad.float Quad(), clipped); 728 localQuad = CCMathUtil::mapQuad(inverseDeviceTransform, deviceQuad.float Quad(), clipped);
727 729
728 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become 730 // We should not ASSERT(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become
729 // clipped. To our knowledge this scenario does not need to be handled d ifferently than the unclipped case. 731 // clipped. To our knowledge this scenario does not need to be handled d ifferently than the unclipped case.
730 } else { 732 } else {
731 // Move fragment shader transform to vertex shader. We can do this while 733 // Move fragment shader transform to vertex shader. We can do this while
732 // still producing correct results as fragmentTexTransformLocation 734 // still producing correct results as fragmentTexTransformLocation
733 // should always be non-negative when tiles are transformed in a way 735 // should always be non-negative when tiles are transformed in a way
734 // that could result in sampling outside the layer. 736 // that could result in sampling outside the layer.
735 vertexTexScaleX *= fragmentTexScaleX; 737 vertexTexScaleX *= fragmentTexScaleX;
736 vertexTexScaleY *= fragmentTexScaleY; 738 vertexTexScaleY *= fragmentTexScaleY;
737 vertexTexTranslateX *= fragmentTexScaleX; 739 vertexTexTranslateX *= fragmentTexScaleX;
738 vertexTexTranslateY *= fragmentTexScaleY; 740 vertexTexTranslateY *= fragmentTexScaleY;
(...skipping 16 matching lines...) Expand all
755 // un-antialiased quad should have and which vertex this is and the float 757 // un-antialiased quad should have and which vertex this is and the float
756 // quad passed in via uniform is the actual geometry that gets used to draw 758 // quad passed in via uniform is the actual geometry that gets used to draw
757 // it. This is why this centered rect is used and not the original quadRect. 759 // it. This is why this centered rect is used and not the original quadRect.
758 FloatRect centeredRect(FloatPoint(-0.5 * tileRect.width(), -0.5 * tileRect.h eight()), tileRect.size()); 760 FloatRect centeredRect(FloatPoint(-0.5 * tileRect.width(), -0.5 * tileRect.h eight()), tileRect.size());
759 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix Location); 761 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix Location);
760 } 762 }
761 763
762 void CCRendererGL::drawYUVVideoQuad(const DrawingFrame& frame, const CCYUVVideoD rawQuad* quad) 764 void CCRendererGL::drawYUVVideoQuad(const DrawingFrame& frame, const CCYUVVideoD rawQuad* quad)
763 { 765 {
764 const VideoYUVProgram* program = videoYUVProgram(); 766 const VideoYUVProgram* program = videoYUVProgram();
765 DCHECK(program && program->initialized()); 767 ASSERT(program && program->initialized());
766 768
767 const CCVideoLayerImpl::FramePlane& yPlane = quad->yPlane(); 769 const CCVideoLayerImpl::FramePlane& yPlane = quad->yPlane();
768 const CCVideoLayerImpl::FramePlane& uPlane = quad->uPlane(); 770 const CCVideoLayerImpl::FramePlane& uPlane = quad->uPlane();
769 const CCVideoLayerImpl::FramePlane& vPlane = quad->vPlane(); 771 const CCVideoLayerImpl::FramePlane& vPlane = quad->vPlane();
770 772
771 CCResourceProvider::ScopedReadLockGL yPlaneLock(m_resourceProvider, yPlane.r esourceId); 773 CCResourceProvider::ScopedReadLockGL yPlaneLock(m_resourceProvider, yPlane.r esourceId);
772 CCResourceProvider::ScopedReadLockGL uPlaneLock(m_resourceProvider, uPlane.r esourceId); 774 CCResourceProvider::ScopedReadLockGL uPlaneLock(m_resourceProvider, uPlane.r esourceId);
773 CCResourceProvider::ScopedReadLockGL vPlaneLock(m_resourceProvider, vPlane.r esourceId); 775 CCResourceProvider::ScopedReadLockGL vPlaneLock(m_resourceProvider, vPlane.r esourceId);
774 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE1)); 776 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE1));
775 GLC(context(), context()->bindTexture(GraphicsContext3D::TEXTURE_2D, yPlaneL ock.textureId())); 777 GLC(context(), context()->bindTexture(GraphicsContext3D::TEXTURE_2D, yPlaneL ock.textureId()));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), program->ve rtexShader().matrixLocation()); 818 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), program->ve rtexShader().matrixLocation());
817 819
818 // Reset active texture back to texture 0. 820 // Reset active texture back to texture 0.
819 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0)); 821 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
820 } 822 }
821 823
822 void CCRendererGL::drawStreamVideoQuad(const DrawingFrame& frame, const CCStream VideoDrawQuad* quad) 824 void CCRendererGL::drawStreamVideoQuad(const DrawingFrame& frame, const CCStream VideoDrawQuad* quad)
823 { 825 {
824 static float glMatrix[16]; 826 static float glMatrix[16];
825 827
826 DCHECK(m_capabilities.usingEglImage); 828 ASSERT(m_capabilities.usingEglImage);
827 829
828 const VideoStreamTextureProgram* program = videoStreamTextureProgram(); 830 const VideoStreamTextureProgram* program = videoStreamTextureProgram();
829 GLC(context(), context()->useProgram(program->program())); 831 GLC(context(), context()->useProgram(program->program()));
830 832
831 toGLMatrix(&glMatrix[0], quad->matrix()); 833 toGLMatrix(&glMatrix[0], quad->matrix());
832 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().texMatrix Location(), 1, false, glMatrix)); 834 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().texMatrix Location(), 1, false, glMatrix));
833 835
834 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0)); 836 GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
835 GLC(context(), context()->bindTexture(Extensions3DChromium::GL_TEXTURE_EXTER NAL_OES, quad->textureId())); 837 GLC(context(), context()->bindTexture(Extensions3DChromium::GL_TEXTURE_EXTER NAL_OES, quad->textureId()));
836 838
837 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio n(), 0)); 839 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio n(), 0));
838 840
839 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ; 841 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ;
840 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), program->ve rtexShader().matrixLocation()); 842 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), program->ve rtexShader().matrixLocation());
841 } 843 }
842 844
843 struct TextureProgramBinding { 845 struct TextureProgramBinding {
844 template<class Program> void set(Program* program) 846 template<class Program> void set(Program* program)
845 { 847 {
846 DCHECK(program && program->initialized()); 848 ASSERT(program && program->initialized());
847 programId = program->program(); 849 programId = program->program();
848 samplerLocation = program->fragmentShader().samplerLocation(); 850 samplerLocation = program->fragmentShader().samplerLocation();
849 matrixLocation = program->vertexShader().matrixLocation(); 851 matrixLocation = program->vertexShader().matrixLocation();
850 alphaLocation = program->fragmentShader().alphaLocation(); 852 alphaLocation = program->fragmentShader().alphaLocation();
851 } 853 }
852 int programId; 854 int programId;
853 int samplerLocation; 855 int samplerLocation;
854 int matrixLocation; 856 int matrixLocation;
855 int alphaLocation; 857 int alphaLocation;
856 }; 858 };
857 859
858 struct TexTransformTextureProgramBinding : TextureProgramBinding { 860 struct TexTransformTextureProgramBinding : TextureProgramBinding {
859 template<class Program> void set(Program* program) 861 template<class Program> void set(Program* program)
860 { 862 {
861 TextureProgramBinding::set(program); 863 TextureProgramBinding::set(program);
862 texTransformLocation = program->vertexShader().texTransformLocation(); 864 texTransformLocation = program->vertexShader().texTransformLocation();
863 } 865 }
864 int texTransformLocation; 866 int texTransformLocation;
865 }; 867 };
866 868
867 void CCRendererGL::drawTextureQuad(const DrawingFrame& frame, const CCTextureDra wQuad* quad) 869 void CCRendererGL::drawTextureQuad(const DrawingFrame& frame, const CCTextureDra wQuad* quad)
868 { 870 {
869 DCHECK(CCProxy::isImplThread()); 871 ASSERT(CCProxy::isImplThread());
870 872
871 TexTransformTextureProgramBinding binding; 873 TexTransformTextureProgramBinding binding;
872 if (quad->flipped()) 874 if (quad->flipped())
873 binding.set(textureProgramFlip()); 875 binding.set(textureProgramFlip());
874 else 876 else
875 binding.set(textureProgram()); 877 binding.set(textureProgram());
876 GLC(context(), context()->useProgram(binding.programId)); 878 GLC(context(), context()->useProgram(binding.programId));
877 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 879 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
878 const FloatRect& uvRect = quad->uvRect(); 880 const FloatRect& uvRect = quad->uvRect();
879 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); 881 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height()));
(...skipping 23 matching lines...) Expand all
903 905
904 setShaderOpacity(quad->opacity(), binding.alphaLocation); 906 setShaderOpacity(quad->opacity(), binding.alphaLocation);
905 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation); 907 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation);
906 908
907 if (!quad->premultipliedAlpha()) 909 if (!quad->premultipliedAlpha())
908 GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsCont ext3D::ONE_MINUS_SRC_ALPHA)); 910 GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsCont ext3D::ONE_MINUS_SRC_ALPHA));
909 } 911 }
910 912
911 void CCRendererGL::drawIOSurfaceQuad(const DrawingFrame& frame, const CCIOSurfac eDrawQuad* quad) 913 void CCRendererGL::drawIOSurfaceQuad(const DrawingFrame& frame, const CCIOSurfac eDrawQuad* quad)
912 { 914 {
913 DCHECK(CCProxy::isImplThread()); 915 ASSERT(CCProxy::isImplThread());
914 TexTransformTextureProgramBinding binding; 916 TexTransformTextureProgramBinding binding;
915 binding.set(textureIOSurfaceProgram()); 917 binding.set(textureIOSurfaceProgram());
916 918
917 GLC(context(), context()->useProgram(binding.programId)); 919 GLC(context(), context()->useProgram(binding.programId));
918 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 920 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
919 if (quad->orientation() == CCIOSurfaceDrawQuad::Flipped) 921 if (quad->orientation() == CCIOSurfaceDrawQuad::Flipped)
920 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0)); 922 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0));
921 else 923 else
922 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height())); 924 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height()));
923 925
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 } 1018 }
1017 1019
1018 void CCRendererGL::finish() 1020 void CCRendererGL::finish()
1019 { 1021 {
1020 TRACE_EVENT0("cc", "CCRendererGL::finish"); 1022 TRACE_EVENT0("cc", "CCRendererGL::finish");
1021 m_context->finish(); 1023 m_context->finish();
1022 } 1024 }
1023 1025
1024 bool CCRendererGL::swapBuffers() 1026 bool CCRendererGL::swapBuffers()
1025 { 1027 {
1026 DCHECK(m_visible); 1028 ASSERT(m_visible);
1027 DCHECK(!m_isFramebufferDiscarded); 1029 ASSERT(!m_isFramebufferDiscarded);
1028 1030
1029 TRACE_EVENT0("cc", "CCRendererGL::swapBuffers"); 1031 TRACE_EVENT0("cc", "CCRendererGL::swapBuffers");
1030 // We're done! Time to swapbuffers! 1032 // We're done! Time to swapbuffers!
1031 1033
1032 if (m_capabilities.usingPartialSwap) { 1034 if (m_capabilities.usingPartialSwap) {
1033 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) 1035 // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport)
1034 m_swapBufferRect.intersect(IntRect(IntPoint(), viewportSize())); 1036 m_swapBufferRect.intersect(IntRect(IntPoint(), viewportSize()));
1035 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height(); 1037 int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height();
1036 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height()); 1038 m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRect Bottom, m_swapBufferRect.width(), m_swapBufferRect.height());
1037 } else { 1039 } else {
1038 // Note that currently this has the same effect as swapBuffers; we shoul d 1040 // Note that currently this has the same effect as swapBuffers; we shoul d
1039 // consider exposing a different entry point on WebGraphicsContext3D. 1041 // consider exposing a different entry point on WebGraphicsContext3D.
1040 m_context->prepareTexture(); 1042 m_context->prepareTexture();
1041 } 1043 }
1042 1044
1043 m_swapBufferRect = IntRect(); 1045 m_swapBufferRect = IntRect();
1044 1046
1045 return true; 1047 return true;
1046 } 1048 }
1047 1049
1048 void CCRendererGL::onSwapBuffersComplete() 1050 void CCRendererGL::onSwapBuffersComplete()
1049 { 1051 {
1050 m_client->onSwapBuffersComplete(); 1052 m_client->onSwapBuffersComplete();
1051 } 1053 }
1052 1054
1053 void CCRendererGL::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocat ion) 1055 void CCRendererGL::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocat ion)
1054 { 1056 {
1055 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. 1057 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread.
1056 if (!CCProxy::hasImplThread()) { 1058 if (!CCProxy::hasImplThread()) {
1057 DCHECK(CCProxy::isMainThread()); 1059 ASSERT(CCProxy::isMainThread());
1058 DebugScopedSetImplThread impl; 1060 DebugScopedSetImplThread impl;
1059 onMemoryAllocationChangedOnImplThread(allocation); 1061 onMemoryAllocationChangedOnImplThread(allocation);
1060 } else { 1062 } else {
1061 DCHECK(CCProxy::isImplThread()); 1063 ASSERT(CCProxy::isImplThread());
1062 onMemoryAllocationChangedOnImplThread(allocation); 1064 onMemoryAllocationChangedOnImplThread(allocation);
1063 } 1065 }
1064 } 1066 }
1065 1067
1066 void CCRendererGL::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemo ryAllocation allocation) 1068 void CCRendererGL::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemo ryAllocation allocation)
1067 { 1069 {
1068 if (m_visible && !allocation.gpuResourceSizeInBytes) 1070 if (m_visible && !allocation.gpuResourceSizeInBytes)
1069 return; 1071 return;
1070 1072
1071 if (!allocation.suggestHaveBackbuffer && !m_visible) 1073 if (!allocation.suggestHaveBackbuffer && !m_visible)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 } 1110 }
1109 1111
1110 void CCRendererGL::onContextLost() 1112 void CCRendererGL::onContextLost()
1111 { 1113 {
1112 m_client->didLoseContext(); 1114 m_client->didLoseContext();
1113 } 1115 }
1114 1116
1115 1117
1116 void CCRendererGL::getFramebufferPixels(void *pixels, const IntRect& rect) 1118 void CCRendererGL::getFramebufferPixels(void *pixels, const IntRect& rect)
1117 { 1119 {
1118 DCHECK(rect.maxX() <= viewportWidth()); 1120 ASSERT(rect.maxX() <= viewportWidth() && rect.maxY() <= viewportHeight());
1119 DCHECK(rect.maxY() <= viewportHeight());
1120 1121
1121 if (!pixels) 1122 if (!pixels)
1122 return; 1123 return;
1123 1124
1124 makeContextCurrent(); 1125 makeContextCurrent();
1125 1126
1126 bool doWorkaround = needsIOSurfaceReadbackWorkaround(); 1127 bool doWorkaround = needsIOSurfaceReadbackWorkaround();
1127 1128
1128 Platform3DObject temporaryTexture = 0; 1129 Platform3DObject temporaryTexture = 0;
1129 Platform3DObject temporaryFBO = 0; 1130 Platform3DObject temporaryFBO = 0;
(...skipping 10 matching lines...) Expand all
1140 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, G raphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); 1141 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, G raphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
1141 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, G raphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); 1142 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, G raphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
1142 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, G raphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); 1143 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, G raphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
1143 // Copy the contents of the current (IOSurface-backed) framebuffer into a temporary texture. 1144 // Copy the contents of the current (IOSurface-backed) framebuffer into a temporary texture.
1144 GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, viewportSize().width(), viewportSize().height( ), 0)); 1145 GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, viewportSize().width(), viewportSize().height( ), 0));
1145 temporaryFBO = m_context->createFramebuffer(); 1146 temporaryFBO = m_context->createFramebuffer();
1146 // Attach this texture to an FBO, and perform the readback from that FBO . 1147 // Attach this texture to an FBO, and perform the readback from that FBO .
1147 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER , temporaryFBO)); 1148 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER , temporaryFBO));
1148 GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEB UFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, temp oraryTexture, 0)); 1149 GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEB UFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, temp oraryTexture, 0));
1149 1150
1150 DCHECK(m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); 1151 ASSERT(m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE);
1151 } 1152 }
1152 1153
1153 scoped_array<uint8_t> srcPixels(new uint8_t[rect.width() * rect.height() * 4 ]); 1154 scoped_array<uint8_t> srcPixels(new uint8_t[rect.width() * rect.height() * 4 ]);
1154 GLC(m_context, m_context->readPixels(rect.x(), viewportSize().height() - rec t.maxY(), rect.width(), rect.height(), 1155 GLC(m_context, m_context->readPixels(rect.x(), viewportSize().height() - rec t.maxY(), rect.width(), rect.height(),
1155 GraphicsContext3D::RGBA, GraphicsContext3D: :UNSIGNED_BYTE, srcPixels.get())); 1156 GraphicsContext3D::RGBA, GraphicsContext3D: :UNSIGNED_BYTE, srcPixels.get()));
1156 1157
1157 uint8_t* destPixels = static_cast<uint8_t*>(pixels); 1158 uint8_t* destPixels = static_cast<uint8_t*>(pixels);
1158 size_t rowBytes = rect.width() * 4; 1159 size_t rowBytes = rect.width() * 4;
1159 int numRows = rect.height(); 1160 int numRows = rect.height();
1160 size_t totalBytes = numRows * rowBytes; 1161 size_t totalBytes = numRows * rowBytes;
(...skipping 21 matching lines...) Expand all
1182 TRACE_EVENT0("cc", "CCRendererGL::getFramebufferPixels dropping resource s after readback"); 1183 TRACE_EVENT0("cc", "CCRendererGL::getFramebufferPixels dropping resource s after readback");
1183 discardFramebuffer(); 1184 discardFramebuffer();
1184 releaseRenderPassTextures(); 1185 releaseRenderPassTextures();
1185 m_client->releaseContentsTextures(); 1186 m_client->releaseContentsTextures();
1186 GLC(m_context, m_context->flush()); 1187 GLC(m_context, m_context->flush());
1187 } 1188 }
1188 } 1189 }
1189 1190
1190 bool CCRendererGL::getFramebufferTexture(CCScopedTexture* texture, const IntRect & deviceRect) 1191 bool CCRendererGL::getFramebufferTexture(CCScopedTexture* texture, const IntRect & deviceRect)
1191 { 1192 {
1192 DCHECK(!texture->id() || (texture->size() == deviceRect.size() && texture->f ormat() == GraphicsContext3D::RGB)); 1193 ASSERT(!texture->id() || (texture->size() == deviceRect.size() && texture->f ormat() == GraphicsContext3D::RGB));
1193 1194
1194 if (!texture->id() && !texture->allocate(CCRenderer::ImplPool, deviceRect.si ze(), GraphicsContext3D::RGB, CCResourceProvider::TextureUsageAny)) 1195 if (!texture->id() && !texture->allocate(CCRenderer::ImplPool, deviceRect.si ze(), GraphicsContext3D::RGB, CCResourceProvider::TextureUsageAny))
1195 return false; 1196 return false;
1196 1197
1197 CCResourceProvider::ScopedWriteLockGL lock(m_resourceProvider, texture->id() ); 1198 CCResourceProvider::ScopedWriteLockGL lock(m_resourceProvider, texture->id() );
1198 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, lock.te xtureId())); 1199 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, lock.te xtureId()));
1199 GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, t exture->format(), 1200 GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, t exture->format(),
1200 deviceRect.x(), deviceRect.y(), dev iceRect.width(), deviceRect.height(), 0)); 1201 deviceRect.x(), deviceRect.y(), dev iceRect.width(), deviceRect.height(), 0));
1201 return true; 1202 return true;
1202 } 1203 }
1203 1204
1204 bool CCRendererGL::useScopedTexture(DrawingFrame& frame, const CCScopedTexture* texture, const IntRect& viewportRect) 1205 bool CCRendererGL::useScopedTexture(DrawingFrame& frame, const CCScopedTexture* texture, const IntRect& viewportRect)
1205 { 1206 {
1206 DCHECK(texture->id()); 1207 ASSERT(texture->id());
1207 frame.currentRenderPass = 0; 1208 frame.currentRenderPass = 0;
1208 frame.currentTexture = texture; 1209 frame.currentTexture = texture;
1209 1210
1210 return bindFramebufferToTexture(frame, texture, viewportRect); 1211 return bindFramebufferToTexture(frame, texture, viewportRect);
1211 } 1212 }
1212 1213
1213 void CCRendererGL::bindFramebufferToOutputSurface(DrawingFrame& frame) 1214 void CCRendererGL::bindFramebufferToOutputSurface(DrawingFrame& frame)
1214 { 1215 {
1215 m_currentFramebufferLock.reset(); 1216 m_currentFramebufferLock.reset();
1216 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0) ); 1217 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0) );
1217 } 1218 }
1218 1219
1219 bool CCRendererGL::bindFramebufferToTexture(DrawingFrame& frame, const CCScopedT exture* texture, const IntRect& framebufferRect) 1220 bool CCRendererGL::bindFramebufferToTexture(DrawingFrame& frame, const CCScopedT exture* texture, const IntRect& framebufferRect)
1220 { 1221 {
1221 DCHECK(texture->id()); 1222 ASSERT(texture->id());
1222 1223
1223 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_ offscreenFramebufferId)); 1224 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_ offscreenFramebufferId));
1224 m_currentFramebufferLock = make_scoped_ptr(new CCResourceProvider::ScopedWri teLockGL(m_resourceProvider, texture->id())); 1225 m_currentFramebufferLock = make_scoped_ptr(new CCResourceProvider::ScopedWri teLockGL(m_resourceProvider, texture->id()));
1225 unsigned textureId = m_currentFramebufferLock->textureId(); 1226 unsigned textureId = m_currentFramebufferLock->textureId();
1226 GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFE R, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, textureI d, 0)); 1227 GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFE R, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, textureI d, 0));
1227 1228
1228 DCHECK(m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); 1229 #if !defined ( NDEBUG )
1230 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != Gra phicsContext3D::FRAMEBUFFER_COMPLETE) {
1231 ASSERT_NOT_REACHED();
1232 return false;
1233 }
1234 #endif
1229 1235
1230 initializeMatrices(frame, framebufferRect, false); 1236 initializeMatrices(frame, framebufferRect, false);
1231 setDrawViewportSize(framebufferRect.size()); 1237 setDrawViewportSize(framebufferRect.size());
1232 1238
1233 return true; 1239 return true;
1234 } 1240 }
1235 1241
1236 void CCRendererGL::enableScissorTestRect(const IntRect& scissorRect) 1242 void CCRendererGL::enableScissorTestRect(const IntRect& scissorRect)
1237 { 1243 {
1238 GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST)); 1244 GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 m_solidColorProgram = make_scoped_ptr(new SolidColorProgram(m_context)); 1297 m_solidColorProgram = make_scoped_ptr(new SolidColorProgram(m_context));
1292 if (!m_solidColorProgram->initialized()) { 1298 if (!m_solidColorProgram->initialized()) {
1293 TRACE_EVENT0("cc", "CCRendererGL::solidColorProgram::initialize"); 1299 TRACE_EVENT0("cc", "CCRendererGL::solidColorProgram::initialize");
1294 m_solidColorProgram->initialize(m_context, m_isUsingBindUniform); 1300 m_solidColorProgram->initialize(m_context, m_isUsingBindUniform);
1295 } 1301 }
1296 return m_solidColorProgram.get(); 1302 return m_solidColorProgram.get();
1297 } 1303 }
1298 1304
1299 const CCRendererGL::RenderPassProgram* CCRendererGL::renderPassProgram() 1305 const CCRendererGL::RenderPassProgram* CCRendererGL::renderPassProgram()
1300 { 1306 {
1301 DCHECK(m_renderPassProgram); 1307 ASSERT(m_renderPassProgram);
1302 if (!m_renderPassProgram->initialized()) { 1308 if (!m_renderPassProgram->initialized()) {
1303 TRACE_EVENT0("cc", "CCRendererGL::renderPassProgram::initialize"); 1309 TRACE_EVENT0("cc", "CCRendererGL::renderPassProgram::initialize");
1304 m_renderPassProgram->initialize(m_context, m_isUsingBindUniform); 1310 m_renderPassProgram->initialize(m_context, m_isUsingBindUniform);
1305 } 1311 }
1306 return m_renderPassProgram.get(); 1312 return m_renderPassProgram.get();
1307 } 1313 }
1308 1314
1309 const CCRendererGL::RenderPassProgramAA* CCRendererGL::renderPassProgramAA() 1315 const CCRendererGL::RenderPassProgramAA* CCRendererGL::renderPassProgramAA()
1310 { 1316 {
1311 if (!m_renderPassProgramAA) 1317 if (!m_renderPassProgramAA)
(...skipping 22 matching lines...) Expand all
1334 m_renderPassMaskProgramAA = make_scoped_ptr(new RenderPassMaskProgramAA( m_context)); 1340 m_renderPassMaskProgramAA = make_scoped_ptr(new RenderPassMaskProgramAA( m_context));
1335 if (!m_renderPassMaskProgramAA->initialized()) { 1341 if (!m_renderPassMaskProgramAA->initialized()) {
1336 TRACE_EVENT0("cc", "CCRendererGL::renderPassMaskProgramAA::initialize"); 1342 TRACE_EVENT0("cc", "CCRendererGL::renderPassMaskProgramAA::initialize");
1337 m_renderPassMaskProgramAA->initialize(m_context, m_isUsingBindUniform); 1343 m_renderPassMaskProgramAA->initialize(m_context, m_isUsingBindUniform);
1338 } 1344 }
1339 return m_renderPassMaskProgramAA.get(); 1345 return m_renderPassMaskProgramAA.get();
1340 } 1346 }
1341 1347
1342 const CCRendererGL::TileProgram* CCRendererGL::tileProgram() 1348 const CCRendererGL::TileProgram* CCRendererGL::tileProgram()
1343 { 1349 {
1344 DCHECK(m_tileProgram); 1350 ASSERT(m_tileProgram);
1345 if (!m_tileProgram->initialized()) { 1351 if (!m_tileProgram->initialized()) {
1346 TRACE_EVENT0("cc", "CCRendererGL::tileProgram::initialize"); 1352 TRACE_EVENT0("cc", "CCRendererGL::tileProgram::initialize");
1347 m_tileProgram->initialize(m_context, m_isUsingBindUniform); 1353 m_tileProgram->initialize(m_context, m_isUsingBindUniform);
1348 } 1354 }
1349 return m_tileProgram.get(); 1355 return m_tileProgram.get();
1350 } 1356 }
1351 1357
1352 const CCRendererGL::TileProgramOpaque* CCRendererGL::tileProgramOpaque() 1358 const CCRendererGL::TileProgramOpaque* CCRendererGL::tileProgramOpaque()
1353 { 1359 {
1354 DCHECK(m_tileProgramOpaque); 1360 ASSERT(m_tileProgramOpaque);
1355 if (!m_tileProgramOpaque->initialized()) { 1361 if (!m_tileProgramOpaque->initialized()) {
1356 TRACE_EVENT0("cc", "CCRendererGL::tileProgramOpaque::initialize"); 1362 TRACE_EVENT0("cc", "CCRendererGL::tileProgramOpaque::initialize");
1357 m_tileProgramOpaque->initialize(m_context, m_isUsingBindUniform); 1363 m_tileProgramOpaque->initialize(m_context, m_isUsingBindUniform);
1358 } 1364 }
1359 return m_tileProgramOpaque.get(); 1365 return m_tileProgramOpaque.get();
1360 } 1366 }
1361 1367
1362 const CCRendererGL::TileProgramAA* CCRendererGL::tileProgramAA() 1368 const CCRendererGL::TileProgramAA* CCRendererGL::tileProgramAA()
1363 { 1369 {
1364 if (!m_tileProgramAA) 1370 if (!m_tileProgramAA)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 1514
1509 releaseRenderPassTextures(); 1515 releaseRenderPassTextures();
1510 } 1516 }
1511 1517
1512 bool CCRendererGL::isContextLost() 1518 bool CCRendererGL::isContextLost()
1513 { 1519 {
1514 return (m_context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERRO R); 1520 return (m_context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERRO R);
1515 } 1521 }
1516 1522
1517 } // namespace cc 1523 } // namespace cc
OLDNEW
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698