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