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

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: DCHECK(GL_RGBA, internal_format_); 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_mode.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,
25 GLHelper* gl_helper, 26 GLHelper* gl_helper,
26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 27 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 available_surfaces_.pop_back(); 206 available_surfaces_.pop_back();
206 return surface; 207 return surface;
207 } 208 }
208 209
209 GLuint texture; 210 GLuint texture;
210 gl_->GenTextures(1, &texture); 211 gl_->GenTextures(1, &texture);
211 212
212 // We don't want to allow anything more than triple buffering. 213 // We don't want to allow anything more than triple buffering.
213 DCHECK_LT(allocated_count_, 4U); 214 DCHECK_LT(allocated_count_, 4U);
214 215
216 gfx::BufferFormat format = ui::DisplayMode::PrimaryFormat();
217 DCHECK_EQ(static_cast<uint32_t>(GL_RGBA), internal_format_);
215 std::unique_ptr<gfx::GpuMemoryBuffer> buffer( 218 std::unique_ptr<gfx::GpuMemoryBuffer> buffer(
216 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 219 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
217 size_, gpu::DefaultBufferFormatForImageFormat(internal_format_), 220 size_, format, gfx::BufferUsage::SCANOUT, surface_handle_));
218 gfx::BufferUsage::SCANOUT, surface_handle_));
219 if (!buffer.get()) { 221 if (!buffer.get()) {
220 gl_->DeleteTextures(1, &texture); 222 gl_->DeleteTextures(1, &texture);
221 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; 223 DLOG(ERROR) << "Failed to allocate GPU memory buffer";
222 return nullptr; 224 return nullptr;
223 } 225 }
224 buffer->SetColorSpaceForScanout(color_space_); 226 buffer->SetColorSpaceForScanout(color_space_);
225 227
226 uint32_t id = 228 uint32_t id =
227 gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(), 229 gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(),
228 size_.height(), internal_format_); 230 size_.height(), internal_format_);
(...skipping 20 matching lines...) Expand all
249 buffer(buffer.release()), 251 buffer(buffer.release()),
250 texture(texture), 252 texture(texture),
251 image(image), 253 image(image),
252 damage(rect) {} 254 damage(rect) {}
253 255
254 BufferQueue::AllocatedSurface::~AllocatedSurface() { 256 BufferQueue::AllocatedSurface::~AllocatedSurface() {
255 buffer_queue->FreeSurfaceResources(this); 257 buffer_queue->FreeSurfaceResources(this);
256 } 258 }
257 259
258 } // namespace display_compositor 260 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698