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