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

Side by Side Diff: gpu/ipc/client/gpu_memory_buffer_impl_io_surface.cc

Issue 2161293002: Color: Separate ICCProfile and ColorSpace structures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporate review feedback 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
« no previous file with comments | « gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h" 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 9 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
11 #include "ui/gfx/color_space.h" 11 #include "ui/gfx/icc_profile.h"
12 #include "ui/gfx/mac/io_surface.h" 12 #include "ui/gfx/mac/io_surface.h"
13 13
14 namespace gpu { 14 namespace gpu {
15 namespace { 15 namespace {
16 16
17 uint32_t LockFlags(gfx::BufferUsage usage) { 17 uint32_t LockFlags(gfx::BufferUsage usage) {
18 switch (usage) { 18 switch (usage) {
19 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: 19 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
20 return kIOSurfaceLockAvoidSync; 20 return kIOSurfaceLockAvoidSync;
21 case gfx::BufferUsage::GPU_READ: 21 case gfx::BufferUsage::GPU_READ:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 mapped_ = false; 105 mapped_ = false;
106 } 106 }
107 107
108 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const { 108 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const {
109 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); 109 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
110 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane); 110 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane);
111 } 111 }
112 112
113 void GpuMemoryBufferImplIOSurface::SetColorSpaceForScanout( 113 void GpuMemoryBufferImplIOSurface::SetColorSpaceForScanout(
114 const gfx::ColorSpace& color_space) { 114 const gfx::ColorSpace& color_space) {
115 const std::vector<char>& icc_profile = color_space.GetICCProfile(); 115 if (color_space == color_space_)
116 return;
117 color_space_ = color_space;
118 std::vector<char> icc_profile =
119 gfx::ICCProfile::FromColorSpace(color_space).GetData();
116 if (icc_profile.size()) { 120 if (icc_profile.size()) {
117 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate( 121 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate(
118 nullptr, reinterpret_cast<const UInt8*>(icc_profile.data()), 122 nullptr, reinterpret_cast<const UInt8*>(icc_profile.data()),
119 icc_profile.size())); 123 icc_profile.size()));
120 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"), 124 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"),
121 cf_data_icc_profile); 125 cf_data_icc_profile);
122 } 126 }
123 } 127 }
124 128
125 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 129 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
126 gfx::GpuMemoryBufferHandle handle; 130 gfx::GpuMemoryBufferHandle handle;
127 handle.type = gfx::IO_SURFACE_BUFFER; 131 handle.type = gfx::IO_SURFACE_BUFFER;
128 handle.id = id_; 132 handle.id = id_;
129 return handle; 133 return handle;
130 } 134 }
131 135
132 } // namespace gpu 136 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698