Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "CCResourceProvider.h" | 7 #include "CCResourceProvider.h" |
| 8 #ifdef LOG | 8 #ifdef LOG |
| 9 #undef LOG | 9 #undef LOG |
| 10 #endif | 10 #endif |
| 11 | 11 |
| 12 #include <limits.h> | |
| 13 | |
| 14 #include "base/string_split.h" | 12 #include "base/string_split.h" |
| 15 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 16 #include "CCProxy.h" | 14 #include "CCProxy.h" |
| 17 #include "CCRendererGL.h" // For the GLC() macro. | 15 #include "CCRendererGL.h" // For the GLC() macro. |
| 18 #include "Extensions3DChromium.h" | 16 #include "Extensions3DChromium.h" |
| 19 #include "IntRect.h" | 17 #include "IntRect.h" |
| 20 #include "LayerTextureSubImage.h" | 18 #include "LayerTextureSubImage.h" |
| 21 #include "ThrottledTextureUploader.h" | 19 #include "ThrottledTextureUploader.h" |
| 22 #include "UnthrottledTextureUploader.h" | 20 #include <limits> |
| 23 #include <public/WebGraphicsContext3D.h> | 21 #include <public/WebGraphicsContext3D.h> |
| 24 #include <wtf/HashSet.h> | 22 #include <wtf/HashSet.h> |
| 25 | 23 |
| 26 using WebKit::WebGraphicsContext3D; | 24 using WebKit::WebGraphicsContext3D; |
| 27 | 25 |
| 28 namespace cc { | 26 namespace cc { |
| 29 | 27 |
| 30 static GC3Denum textureToStorageFormat(GC3Denum textureFormat) | 28 static GC3Denum textureToStorageFormat(GC3Denum textureFormat) |
| 31 { | 29 { |
| 32 GC3Denum storageFormat = Extensions3D::RGBA8_OES; | 30 GC3Denum storageFormat = Extensions3D::RGBA8_OES; |
| 33 switch (textureFormat) { | 31 switch (textureFormat) { |
| 34 case GraphicsContext3D::RGBA: | 32 case GraphicsContext3D::RGBA: |
| 35 break; | 33 break; |
| 36 case Extensions3D::BGRA_EXT: | 34 case Extensions3D::BGRA_EXT: |
| 37 storageFormat = Extensions3DChromium::BGRA8_EXT; | 35 storageFormat = Extensions3DChromium::BGRA8_EXT; |
| 38 break; | 36 break; |
| 39 default: | 37 default: |
| 40 ASSERT_NOT_REACHED(); | 38 ASSERT_NOT_REACHED(); |
| 41 break; | 39 break; |
| 42 } | 40 } |
| 43 | 41 |
| 44 return storageFormat; | 42 return storageFormat; |
| 45 } | 43 } |
| 46 | 44 |
| 47 static bool isTextureFormatSupportedForStorage(GC3Denum format) | 45 static bool isTextureFormatSupportedForStorage(GC3Denum format) |
| 48 { | 46 { |
| 49 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX T); | 47 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX T); |
| 50 } | 48 } |
| 51 | 49 |
| 52 PassOwnPtr<CCResourceProvider> CCResourceProvider::create(CCGraphicsContext* con text, TextureUploaderOption option) | 50 PassOwnPtr<CCResourceProvider> CCResourceProvider::create(CCGraphicsContext* con text) |
| 53 { | 51 { |
| 54 OwnPtr<CCResourceProvider> resourceProvider(adoptPtr(new CCResourceProvider( context))); | 52 OwnPtr<CCResourceProvider> resourceProvider(adoptPtr(new CCResourceProvider( context))); |
| 55 if (!resourceProvider->initialize(option)) | 53 if (!resourceProvider->initialize()) |
| 56 return nullptr; | 54 return nullptr; |
| 57 return resourceProvider.release(); | 55 return resourceProvider.release(); |
| 58 } | 56 } |
| 59 | 57 |
| 60 CCResourceProvider::~CCResourceProvider() | 58 CCResourceProvider::~CCResourceProvider() |
| 61 { | 59 { |
| 62 WebGraphicsContext3D* context3d = m_context->context3D(); | 60 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 63 if (!context3d || !context3d->makeContextCurrent()) | 61 if (!context3d || !context3d->makeContextCurrent()) |
| 64 return; | 62 return; |
| 65 m_textureUploader.clear(); | 63 m_textureUploader.clear(); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 } | 376 } |
| 379 | 377 |
| 380 CCResourceProvider::CCResourceProvider(CCGraphicsContext* context) | 378 CCResourceProvider::CCResourceProvider(CCGraphicsContext* context) |
| 381 : m_context(context) | 379 : m_context(context) |
| 382 , m_nextId(1) | 380 , m_nextId(1) |
| 383 , m_nextChild(1) | 381 , m_nextChild(1) |
| 384 , m_defaultResourceType(GLTexture) | 382 , m_defaultResourceType(GLTexture) |
| 385 , m_useTextureStorageExt(false) | 383 , m_useTextureStorageExt(false) |
| 386 , m_useTextureUsageHint(false) | 384 , m_useTextureUsageHint(false) |
| 387 , m_useShallowFlush(false) | 385 , m_useShallowFlush(false) |
| 388 , m_maxTextureSize(0) | 386 , m_maxTextureSize(std::numeric_limits<int>::max()) |
| 389 { | 387 { |
| 390 } | 388 } |
| 391 | 389 |
| 392 bool CCResourceProvider::initialize(TextureUploaderOption textureUploaderOption) | 390 bool CCResourceProvider::initialize() |
| 393 { | 391 { |
| 394 ASSERT(CCProxy::isImplThread()); | 392 ASSERT(CCProxy::isImplThread()); |
| 395 WebGraphicsContext3D* context3d = m_context->context3D(); | 393 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 396 if (!context3d) { | 394 if (!context3d) { |
| 397 m_maxTextureSize = INT_MAX; | |
| 398 m_textureUploader = UnthrottledTextureUploader::create(); | |
|
piman
2012/09/20 01:37:01
drive-by: what about the software case (no context
nduca
2012/09/20 03:49:29
It'd be really nice if the uploader talked only to
piman
2012/09/20 04:30:29
My main issue though is that in software mode, we
reveman
2012/09/20 04:52:18
I think you're right. We might still need a textur
| |
| 399 | |
| 400 // FIXME: Implement this path for software compositing. | 395 // FIXME: Implement this path for software compositing. |
| 401 return false; | 396 return false; |
| 402 } | 397 } |
| 403 if (!context3d->makeContextCurrent()) | 398 if (!context3d->makeContextCurrent()) |
| 404 return false; | 399 return false; |
| 405 | 400 |
| 406 std::string extensionsString = UTF16ToASCII(context3d->getString(GraphicsCon text3D::EXTENSIONS)); | 401 std::string extensionsString = UTF16ToASCII(context3d->getString(GraphicsCon text3D::EXTENSIONS)); |
| 407 std::vector<std::string> extensions; | 402 std::vector<std::string> extensions; |
| 408 base::SplitString(extensionsString, ' ', &extensions); | 403 base::SplitString(extensionsString, ' ', &extensions); |
| 409 bool useMapSub = false; | 404 bool useMapSub = false; |
| 410 bool useBindUniform = false; | 405 bool useBindUniform = false; |
| 411 for (size_t i = 0; i < extensions.size(); ++i) { | 406 for (size_t i = 0; i < extensions.size(); ++i) { |
| 412 if (extensions[i] == "GL_EXT_texture_storage") | 407 if (extensions[i] == "GL_EXT_texture_storage") |
| 413 m_useTextureStorageExt = true; | 408 m_useTextureStorageExt = true; |
| 414 else if (extensions[i] == "GL_ANGLE_texture_usage") | 409 else if (extensions[i] == "GL_ANGLE_texture_usage") |
| 415 m_useTextureUsageHint = true; | 410 m_useTextureUsageHint = true; |
| 416 else if (extensions[i] == "GL_CHROMIUM_map_sub") | 411 else if (extensions[i] == "GL_CHROMIUM_map_sub") |
| 417 useMapSub = true; | 412 useMapSub = true; |
| 418 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") | 413 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") |
| 419 m_useShallowFlush = true; | 414 m_useShallowFlush = true; |
| 420 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") | 415 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") |
| 421 useBindUniform = true; | 416 useBindUniform = true; |
| 422 } | 417 } |
| 423 | 418 |
| 424 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); | 419 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); |
| 425 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform ); | 420 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform ); |
| 426 | 421 |
| 427 if (textureUploaderOption == ThrottledUploader) | 422 m_textureUploader = ThrottledTextureUploader::create(context3d); |
| 428 m_textureUploader = ThrottledTextureUploader::create(context3d); | |
| 429 else | |
| 430 m_textureUploader = UnthrottledTextureUploader::create(); | |
| 431 GLC(context3d, context3d->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, & m_maxTextureSize)); | 423 GLC(context3d, context3d->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, & m_maxTextureSize)); |
|
piman
2012/09/20 04:30:29
another thing, IIRC in debug, command buffers like
| |
| 432 return true; | 424 return true; |
| 433 } | 425 } |
| 434 | 426 |
| 435 int CCResourceProvider::createChild(int pool) | 427 int CCResourceProvider::createChild(int pool) |
| 436 { | 428 { |
| 437 ASSERT(CCProxy::isImplThread()); | 429 ASSERT(CCProxy::isImplThread()); |
| 438 Child childInfo; | 430 Child childInfo; |
| 439 childInfo.pool = pool; | 431 childInfo.pool = pool; |
| 440 int child = m_nextChild++; | 432 int child = m_nextChild++; |
| 441 m_children.add(child, childInfo); | 433 m_children.add(child, childInfo); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 if (childPoolSet.contains(it->second.pool)) | 635 if (childPoolSet.contains(it->second.pool)) |
| 644 #endif | 636 #endif |
| 645 ++maxMailboxCount; | 637 ++maxMailboxCount; |
| 646 } | 638 } |
| 647 } | 639 } |
| 648 while (m_mailboxes.size() > maxMailboxCount) | 640 while (m_mailboxes.size() > maxMailboxCount) |
| 649 m_mailboxes.removeFirst(); | 641 m_mailboxes.removeFirst(); |
| 650 } | 642 } |
| 651 | 643 |
| 652 } | 644 } |
| OLD | NEW |