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

Side by Side Diff: cc/gl_renderer.cc

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

Powered by Google App Engine
This is Rietveld 408576698