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

Side by Side Diff: cc/gl_renderer.cc

Issue 11464007: Add the DelegatingRenderer class with its initialize path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: init 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 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 #include "cc/gl_renderer.h" 5 #include "cc/gl_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "cc/damage_tracker.h" 12 #include "cc/damage_tracker.h"
13 #include "cc/geometry_binding.h" 13 #include "cc/geometry_binding.h"
14 #include "cc/layer_quad.h" 14 #include "cc/layer_quad.h"
15 #include "cc/math_util.h" 15 #include "cc/math_util.h"
16 #include "cc/platform_color.h"
17 #include "cc/priority_calculator.h" 16 #include "cc/priority_calculator.h"
18 #include "cc/proxy.h" 17 #include "cc/proxy.h"
19 #include "cc/render_pass.h" 18 #include "cc/render_pass.h"
20 #include "cc/render_surface_filters.h" 19 #include "cc/render_surface_filters.h"
21 #include "cc/scoped_resource.h" 20 #include "cc/scoped_resource.h"
22 #include "cc/single_thread_proxy.h" 21 #include "cc/single_thread_proxy.h"
23 #include "cc/stream_video_draw_quad.h" 22 #include "cc/stream_video_draw_quad.h"
24 #include "cc/texture_draw_quad.h" 23 #include "cc/texture_draw_quad.h"
25 #include "cc/video_layer_impl.h" 24 #include "cc/video_layer_impl.h"
26 #include "third_party/khronos/GLES2/gl2.h" 25 #include "third_party/khronos/GLES2/gl2.h"
(...skipping 28 matching lines...) Expand all
55 #else 54 #else
56 return false; 55 return false;
57 #endif 56 #endif
58 } 57 }
59 58
60 } // anonymous namespace 59 } // anonymous namespace
61 60
62 scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvid er* resourceProvider) 61 scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvid er* resourceProvider)
63 { 62 {
64 scoped_ptr<GLRenderer> renderer(make_scoped_ptr(new GLRenderer(client, resou rceProvider))); 63 scoped_ptr<GLRenderer> renderer(make_scoped_ptr(new GLRenderer(client, resou rceProvider)));
65 if (!renderer->initialize()) 64 if (!renderer->initialize(resourceProvider))
66 return scoped_ptr<GLRenderer>(); 65 return scoped_ptr<GLRenderer>();
67 66
68 return renderer.Pass(); 67 return renderer.Pass();
69 } 68 }
70 69
71 GLRenderer::GLRenderer(RendererClient* client, ResourceProvider* resourceProvide r) 70 GLRenderer::GLRenderer(RendererClient* client, ResourceProvider* resourceProvide r)
72 : DirectRenderer(client, resourceProvider) 71 : DirectRenderer(client, resourceProvider)
73 , m_offscreenFramebufferId(0) 72 , m_offscreenFramebufferId(0)
74 , m_sharedGeometryQuad(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)) 73 , m_sharedGeometryQuad(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f))
75 , m_context(resourceProvider->graphicsContext3D()) 74 , m_context(resourceProvider->graphicsContext3D())
76 , m_isViewportChanged(false) 75 , m_isViewportChanged(false)
77 , m_isFramebufferDiscarded(false) 76 , m_isFramebufferDiscarded(false)
78 , m_discardFramebufferWhenNotVisible(false) 77 , m_discardFramebufferWhenNotVisible(false)
79 , m_isUsingBindUniform(false) 78 , m_isUsingBindUniform(false)
80 , m_visible(true) 79 , m_visible(true)
81 , m_isScissorEnabled(false) 80 , m_isScissorEnabled(false)
82 { 81 {
83 DCHECK(m_context); 82 DCHECK(m_context);
84 } 83 }
85 84
86 bool GLRenderer::initialize() 85 bool GLRenderer::initialize(ResourceProvider* resourceProvider)
piman 2012/12/07 22:37:35 why? (you already have it).
danakj 2012/12/07 22:41:01 The provider isn't saved, right? Just the context3
piman 2012/12/07 22:53:13 It is saved in the DirectRenderer, that's the one
danakj 2012/12/07 22:54:12 OH >_< I copied and pasted and didn't notice the m
87 { 86 {
88 if (!m_context->makeContextCurrent()) 87 if (!m_context->makeContextCurrent())
89 return false; 88 return false;
90 89
91 m_context->setContextLostCallback(this); 90 m_context->setContextLostCallback(this);
92 m_context->pushGroupMarkerEXT("CompositorContext"); 91 m_context->pushGroupMarkerEXT("CompositorContext");
93 92
94 std::string extensionsString = UTF16ToASCII(m_context->getString(GL_EXTENSIO NS)); 93 std::string extensionsString = UTF16ToASCII(m_context->getString(GL_EXTENSIO NS));
95 std::vector<std::string> extensionsList; 94 std::vector<std::string> extensionsList;
96 base::SplitString(extensionsString, ' ', &extensionsList); 95 base::SplitString(extensionsString, ' ', &extensionsList);
(...skipping 19 matching lines...) Expand all
116 DCHECK(extensions.count("GL_ARB_texture_rectangle")); 115 DCHECK(extensions.count("GL_ARB_texture_rectangle"));
117 116
118 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager"); 117 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager");
119 if (m_capabilities.usingGpuMemoryManager) 118 if (m_capabilities.usingGpuMemoryManager)
120 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); 119 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this);
121 120
122 m_capabilities.usingDiscardFramebuffer = extensions.count("GL_CHROMIUM_disca rd_framebuffer"); 121 m_capabilities.usingDiscardFramebuffer = extensions.count("GL_CHROMIUM_disca rd_framebuffer");
123 122
124 m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external") ; 123 m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external") ;
125 124
126 GLC(m_context, m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_capabilities.m axTextureSize)); 125 m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize();
127 m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_contex t, extensions.count("GL_EXT_texture_format_BGRA8888")); 126 m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat();
128 127
129 // The updater can access textures while the GLRenderer is using them. 128 // The updater can access textures while the GLRenderer is using them.
130 m_capabilities.allowPartialTextureUpdates = true; 129 m_capabilities.allowPartialTextureUpdates = true;
131 130
132 m_isUsingBindUniform = extensions.count("GL_CHROMIUM_bind_uniform_location") ; 131 m_isUsingBindUniform = extensions.count("GL_CHROMIUM_bind_uniform_location") ;
133 132
134 // Make sure scissoring starts as disabled. 133 // Make sure scissoring starts as disabled.
135 GLC(m_context, m_context->disable(GL_SCISSOR_TEST)); 134 GLC(m_context, m_context->disable(GL_SCISSOR_TEST));
136 DCHECK(!m_isScissorEnabled); 135 DCHECK(!m_isScissorEnabled);
137 136
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 1747
1749 releaseRenderPassTextures(); 1748 releaseRenderPassTextures();
1750 } 1749 }
1751 1750
1752 bool GLRenderer::isContextLost() 1751 bool GLRenderer::isContextLost()
1753 { 1752 {
1754 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1753 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1755 } 1754 }
1756 1755
1757 } // namespace cc 1756 } // namespace cc
OLDNEW
« cc/delegating_renderer.h ('K') | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698