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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 return storageFormat; | 44 return storageFormat; |
45 } | 45 } |
46 | 46 |
47 static bool isTextureFormatSupportedForStorage(GC3Denum format) | 47 static bool isTextureFormatSupportedForStorage(GC3Denum format) |
48 { | 48 { |
49 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX
T); | 49 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX
T); |
50 } | 50 } |
51 | 51 |
52 PassOwnPtr<CCResourceProvider> CCResourceProvider::create(CCGraphicsContext* con
text) | 52 PassOwnPtr<CCResourceProvider> CCResourceProvider::create(CCGraphicsContext* con
text, TextureUploaderOption option) |
53 { | 53 { |
54 OwnPtr<CCResourceProvider> resourceProvider(adoptPtr(new CCResourceProvider(
context))); | 54 OwnPtr<CCResourceProvider> resourceProvider(adoptPtr(new CCResourceProvider(
context))); |
55 if (!resourceProvider->initialize()) | 55 if (!resourceProvider->initialize(option)) |
56 return nullptr; | 56 return nullptr; |
57 return resourceProvider.release(); | 57 return resourceProvider.release(); |
58 } | 58 } |
59 | 59 |
60 CCResourceProvider::~CCResourceProvider() | 60 CCResourceProvider::~CCResourceProvider() |
61 { | 61 { |
62 WebGraphicsContext3D* context3d = m_context->context3D(); | 62 WebGraphicsContext3D* context3d = m_context->context3D(); |
63 if (!context3d || !context3d->makeContextCurrent()) | 63 if (!context3d || !context3d->makeContextCurrent()) |
64 return; | 64 return; |
65 m_textureUploader.clear(); | 65 m_textureUploader.clear(); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 , m_nextId(1) | 382 , m_nextId(1) |
383 , m_nextChild(1) | 383 , m_nextChild(1) |
384 , m_defaultResourceType(GLTexture) | 384 , m_defaultResourceType(GLTexture) |
385 , m_useTextureStorageExt(false) | 385 , m_useTextureStorageExt(false) |
386 , m_useTextureUsageHint(false) | 386 , m_useTextureUsageHint(false) |
387 , m_useShallowFlush(false) | 387 , m_useShallowFlush(false) |
388 , m_maxTextureSize(0) | 388 , m_maxTextureSize(0) |
389 { | 389 { |
390 } | 390 } |
391 | 391 |
392 bool CCResourceProvider::initialize() | 392 bool CCResourceProvider::initialize(TextureUploaderOption textureUploaderOption) |
393 { | 393 { |
394 ASSERT(CCProxy::isImplThread()); | 394 ASSERT(CCProxy::isImplThread()); |
395 WebGraphicsContext3D* context3d = m_context->context3D(); | 395 WebGraphicsContext3D* context3d = m_context->context3D(); |
396 if (!context3d) { | 396 if (!context3d) { |
397 m_maxTextureSize = INT_MAX; | 397 m_maxTextureSize = INT_MAX; |
398 m_textureUploader = UnthrottledTextureUploader::create(); | 398 m_textureUploader = UnthrottledTextureUploader::create(); |
399 | 399 |
400 // FIXME: Implement this path for software compositing. | 400 // FIXME: Implement this path for software compositing. |
401 return false; | 401 return false; |
402 } | 402 } |
(...skipping 14 matching lines...) Expand all Loading... |
417 useMapSub = true; | 417 useMapSub = true; |
418 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") | 418 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") |
419 m_useShallowFlush = true; | 419 m_useShallowFlush = true; |
420 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") | 420 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") |
421 useBindUniform = true; | 421 useBindUniform = true; |
422 } | 422 } |
423 | 423 |
424 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); | 424 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); |
425 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform
); | 425 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform
); |
426 | 426 |
427 m_textureUploader = ThrottledTextureUploader::create(context3d); | 427 if (textureUploaderOption == ThrottledUploader) |
| 428 m_textureUploader = ThrottledTextureUploader::create(context3d); |
| 429 else |
| 430 m_textureUploader = UnthrottledTextureUploader::create(); |
428 GLC(context3d, context3d->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &
m_maxTextureSize)); | 431 GLC(context3d, context3d->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &
m_maxTextureSize)); |
429 return true; | 432 return true; |
430 } | 433 } |
431 | 434 |
432 int CCResourceProvider::createChild(int pool) | 435 int CCResourceProvider::createChild(int pool) |
433 { | 436 { |
434 ASSERT(CCProxy::isImplThread()); | 437 ASSERT(CCProxy::isImplThread()); |
435 Child childInfo; | 438 Child childInfo; |
436 childInfo.pool = pool; | 439 childInfo.pool = pool; |
437 int child = m_nextChild++; | 440 int child = m_nextChild++; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 if (childPoolSet.contains(it->second.pool)) | 643 if (childPoolSet.contains(it->second.pool)) |
641 #endif | 644 #endif |
642 ++maxMailboxCount; | 645 ++maxMailboxCount; |
643 } | 646 } |
644 } | 647 } |
645 while (m_mailboxes.size() > maxMailboxCount) | 648 while (m_mailboxes.size() > maxMailboxCount) |
646 m_mailboxes.removeFirst(); | 649 m_mailboxes.removeFirst(); |
647 } | 650 } |
648 | 651 |
649 } | 652 } |
OLD | NEW |