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

Side by Side Diff: cc/gl_renderer.cc

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