| 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 "ThrottledTextureUploader.h" | |
| 30 #include "TraceEvent.h" | 29 #include "TraceEvent.h" |
| 31 #include "UnthrottledTextureUploader.h" | |
| 32 #ifdef LOG | 30 #ifdef LOG |
| 33 #undef LOG | 31 #undef LOG |
| 34 #endif | 32 #endif |
| 35 #include "base/string_split.h" | 33 #include "base/string_split.h" |
| 36 #include "base/string_util.h" | 34 #include "base/string_util.h" |
| 37 #include <public/WebGraphicsContext3D.h> | 35 #include <public/WebGraphicsContext3D.h> |
| 38 #include <public/WebSharedGraphicsContext3D.h> | 36 #include <public/WebSharedGraphicsContext3D.h> |
| 39 #include <public/WebVideoFrame.h> | 37 #include <public/WebVideoFrame.h> |
| 40 #include <set> | 38 #include <set> |
| 41 #include <string> | 39 #include <string> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 { | 55 { |
| 58 #if OS(DARWIN) | 56 #if OS(DARWIN) |
| 59 return true; | 57 return true; |
| 60 #else | 58 #else |
| 61 return false; | 59 return false; |
| 62 #endif | 60 #endif |
| 63 } | 61 } |
| 64 | 62 |
| 65 } // anonymous namespace | 63 } // anonymous namespace |
| 66 | 64 |
| 67 PassOwnPtr<CCRendererGL> CCRendererGL::create(CCRendererClient* client, CCResour
ceProvider* resourceProvider, TextureUploaderOption textureUploaderSetting) | 65 PassOwnPtr<CCRendererGL> CCRendererGL::create(CCRendererClient* client, CCResour
ceProvider* resourceProvider) |
| 68 { | 66 { |
| 69 OwnPtr<CCRendererGL> renderer(adoptPtr(new CCRendererGL(client, resourceProv
ider, textureUploaderSetting))); | 67 OwnPtr<CCRendererGL> renderer(adoptPtr(new CCRendererGL(client, resourceProv
ider))); |
| 70 if (!renderer->initialize()) | 68 if (!renderer->initialize()) |
| 71 return nullptr; | 69 return nullptr; |
| 72 | 70 |
| 73 return renderer.release(); | 71 return renderer.release(); |
| 74 } | 72 } |
| 75 | 73 |
| 76 CCRendererGL::CCRendererGL(CCRendererClient* client, | 74 CCRendererGL::CCRendererGL(CCRendererClient* client, |
| 77 CCResourceProvider* resourceProvide
r, | 75 CCResourceProvider* resourceProvider) |
| 78 TextureUploaderOption textureUpload
erSetting) | |
| 79 : CCDirectRenderer(client, resourceProvider) | 76 : CCDirectRenderer(client, resourceProvider) |
| 80 , m_offscreenFramebufferId(0) | 77 , m_offscreenFramebufferId(0) |
| 81 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) | 78 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) |
| 82 , m_context(resourceProvider->graphicsContext3D()) | 79 , m_context(resourceProvider->graphicsContext3D()) |
| 83 , m_isViewportChanged(false) | 80 , m_isViewportChanged(false) |
| 84 , m_isFramebufferDiscarded(false) | 81 , m_isFramebufferDiscarded(false) |
| 85 , m_isUsingBindUniform(false) | 82 , m_isUsingBindUniform(false) |
| 86 , m_visible(true) | 83 , m_visible(true) |
| 87 , m_textureUploaderSetting(textureUploaderSetting) | |
| 88 { | 84 { |
| 89 ASSERT(m_context); | 85 ASSERT(m_context); |
| 90 } | 86 } |
| 91 | 87 |
| 92 bool CCRendererGL::initialize() | 88 bool CCRendererGL::initialize() |
| 93 { | 89 { |
| 94 if (!m_context->makeContextCurrent()) | 90 if (!m_context->makeContextCurrent()) |
| 95 return false; | 91 return false; |
| 96 | 92 |
| 97 m_context->setContextLostCallback(this); | 93 m_context->setContextLostCallback(this); |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 | 1262 |
| 1267 // We will always need these programs to render, so create the programs eage
rly so that the shader compilation can | 1263 // We will always need these programs to render, so create the programs eage
rly so that the shader compilation can |
| 1268 // start while we do other work. Other programs are created lazily on first
access. | 1264 // start while we do other work. Other programs are created lazily on first
access. |
| 1269 m_sharedGeometry = adoptPtr(new GeometryBinding(m_context, quadVertexRect())
); | 1265 m_sharedGeometry = adoptPtr(new GeometryBinding(m_context, quadVertexRect())
); |
| 1270 m_renderPassProgram = adoptPtr(new RenderPassProgram(m_context)); | 1266 m_renderPassProgram = adoptPtr(new RenderPassProgram(m_context)); |
| 1271 m_tileProgram = adoptPtr(new TileProgram(m_context)); | 1267 m_tileProgram = adoptPtr(new TileProgram(m_context)); |
| 1272 m_tileProgramOpaque = adoptPtr(new TileProgramOpaque(m_context)); | 1268 m_tileProgramOpaque = adoptPtr(new TileProgramOpaque(m_context)); |
| 1273 | 1269 |
| 1274 GLC(m_context, m_context->flush()); | 1270 GLC(m_context, m_context->flush()); |
| 1275 | 1271 |
| 1276 m_textureCopier = AcceleratedTextureCopier::create(m_context, m_isUsingBindU
niform); | |
| 1277 if (m_textureUploaderSetting == ThrottledUploader) | |
| 1278 m_textureUploader = ThrottledTextureUploader::create(m_context); | |
| 1279 else | |
| 1280 m_textureUploader = UnthrottledTextureUploader::create(); | |
| 1281 | |
| 1282 return true; | 1272 return true; |
| 1283 } | 1273 } |
| 1284 | 1274 |
| 1285 const CCRendererGL::TileCheckerboardProgram* CCRendererGL::tileCheckerboardProgr
am() | 1275 const CCRendererGL::TileCheckerboardProgram* CCRendererGL::tileCheckerboardProgr
am() |
| 1286 { | 1276 { |
| 1287 if (!m_tileCheckerboardProgram) | 1277 if (!m_tileCheckerboardProgram) |
| 1288 m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_conte
xt)); | 1278 m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_conte
xt)); |
| 1289 if (!m_tileCheckerboardProgram->initialized()) { | 1279 if (!m_tileCheckerboardProgram->initialized()) { |
| 1290 TRACE_EVENT0("cc", "CCRendererGL::checkerboardProgram::initalize"); | 1280 TRACE_EVENT0("cc", "CCRendererGL::checkerboardProgram::initalize"); |
| 1291 m_tileCheckerboardProgram->initialize(m_context, m_isUsingBindUniform); | 1281 m_tileCheckerboardProgram->initialize(m_context, m_isUsingBindUniform); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 m_videoYUVProgram->cleanup(m_context); | 1497 m_videoYUVProgram->cleanup(m_context); |
| 1508 if (m_videoStreamTextureProgram) | 1498 if (m_videoStreamTextureProgram) |
| 1509 m_videoStreamTextureProgram->cleanup(m_context); | 1499 m_videoStreamTextureProgram->cleanup(m_context); |
| 1510 | 1500 |
| 1511 if (m_solidColorProgram) | 1501 if (m_solidColorProgram) |
| 1512 m_solidColorProgram->cleanup(m_context); | 1502 m_solidColorProgram->cleanup(m_context); |
| 1513 | 1503 |
| 1514 if (m_offscreenFramebufferId) | 1504 if (m_offscreenFramebufferId) |
| 1515 GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId)); | 1505 GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId)); |
| 1516 | 1506 |
| 1517 m_textureCopier.clear(); | |
| 1518 m_textureUploader.clear(); | |
| 1519 | |
| 1520 releaseRenderPassTextures(); | 1507 releaseRenderPassTextures(); |
| 1521 } | 1508 } |
| 1522 | 1509 |
| 1523 bool CCRendererGL::isContextLost() | 1510 bool CCRendererGL::isContextLost() |
| 1524 { | 1511 { |
| 1525 return (m_context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERRO
R); | 1512 return (m_context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERRO
R); |
| 1526 } | 1513 } |
| 1527 | 1514 |
| 1528 } // namespace cc | 1515 } // namespace cc |
| 1529 | 1516 |
| 1530 #endif // USE(ACCELERATED_COMPOSITING) | 1517 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |