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

Side by Side Diff: components/mus/gles2/command_buffer_driver.cc

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/mus/gles2/command_buffer_driver.h" 5 #include "components/mus/gles2/command_buffer_driver.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 DCHECK(CalledOnValidThread()); 83 DCHECK(CalledOnValidThread());
84 gpu::gles2::ContextCreationAttribHelper attrib_helper; 84 gpu::gles2::ContextCreationAttribHelper attrib_helper;
85 if (!attrib_helper.Parse(attribs.storage())) 85 if (!attrib_helper.Parse(attribs.storage()))
86 return false; 86 return false;
87 87
88 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; 88 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget;
89 if (offscreen) { 89 if (offscreen) {
90 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size(0, 0)); 90 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size(0, 0));
91 } else { 91 } else {
92 #if defined(USE_OZONE) 92 #if defined(USE_OZONE)
93 scoped_refptr<gfx::GLSurface> underlying_surface = 93 scoped_refptr<gl::GLSurface> underlying_surface =
94 gl::init::CreateSurfacelessViewGLSurface(widget_); 94 gl::init::CreateSurfacelessViewGLSurface(widget_);
95 if (!underlying_surface) 95 if (!underlying_surface)
96 underlying_surface = gl::init::CreateViewGLSurface(widget_); 96 underlying_surface = gl::init::CreateViewGLSurface(widget_);
97 #else 97 #else
98 scoped_refptr<gfx::GLSurface> underlying_surface = 98 scoped_refptr<gl::GLSurface> underlying_surface =
99 gl::init::CreateViewGLSurface(widget_); 99 gl::init::CreateViewGLSurface(widget_);
100 #endif 100 #endif
101 scoped_refptr<GLSurfaceAdapterMus> surface_adapter = 101 scoped_refptr<GLSurfaceAdapterMus> surface_adapter =
102 new GLSurfaceAdapterMus(underlying_surface); 102 new GLSurfaceAdapterMus(underlying_surface);
103 surface_adapter->SetGpuCompletedSwapBuffersCallback( 103 surface_adapter->SetGpuCompletedSwapBuffersCallback(
104 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers, 104 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers,
105 weak_factory_.GetWeakPtr())); 105 weak_factory_.GetWeakPtr()));
106 surface_ = surface_adapter; 106 surface_ = surface_adapter;
107 107
108 gfx::VSyncProvider* vsync_provider = 108 gfx::VSyncProvider* vsync_provider =
109 surface_ ? surface_->GetVSyncProvider() : nullptr; 109 surface_ ? surface_->GetVSyncProvider() : nullptr;
110 if (vsync_provider) { 110 if (vsync_provider) {
111 vsync_provider->GetVSyncParameters( 111 vsync_provider->GetVSyncParameters(
112 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, 112 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters,
113 weak_factory_.GetWeakPtr())); 113 weak_factory_.GetWeakPtr()));
114 } 114 }
115 } 115 }
116 116
117 if (!surface_.get()) 117 if (!surface_.get())
118 return false; 118 return false;
119 119
120 // TODO(piman): virtual contexts, gpu preference. 120 // TODO(piman): virtual contexts, gpu preference.
121 context_ = gl::init::CreateGLContext( 121 context_ = gl::init::CreateGLContext(gpu_state_->share_group(),
122 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); 122 surface_.get(), gl::PreferIntegratedGpu);
123 if (!context_.get()) 123 if (!context_.get())
124 return false; 124 return false;
125 125
126 if (!context_->MakeCurrent(surface_.get())) 126 if (!context_->MakeCurrent(surface_.get()))
127 return false; 127 return false;
128 128
129 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but 129 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but
130 // only needs to be per-thread. 130 // only needs to be per-thread.
131 const bool bind_generates_resource = attrib_helper.bind_generates_resource; 131 const bool bind_generates_resource = attrib_helper.bind_generates_resource;
132 scoped_refptr<gpu::gles2::FeatureInfo> feature_info = 132 scoped_refptr<gpu::gles2::FeatureInfo> feature_info =
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 gfx::BufferFormat format, 290 gfx::BufferFormat format,
291 uint32_t internal_format, 291 uint32_t internal_format,
292 ui::NativePixmap* pixmap) { 292 ui::NativePixmap* pixmap) {
293 #if defined(USE_OZONE) 293 #if defined(USE_OZONE)
294 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 294 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
295 if (image_manager->LookupImage(id)) { 295 if (image_manager->LookupImage(id)) {
296 LOG(ERROR) << "Image already exists with same ID."; 296 LOG(ERROR) << "Image already exists with same ID.";
297 return; 297 return;
298 } 298 }
299 299
300 scoped_refptr<gfx::GLImageOzoneNativePixmap> image = 300 scoped_refptr<gl::GLImageOzoneNativePixmap> image =
301 new gfx::GLImageOzoneNativePixmap(size, internal_format); 301 new gl::GLImageOzoneNativePixmap(size, internal_format);
302 if (!image->Initialize(pixmap, format)) { 302 if (!image->Initialize(pixmap, format)) {
303 NOTREACHED(); 303 NOTREACHED();
304 return; 304 return;
305 } 305 }
306 306
307 image_manager->AddImage(image.get(), id); 307 image_manager->AddImage(image.get(), id);
308 #endif 308 #endif
309 } 309 }
310 310
311 void CommandBufferDriver::DestroyImage(int32_t id) { 311 void CommandBufferDriver::DestroyImage(int32_t id) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 542
543 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { 543 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) {
544 DCHECK(CalledOnValidThread()); 544 DCHECK(CalledOnValidThread());
545 if (client_) { 545 if (client_) {
546 client_->OnGpuCompletedSwapBuffers(result); 546 client_->OnGpuCompletedSwapBuffers(result);
547 } 547 }
548 } 548 }
549 549
550 } // namespace mus 550 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/gles2/command_buffer_driver.h ('k') | components/mus/gles2/command_buffer_local.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698