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

Side by Side Diff: cc/ProgramBinding.cpp

Issue 10900021: Use std::string instead of WTF::String / TextStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/ProgramBinding.h ('k') | cc/RenderSurfaceChromium.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #if USE(ACCELERATED_COMPOSITING) 7 #if USE(ACCELERATED_COMPOSITING)
8 8
9 #include "ProgramBinding.h" 9 #include "ProgramBinding.h"
10 10
11 #include "CCRendererGL.h" // For the GLC() macro. 11 #include "CCRendererGL.h" // For the GLC() macro.
12 #include "GeometryBinding.h" 12 #include "GeometryBinding.h"
13 #include "GraphicsContext3D.h" 13 #include "GraphicsContext3D.h"
14 #include "TraceEvent.h" 14 #include "TraceEvent.h"
15 #include <public/WebGraphicsContext3D.h> 15 #include <public/WebGraphicsContext3D.h>
16 #include <wtf/text/CString.h>
17 16
18 using WebKit::WebGraphicsContext3D; 17 using WebKit::WebGraphicsContext3D;
19 18
20 namespace WebCore { 19 namespace WebCore {
21 20
22 ProgramBindingBase::ProgramBindingBase() 21 ProgramBindingBase::ProgramBindingBase()
23 : m_program(0) 22 : m_program(0)
24 , m_vertexShaderId(0) 23 , m_vertexShaderId(0)
25 , m_fragmentShaderId(0) 24 , m_fragmentShaderId(0)
26 , m_initialized(false) 25 , m_initialized(false)
27 { 26 {
28 } 27 }
29 28
30 ProgramBindingBase::~ProgramBindingBase() 29 ProgramBindingBase::~ProgramBindingBase()
31 { 30 {
32 // If you hit these asserts, you initialized but forgot to call cleanup(). 31 // If you hit these asserts, you initialized but forgot to call cleanup().
33 ASSERT(!m_program); 32 ASSERT(!m_program);
34 ASSERT(!m_vertexShaderId); 33 ASSERT(!m_vertexShaderId);
35 ASSERT(!m_fragmentShaderId); 34 ASSERT(!m_fragmentShaderId);
36 ASSERT(!m_initialized); 35 ASSERT(!m_initialized);
37 } 36 }
38 37
39 static bool contextLost(WebGraphicsContext3D* context) 38 static bool contextLost(WebGraphicsContext3D* context)
40 { 39 {
41 return (context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR) ; 40 return (context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR) ;
42 } 41 }
43 42
44 43
45 void ProgramBindingBase::init(WebGraphicsContext3D* context, const String& verte xShader, const String& fragmentShader) 44 void ProgramBindingBase::init(WebGraphicsContext3D* context, const std::string& vertexShader, const std::string& fragmentShader)
46 { 45 {
47 TRACE_EVENT0("cc", "ProgramBindingBase::init"); 46 TRACE_EVENT0("cc", "ProgramBindingBase::init");
48 m_vertexShaderId = loadShader(context, GraphicsContext3D::VERTEX_SHADER, ver texShader); 47 m_vertexShaderId = loadShader(context, GraphicsContext3D::VERTEX_SHADER, ver texShader);
49 if (!m_vertexShaderId) { 48 if (!m_vertexShaderId) {
50 if (!contextLost(context)) 49 if (!contextLost(context))
51 LOG_ERROR("Failed to create vertex shader"); 50 LOG_ERROR("Failed to create vertex shader");
52 return; 51 return;
53 } 52 }
54 53
55 m_fragmentShaderId = loadShader(context, GraphicsContext3D::FRAGMENT_SHADER, fragmentShader); 54 m_fragmentShaderId = loadShader(context, GraphicsContext3D::FRAGMENT_SHADER, fragmentShader);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (!m_program) 86 if (!m_program)
88 return; 87 return;
89 88
90 ASSERT(context); 89 ASSERT(context);
91 GLC(context, context->deleteProgram(m_program)); 90 GLC(context, context->deleteProgram(m_program));
92 m_program = 0; 91 m_program = 0;
93 92
94 cleanupShaders(context); 93 cleanupShaders(context);
95 } 94 }
96 95
97 unsigned ProgramBindingBase::loadShader(WebGraphicsContext3D* context, unsigned type, const String& shaderSource) 96 unsigned ProgramBindingBase::loadShader(WebGraphicsContext3D* context, unsigned type, const std::string& shaderSource)
98 { 97 {
99 unsigned shader = context->createShader(type); 98 unsigned shader = context->createShader(type);
100 if (!shader) 99 if (!shader)
101 return 0; 100 return 0;
102 String sourceString(shaderSource); 101 GLC(context, context->shaderSource(shader, shaderSource.data()));
103 GLC(context, context->shaderSource(shader, sourceString.utf8().data()));
104 GLC(context, context->compileShader(shader)); 102 GLC(context, context->compileShader(shader));
105 #ifndef NDEBUG 103 #ifndef NDEBUG
106 int compiled = 0; 104 int compiled = 0;
107 GLC(context, context->getShaderiv(shader, GraphicsContext3D::COMPILE_STATUS, &compiled)); 105 GLC(context, context->getShaderiv(shader, GraphicsContext3D::COMPILE_STATUS, &compiled));
108 if (!compiled) { 106 if (!compiled) {
109 GLC(context, context->deleteShader(shader)); 107 GLC(context, context->deleteShader(shader));
110 return 0; 108 return 0;
111 } 109 }
112 #endif 110 #endif
113 return shader; 111 return shader;
(...skipping 26 matching lines...) Expand all
140 } 138 }
141 if (m_fragmentShaderId) { 139 if (m_fragmentShaderId) {
142 GLC(context, context->deleteShader(m_fragmentShaderId)); 140 GLC(context, context->deleteShader(m_fragmentShaderId));
143 m_fragmentShaderId = 0; 141 m_fragmentShaderId = 0;
144 } 142 }
145 } 143 }
146 144
147 } // namespace WebCore 145 } // namespace WebCore
148 146
149 #endif // USE(ACCELERATED_COMPOSITING) 147 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « cc/ProgramBinding.h ('k') | cc/RenderSurfaceChromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698