Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Side by Side Diff: cc/CCResourceProvider.cpp

Issue 10961008: cc: Remove TextureUploaderOption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add SoftwareTextureUploader to CCResourceProvider for software mode and init m_maxTextureSize to 0. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCResourceProvider.h ('k') | cc/CCResourceProviderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 12 #include <limits.h>
13 13
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "CCProxy.h" 16 #include "CCProxy.h"
17 #include "CCRendererGL.h" // For the GLC() macro. 17 #include "CCRendererGL.h" // For the GLC() macro.
18 #include "Extensions3DChromium.h" 18 #include "Extensions3DChromium.h"
19 #include "IntRect.h" 19 #include "IntRect.h"
20 #include "LayerTextureSubImage.h" 20 #include "LayerTextureSubImage.h"
21 #include "ThrottledTextureUploader.h" 21 #include "ThrottledTextureUploader.h"
22 #include "UnthrottledTextureUploader.h"
23 #include <public/WebGraphicsContext3D.h> 22 #include <public/WebGraphicsContext3D.h>
24 #include <wtf/HashSet.h> 23 #include <wtf/HashSet.h>
25 24
26 using WebKit::WebGraphicsContext3D; 25 using WebKit::WebGraphicsContext3D;
27 26
28 namespace cc { 27 namespace cc {
29 28
29 class SoftwareTextureUploader : public TextureUploader {
nduca 2012/09/20 18:34:17 One class per file, please.
piman 2012/09/20 18:48:42 FYI, in chrome code having multiple private classe
30 public:
31 virtual bool isBusy() OVERRIDE { return false; }
32 virtual double estimatedTexturesPerSecond() { return std::numeric_limits<dou ble>::max(); }
33 virtual void beginUploads() OVERRIDE { }
34 virtual void endUploads() OVERRIDE { }
35 virtual void uploadTexture(CCResourceProvider* resourceProvider, Parameters upload) OVERRIDE { upload.texture->updateRect(resourceProvider, upload.sourceRec t, upload.destOffset); }
36 };
37
30 static GC3Denum textureToStorageFormat(GC3Denum textureFormat) 38 static GC3Denum textureToStorageFormat(GC3Denum textureFormat)
31 { 39 {
32 GC3Denum storageFormat = Extensions3D::RGBA8_OES; 40 GC3Denum storageFormat = Extensions3D::RGBA8_OES;
33 switch (textureFormat) { 41 switch (textureFormat) {
34 case GraphicsContext3D::RGBA: 42 case GraphicsContext3D::RGBA:
35 break; 43 break;
36 case Extensions3D::BGRA_EXT: 44 case Extensions3D::BGRA_EXT:
37 storageFormat = Extensions3DChromium::BGRA8_EXT; 45 storageFormat = Extensions3DChromium::BGRA8_EXT;
38 break; 46 break;
39 default: 47 default:
40 ASSERT_NOT_REACHED(); 48 ASSERT_NOT_REACHED();
41 break; 49 break;
42 } 50 }
43 51
44 return storageFormat; 52 return storageFormat;
45 } 53 }
46 54
47 static bool isTextureFormatSupportedForStorage(GC3Denum format) 55 static bool isTextureFormatSupportedForStorage(GC3Denum format)
48 { 56 {
49 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX T); 57 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX T);
50 } 58 }
51 59
52 PassOwnPtr<CCResourceProvider> CCResourceProvider::create(CCGraphicsContext* con text, TextureUploaderOption option) 60 PassOwnPtr<CCResourceProvider> CCResourceProvider::create(CCGraphicsContext* con text)
53 { 61 {
54 OwnPtr<CCResourceProvider> resourceProvider(adoptPtr(new CCResourceProvider( context))); 62 OwnPtr<CCResourceProvider> resourceProvider(adoptPtr(new CCResourceProvider( context)));
55 if (!resourceProvider->initialize(option)) 63 if (!resourceProvider->initialize())
56 return nullptr; 64 return nullptr;
57 return resourceProvider.release(); 65 return resourceProvider.release();
58 } 66 }
59 67
60 CCResourceProvider::~CCResourceProvider() 68 CCResourceProvider::~CCResourceProvider()
61 { 69 {
62 WebGraphicsContext3D* context3d = m_context->context3D(); 70 WebGraphicsContext3D* context3d = m_context->context3D();
63 if (!context3d || !context3d->makeContextCurrent()) 71 if (!context3d || !context3d->makeContextCurrent())
64 return; 72 return;
65 m_textureUploader.clear(); 73 m_textureUploader.clear();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 , m_nextId(1) 390 , m_nextId(1)
383 , m_nextChild(1) 391 , m_nextChild(1)
384 , m_defaultResourceType(GLTexture) 392 , m_defaultResourceType(GLTexture)
385 , m_useTextureStorageExt(false) 393 , m_useTextureStorageExt(false)
386 , m_useTextureUsageHint(false) 394 , m_useTextureUsageHint(false)
387 , m_useShallowFlush(false) 395 , m_useShallowFlush(false)
388 , m_maxTextureSize(0) 396 , m_maxTextureSize(0)
389 { 397 {
390 } 398 }
391 399
392 bool CCResourceProvider::initialize(TextureUploaderOption textureUploaderOption) 400 bool CCResourceProvider::initialize()
393 { 401 {
394 ASSERT(CCProxy::isImplThread()); 402 ASSERT(CCProxy::isImplThread());
395 WebGraphicsContext3D* context3d = m_context->context3D(); 403 WebGraphicsContext3D* context3d = m_context->context3D();
396 if (!context3d) { 404 if (!context3d) {
397 m_maxTextureSize = INT_MAX; 405 m_maxTextureSize = INT_MAX;
398 m_textureUploader = UnthrottledTextureUploader::create(); 406 m_textureUploader = adoptPtr(new SoftwareTextureUploader);
399 407
400 // FIXME: Implement this path for software compositing. 408 // FIXME: Implement this path for software compositing.
401 return false; 409 return false;
402 } 410 }
403 if (!context3d->makeContextCurrent()) 411 if (!context3d->makeContextCurrent())
404 return false; 412 return false;
405 413
406 std::string extensionsString = UTF16ToASCII(context3d->getString(GraphicsCon text3D::EXTENSIONS)); 414 std::string extensionsString = UTF16ToASCII(context3d->getString(GraphicsCon text3D::EXTENSIONS));
407 std::vector<std::string> extensions; 415 std::vector<std::string> extensions;
408 base::SplitString(extensionsString, ' ', &extensions); 416 base::SplitString(extensionsString, ' ', &extensions);
409 bool useMapSub = false; 417 bool useMapSub = false;
410 bool useBindUniform = false; 418 bool useBindUniform = false;
411 for (size_t i = 0; i < extensions.size(); ++i) { 419 for (size_t i = 0; i < extensions.size(); ++i) {
412 if (extensions[i] == "GL_EXT_texture_storage") 420 if (extensions[i] == "GL_EXT_texture_storage")
413 m_useTextureStorageExt = true; 421 m_useTextureStorageExt = true;
414 else if (extensions[i] == "GL_ANGLE_texture_usage") 422 else if (extensions[i] == "GL_ANGLE_texture_usage")
415 m_useTextureUsageHint = true; 423 m_useTextureUsageHint = true;
416 else if (extensions[i] == "GL_CHROMIUM_map_sub") 424 else if (extensions[i] == "GL_CHROMIUM_map_sub")
417 useMapSub = true; 425 useMapSub = true;
418 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") 426 else if (extensions[i] == "GL_CHROMIUM_shallow_flush")
419 m_useShallowFlush = true; 427 m_useShallowFlush = true;
420 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") 428 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location")
421 useBindUniform = true; 429 useBindUniform = true;
422 } 430 }
423 431
424 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); 432 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub));
425 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform ); 433 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform );
426 434
427 if (textureUploaderOption == ThrottledUploader) 435 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)); 436 GLC(context3d, context3d->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, & m_maxTextureSize));
432 return true; 437 return true;
433 } 438 }
434 439
435 int CCResourceProvider::createChild(int pool) 440 int CCResourceProvider::createChild(int pool)
436 { 441 {
437 ASSERT(CCProxy::isImplThread()); 442 ASSERT(CCProxy::isImplThread());
438 Child childInfo; 443 Child childInfo;
439 childInfo.pool = pool; 444 childInfo.pool = pool;
440 int child = m_nextChild++; 445 int child = m_nextChild++;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if (childPoolSet.contains(it->second.pool)) 648 if (childPoolSet.contains(it->second.pool))
644 #endif 649 #endif
645 ++maxMailboxCount; 650 ++maxMailboxCount;
646 } 651 }
647 } 652 }
648 while (m_mailboxes.size() > maxMailboxCount) 653 while (m_mailboxes.size() > maxMailboxCount)
649 m_mailboxes.removeFirst(); 654 m_mailboxes.removeFirst();
650 } 655 }
651 656
652 } 657 }
OLDNEW
« no previous file with comments | « cc/CCResourceProvider.h ('k') | cc/CCResourceProviderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698