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

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

Issue 2119723002: Color: Add SetColorSpace member to gfx::GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumb_2
Patch Set: Add OWNERs Created 4 years, 5 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"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 current_surface_->damage = gfx::Rect(); 101 current_surface_->damage = gfx::Rect();
102 } 102 }
103 UpdateBufferDamage(damage); 103 UpdateBufferDamage(damage);
104 in_flight_surfaces_.push_back(std::move(current_surface_)); 104 in_flight_surfaces_.push_back(std::move(current_surface_));
105 // Some things reset the framebuffer (CopySubBufferDamage, some GLRenderer 105 // Some things reset the framebuffer (CopySubBufferDamage, some GLRenderer
106 // paths), so ensure we restore it here. 106 // paths), so ensure we restore it here.
107 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_); 107 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
108 } 108 }
109 109
110 void BufferQueue::Reshape(const gfx::Size& size, float scale_factor) { 110 void BufferQueue::Reshape(const gfx::Size& size,
111 if (size == size_) 111 float scale_factor,
112 const gfx::ColorSpace& color_space) {
113 if (size == size_ && color_space == color_space_)
hubbe 2016/07/06 21:30:53 Isn't this the kind of comparison you were worried
112 return; 114 return;
113 #if !defined(OS_MACOSX) 115 #if !defined(OS_MACOSX)
114 // TODO(ccameron): This assert is being hit on Mac try jobs. Determine if that 116 // TODO(ccameron): This assert is being hit on Mac try jobs. Determine if that
115 // is cause for concern or if it is benign. 117 // is cause for concern or if it is benign.
116 // http://crbug.com/524624 118 // http://crbug.com/524624
117 DCHECK(!current_surface_); 119 DCHECK(!current_surface_);
118 #endif 120 #endif
119 size_ = size; 121 size_ = size;
122 color_space_ = color_space;
120 123
121 // TODO: add stencil buffer when needed. 124 // TODO: add stencil buffer when needed.
122 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_); 125 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
123 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 126 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
124 texture_target_, 0, 0); 127 texture_target_, 0, 0);
125 128
126 FreeAllSurfaces(); 129 FreeAllSurfaces();
127 } 130 }
128 131
129 void BufferQueue::RecreateBuffers() { 132 void BufferQueue::RecreateBuffers() {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 214
212 std::unique_ptr<gfx::GpuMemoryBuffer> buffer( 215 std::unique_ptr<gfx::GpuMemoryBuffer> buffer(
213 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 216 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
214 size_, gpu::DefaultBufferFormatForImageFormat(internal_format_), 217 size_, gpu::DefaultBufferFormatForImageFormat(internal_format_),
215 gfx::BufferUsage::SCANOUT, surface_handle_)); 218 gfx::BufferUsage::SCANOUT, surface_handle_));
216 if (!buffer.get()) { 219 if (!buffer.get()) {
217 gl_->DeleteTextures(1, &texture); 220 gl_->DeleteTextures(1, &texture);
218 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; 221 DLOG(ERROR) << "Failed to allocate GPU memory buffer";
219 return nullptr; 222 return nullptr;
220 } 223 }
224 buffer->SetColorSpaceForScanout(color_space_);
221 225
222 uint32_t id = 226 uint32_t id =
223 gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(), 227 gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(),
224 size_.height(), internal_format_); 228 size_.height(), internal_format_);
225 if (!id) { 229 if (!id) {
226 LOG(ERROR) << "Failed to allocate backing image surface"; 230 LOG(ERROR) << "Failed to allocate backing image surface";
227 gl_->DeleteTextures(1, &texture); 231 gl_->DeleteTextures(1, &texture);
228 return nullptr; 232 return nullptr;
229 } 233 }
230 234
(...skipping 14 matching lines...) Expand all
245 buffer(buffer.release()), 249 buffer(buffer.release()),
246 texture(texture), 250 texture(texture),
247 image(image), 251 image(image),
248 damage(rect) {} 252 damage(rect) {}
249 253
250 BufferQueue::AllocatedSurface::~AllocatedSurface() { 254 BufferQueue::AllocatedSurface::~AllocatedSurface() {
251 buffer_queue->FreeSurfaceResources(this); 255 buffer_queue->FreeSurfaceResources(this);
252 } 256 }
253 257
254 } // namespace display_compositor 258 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698