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

Side by Side Diff: components/display_compositor/buffer_queue.cc

Issue 2213273002: ozone: Consolidate primary plane format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac back to GL_RGBA. Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display_compositor/buffer_queue.h" 5 #include "components/display_compositor/buffer_queue.h"
6 6
7 #include "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "components/display_compositor/gl_helper.h" 10 #include "components/display_compositor/gl_helper.h"
11 #include "gpu/GLES2/gl2extchromium.h" 11 #include "gpu/GLES2/gl2extchromium.h"
12 #include "gpu/command_buffer/client/gles2_interface.h" 12 #include "gpu/command_buffer/client/gles2_interface.h"
13 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 13 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
14 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" 14 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
15 #include "third_party/skia/include/core/SkRect.h" 15 #include "third_party/skia/include/core/SkRect.h"
16 #include "third_party/skia/include/core/SkRegion.h" 16 #include "third_party/skia/include/core/SkRegion.h"
17 #include "ui/display/types/display_snapshot.h"
17 #include "ui/gfx/gpu_memory_buffer.h" 18 #include "ui/gfx/gpu_memory_buffer.h"
18 #include "ui/gfx/skia_util.h" 19 #include "ui/gfx/skia_util.h"
19 20
20 namespace display_compositor { 21 namespace display_compositor {
21 22
22 BufferQueue::BufferQueue(gpu::gles2::GLES2Interface* gl, 23 BufferQueue::BufferQueue(gpu::gles2::GLES2Interface* gl,
23 uint32_t texture_target, 24 uint32_t texture_target,
24 uint32_t internal_format, 25 uint32_t internal_format,
26 gfx::BufferFormat format,
25 GLHelper* gl_helper, 27 GLHelper* gl_helper,
26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 28 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
27 gpu::SurfaceHandle surface_handle) 29 gpu::SurfaceHandle surface_handle)
28 : gl_(gl), 30 : gl_(gl),
29 fbo_(0), 31 fbo_(0),
30 allocated_count_(0), 32 allocated_count_(0),
31 texture_target_(texture_target), 33 texture_target_(texture_target),
32 internal_format_(internal_format), 34 internal_format_(internal_format),
35 format_(format),
33 gl_helper_(gl_helper), 36 gl_helper_(gl_helper),
34 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 37 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
35 surface_handle_(surface_handle) {} 38 surface_handle_(surface_handle) {
39 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat(internal_format,
40 format_));
41 }
36 42
37 BufferQueue::~BufferQueue() { 43 BufferQueue::~BufferQueue() {
38 FreeAllSurfaces(); 44 FreeAllSurfaces();
39 45
40 if (fbo_) 46 if (fbo_)
41 gl_->DeleteFramebuffers(1, &fbo_); 47 gl_->DeleteFramebuffers(1, &fbo_);
42 } 48 }
43 49
44 void BufferQueue::Initialize() { 50 void BufferQueue::Initialize() {
45 gl_->GenFramebuffers(1, &fbo_); 51 gl_->GenFramebuffers(1, &fbo_);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 std::move(available_surfaces_.back()); 210 std::move(available_surfaces_.back());
205 available_surfaces_.pop_back(); 211 available_surfaces_.pop_back();
206 return surface; 212 return surface;
207 } 213 }
208 214
209 GLuint texture; 215 GLuint texture;
210 gl_->GenTextures(1, &texture); 216 gl_->GenTextures(1, &texture);
211 217
212 // We don't want to allow anything more than triple buffering. 218 // We don't want to allow anything more than triple buffering.
213 DCHECK_LT(allocated_count_, 4U); 219 DCHECK_LT(allocated_count_, 4U);
214
215 std::unique_ptr<gfx::GpuMemoryBuffer> buffer( 220 std::unique_ptr<gfx::GpuMemoryBuffer> buffer(
216 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 221 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
217 size_, gpu::DefaultBufferFormatForImageFormat(internal_format_), 222 size_, format_, gfx::BufferUsage::SCANOUT, surface_handle_));
218 gfx::BufferUsage::SCANOUT, surface_handle_));
219 if (!buffer.get()) { 223 if (!buffer.get()) {
220 gl_->DeleteTextures(1, &texture); 224 gl_->DeleteTextures(1, &texture);
221 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; 225 DLOG(ERROR) << "Failed to allocate GPU memory buffer";
222 return nullptr; 226 return nullptr;
223 } 227 }
224 buffer->SetColorSpaceForScanout(color_space_); 228 buffer->SetColorSpaceForScanout(color_space_);
225 229
226 uint32_t id = 230 uint32_t id =
227 gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(), 231 gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(),
228 size_.height(), internal_format_); 232 size_.height(), internal_format_);
(...skipping 20 matching lines...) Expand all
249 buffer(buffer.release()), 253 buffer(buffer.release()),
250 texture(texture), 254 texture(texture),
251 image(image), 255 image(image),
252 damage(rect) {} 256 damage(rect) {}
253 257
254 BufferQueue::AllocatedSurface::~AllocatedSurface() { 258 BufferQueue::AllocatedSurface::~AllocatedSurface() {
255 buffer_queue->FreeSurfaceResources(this); 259 buffer_queue->FreeSurfaceResources(this);
256 } 260 }
257 261
258 } // namespace display_compositor 262 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698