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

Side by Side Diff: gpu/gles2_conform_support/egl/display.cc

Issue 9166034: Fix GLES2 Conformance test support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "gpu/gles2_conform_support/egl/display.h" 5 #include "gpu/gles2_conform_support/egl/display.h"
6 6
7 #include <vector> 7 #include <vector>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "gpu/command_buffer/client/gles2_lib.h" 10 #include "gpu/command_buffer/client/gles2_lib.h"
(...skipping 12 matching lines...) Expand all
23 : display_id_(display_id), 23 : display_id_(display_id),
24 is_initialized_(false), 24 is_initialized_(false),
25 transfer_buffer_id_(-1) { 25 transfer_buffer_id_(-1) {
26 } 26 }
27 27
28 Display::~Display() { 28 Display::~Display() {
29 gles2::Terminate(); 29 gles2::Terminate();
30 } 30 }
31 31
32 bool Display::Initialize() { 32 bool Display::Initialize() {
33 scoped_ptr<gpu::CommandBufferService> command_buffer(
34 new gpu::CommandBufferService);
35 if (!command_buffer->Initialize())
36 return false;
37
38 int32 transfer_buffer_id =
39 command_buffer->CreateTransferBuffer(kTransferBufferSize, -1);
40 gpu::Buffer transfer_buffer =
41 command_buffer->GetTransferBuffer(transfer_buffer_id);
42 if (transfer_buffer.ptr == NULL)
43 return false;
44
45 scoped_ptr<gpu::gles2::GLES2CmdHelper> cmd_helper(
46 new gpu::gles2::GLES2CmdHelper(command_buffer.get()));
47 if (!cmd_helper->Initialize(kCommandBufferSize))
48 return false;
49
50 gles2::Initialize(); 33 gles2::Initialize();
51
52 is_initialized_ = true; 34 is_initialized_ = true;
53 command_buffer_.reset(command_buffer.release());
54 transfer_buffer_id_ = transfer_buffer_id;
55 gles2_cmd_helper_.reset(cmd_helper.release());
56 return true; 35 return true;
57 } 36 }
58 37
59 bool Display::IsValidConfig(EGLConfig config) { 38 bool Display::IsValidConfig(EGLConfig config) {
60 return (config != NULL) && (config == config_.get()); 39 return (config != NULL) && (config == config_.get());
61 } 40 }
62 41
63 bool Display::GetConfigs(EGLConfig* configs, 42 bool Display::GetConfigs(EGLConfig* configs,
64 EGLint config_size, 43 EGLint config_size,
65 EGLint* num_config) { 44 EGLint* num_config) {
(...skipping 30 matching lines...) Expand all
96 } 75 }
97 76
98 EGLSurface Display::CreateWindowSurface(EGLConfig config, 77 EGLSurface Display::CreateWindowSurface(EGLConfig config,
99 EGLNativeWindowType win, 78 EGLNativeWindowType win,
100 const EGLint* attrib_list) { 79 const EGLint* attrib_list) {
101 if (surface_ != NULL) { 80 if (surface_ != NULL) {
102 // We do not support more than one window surface. 81 // We do not support more than one window surface.
103 return EGL_NO_SURFACE; 82 return EGL_NO_SURFACE;
104 } 83 }
105 84
85 scoped_ptr<gpu::CommandBufferService> command_buffer(
86 new gpu::CommandBufferService);
87 if (!command_buffer->Initialize())
88 return false;
89
106 gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup(true)); 90 gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup(true));
107 91
108 decoder_.reset(gpu::gles2::GLES2Decoder::Create(group.get())); 92 decoder_.reset(gpu::gles2::GLES2Decoder::Create(group.get()));
109 if (!decoder_.get()) 93 if (!decoder_.get())
110 return EGL_NO_SURFACE; 94 return EGL_NO_SURFACE;
111 95
112 gpu_scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), 96 gpu_scheduler_.reset(new gpu::GpuScheduler(command_buffer.get(),
113 decoder_.get(), 97 decoder_.get(),
114 NULL)); 98 NULL));
115 99
116 decoder_->set_engine(gpu_scheduler_.get()); 100 decoder_->set_engine(gpu_scheduler_.get());
117 101
118 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, win); 102 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, win);
119 if (!gl_surface_.get()) 103 if (!gl_surface_.get())
120 return EGL_NO_SURFACE; 104 return EGL_NO_SURFACE;
121 105
122 gl_context_ = gfx::GLContext::CreateGLContext(NULL, 106 gl_context_ = gfx::GLContext::CreateGLContext(NULL,
123 gl_surface_.get(), 107 gl_surface_.get(),
124 gfx::PreferDiscreteGpu); 108 gfx::PreferDiscreteGpu);
125 if (!gl_context_.get()) 109 if (!gl_context_.get())
126 return EGL_NO_SURFACE; 110 return EGL_NO_SURFACE;
127 111
128 std::vector<int32> attribs; 112 std::vector<int32> attribs;
129 if (!decoder_->Initialize(gl_surface_.get(), 113 if (!decoder_->Initialize(gl_surface_.get(),
130 gl_context_.get(), 114 gl_context_.get(),
131 gfx::Size(), 115 gfx::Size(),
132 gpu::gles2::DisallowedFeatures(), 116 gpu::gles2::DisallowedFeatures(),
133 NULL, 117 NULL,
134 attribs)) { 118 attribs)) {
135 return EGL_NO_SURFACE; 119 return EGL_NO_SURFACE;
136 } 120 }
137 121
138 command_buffer_->SetPutOffsetChangeCallback( 122 command_buffer->SetPutOffsetChangeCallback(
139 base::Bind(&gpu::GpuScheduler::PutChanged, 123 base::Bind(&gpu::GpuScheduler::PutChanged,
140 base::Unretained(gpu_scheduler_.get()))); 124 base::Unretained(gpu_scheduler_.get())));
141 command_buffer_->SetGetBufferChangeCallback( 125 command_buffer->SetGetBufferChangeCallback(
142 base::Bind(&gpu::GpuScheduler::SetGetBuffer, 126 base::Bind(&gpu::GpuScheduler::SetGetBuffer,
143 base::Unretained(gpu_scheduler_.get()))); 127 base::Unretained(gpu_scheduler_.get())));
144 128
129 scoped_ptr<gpu::gles2::GLES2CmdHelper> cmd_helper(
130 new gpu::gles2::GLES2CmdHelper(command_buffer.get()));
131 if (!cmd_helper->Initialize(kCommandBufferSize))
132 return false;
133
134 int32 transfer_buffer_id =
135 command_buffer->CreateTransferBuffer(kTransferBufferSize, -1);
136 gpu::Buffer transfer_buffer =
137 command_buffer->GetTransferBuffer(transfer_buffer_id);
138 if (transfer_buffer.ptr == NULL)
139 return false;
140
141 command_buffer_.reset(command_buffer.release());
142 transfer_buffer_id_ = transfer_buffer_id;
143 gles2_cmd_helper_.reset(cmd_helper.release());
145 surface_.reset(new Surface(win)); 144 surface_.reset(new Surface(win));
146 145
147 return surface_.get(); 146 return surface_.get();
148 } 147 }
149 148
150 void Display::DestroySurface(EGLSurface surface) { 149 void Display::DestroySurface(EGLSurface surface) {
151 DCHECK(IsValidSurface(surface)); 150 DCHECK(IsValidSurface(surface));
152 gpu_scheduler_.reset(); 151 gpu_scheduler_.reset();
153 if (decoder_.get()) { 152 if (decoder_.get()) {
154 decoder_->Destroy(); 153 decoder_->Destroy();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } else { 205 } else {
207 DCHECK(IsValidSurface(draw)); 206 DCHECK(IsValidSurface(draw));
208 DCHECK(IsValidSurface(read)); 207 DCHECK(IsValidSurface(read));
209 DCHECK(IsValidContext(ctx)); 208 DCHECK(IsValidContext(ctx));
210 gles2::SetGLContext(context_.get()); 209 gles2::SetGLContext(context_.get());
211 } 210 }
212 return true; 211 return true;
213 } 212 }
214 213
215 } // namespace egl 214 } // namespace egl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698