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

Side by Side Diff: cc/resource_provider.cc

Issue 11464007: Add the DelegatingRenderer class with its initialize path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initialize() Created 8 years 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
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 "cc/resource_provider.h" 5 #include "cc/resource_provider.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "cc/gl_renderer.h" // For the GLC() macro. 14 #include "cc/gl_renderer.h" // For the GLC() macro.
15 #include "cc/platform_color.h"
15 #include "cc/texture_uploader.h" 16 #include "cc/texture_uploader.h"
16 #include "cc/transferable_resource.h" 17 #include "cc/transferable_resource.h"
17 #include "third_party/khronos/GLES2/gl2.h" 18 #include "third_party/khronos/GLES2/gl2.h"
18 #include "third_party/khronos/GLES2/gl2ext.h" 19 #include "third_party/khronos/GLES2/gl2ext.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 #include "ui/gfx/vector2d.h" 21 #include "ui/gfx/vector2d.h"
21 22
22 #include <public/WebGraphicsContext3D.h> 23 #include <public/WebGraphicsContext3D.h>
23 24
24 using WebKit::WebGraphicsContext3D; 25 using WebKit::WebGraphicsContext3D;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 493
493 ResourceProvider::ResourceProvider(OutputSurface* context) 494 ResourceProvider::ResourceProvider(OutputSurface* context)
494 : m_outputSurface(context) 495 : m_outputSurface(context)
495 , m_nextId(1) 496 , m_nextId(1)
496 , m_nextChild(1) 497 , m_nextChild(1)
497 , m_defaultResourceType(GLTexture) 498 , m_defaultResourceType(GLTexture)
498 , m_useTextureStorageExt(false) 499 , m_useTextureStorageExt(false)
499 , m_useTextureUsageHint(false) 500 , m_useTextureUsageHint(false)
500 , m_useShallowFlush(false) 501 , m_useShallowFlush(false)
501 , m_maxTextureSize(0) 502 , m_maxTextureSize(0)
503 , m_bestTextureFormat(0)
502 { 504 {
503 } 505 }
504 506
505 bool ResourceProvider::initialize() 507 bool ResourceProvider::initialize()
506 { 508 {
507 DCHECK(m_threadChecker.CalledOnValidThread()); 509 DCHECK(m_threadChecker.CalledOnValidThread());
508 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 510 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
509 if (!context3d) { 511 if (!context3d) {
510 m_maxTextureSize = INT_MAX / 2; 512 m_maxTextureSize = INT_MAX / 2;
513 m_bestTextureFormat = GL_RGBA;
511 return true; 514 return true;
512 } 515 }
513 if (!context3d->makeContextCurrent()) 516 if (!context3d->makeContextCurrent())
514 return false; 517 return false;
515 518
516 std::string extensionsString = UTF16ToASCII(context3d->getString(GL_EXTENSIO NS)); 519 std::string extensionsString = UTF16ToASCII(context3d->getString(GL_EXTENSIO NS));
517 std::vector<std::string> extensions; 520 std::vector<std::string> extensions;
518 base::SplitString(extensionsString, ' ', &extensions); 521 base::SplitString(extensionsString, ' ', &extensions);
519 bool useMapSub = false; 522 bool useMapSub = false;
520 bool useBindUniform = false; 523 bool useBindUniform = false;
524 bool useBGRA = false;
521 for (size_t i = 0; i < extensions.size(); ++i) { 525 for (size_t i = 0; i < extensions.size(); ++i) {
522 if (extensions[i] == "GL_EXT_texture_storage") 526 if (extensions[i] == "GL_EXT_texture_storage")
523 m_useTextureStorageExt = true; 527 m_useTextureStorageExt = true;
524 else if (extensions[i] == "GL_ANGLE_texture_usage") 528 else if (extensions[i] == "GL_ANGLE_texture_usage")
525 m_useTextureUsageHint = true; 529 m_useTextureUsageHint = true;
526 else if (extensions[i] == "GL_CHROMIUM_map_sub") 530 else if (extensions[i] == "GL_CHROMIUM_map_sub")
527 useMapSub = true; 531 useMapSub = true;
528 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") 532 else if (extensions[i] == "GL_CHROMIUM_shallow_flush")
529 m_useShallowFlush = true; 533 m_useShallowFlush = true;
530 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") 534 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location")
531 useBindUniform = true; 535 useBindUniform = true;
536 else if (extensions[i] == "GL_EXT_texture_format_BGRA8888")
537 useBGRA = true;
532 } 538 }
533 539
534 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform ); 540 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform );
535 541
536 m_textureUploader = TextureUploader::create(context3d, useMapSub, m_useShall owFlush); 542 m_textureUploader = TextureUploader::create(context3d, useMapSub, m_useShall owFlush);
537 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize )); 543 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize ));
544 m_bestTextureFormat = PlatformColor::bestTextureFormat(context3d, useBGRA);
538 return true; 545 return true;
539 } 546 }
540 547
541 int ResourceProvider::createChild(int pool) 548 int ResourceProvider::createChild(int pool)
542 { 549 {
543 DCHECK(m_threadChecker.CalledOnValidThread()); 550 DCHECK(m_threadChecker.CalledOnValidThread());
544 Child childInfo; 551 Child childInfo;
545 childInfo.pool = pool; 552 childInfo.pool = pool;
546 int child = m_nextChild++; 553 int child = m_nextChild++;
547 m_children[child] = childInfo; 554 m_children[child] = childInfo;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 return false; 949 return false;
943 } 950 }
944 951
945 resource->pendingSetPixels = false; 952 resource->pendingSetPixels = false;
946 unlockForWrite(id); 953 unlockForWrite(id);
947 954
948 return true; 955 return true;
949 } 956 }
950 957
951 } // namespace cc 958 } // namespace cc
OLDNEW
« cc/delegating_renderer.cc ('K') | « cc/resource_provider.h ('k') | cc/software_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698