Commit 1ea67932 authored by ccameron's avatar ccameron Committed by Commit bot

Color: Rename gfx::ColorProfile to gfx::ColorSpace

This is more accurate terminology. A color space can be represented
by ICC profile. There isn't really such a thing as a "color profile".

BUG=622133

Review-Url: https://codereview.chromium.org/2106303002
Cr-Commit-Position: refs/heads/master@{#403275}
parent 513a888b
...@@ -70,7 +70,6 @@ ...@@ -70,7 +70,6 @@
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "ppapi/shared_impl/file_type_conversion.h" #include "ppapi/shared_impl/file_type_conversion.h"
#include "ui/gfx/color_profile.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
#include "ui/base/touch/touch_enabled.h" #include "ui/base/touch/touch_enabled.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/gfx/animation/animation.h" #include "ui/gfx/animation/animation.h"
#include "ui/gfx/color_profile.h" #include "ui/gfx/color_space.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/native_theme/native_theme_switches.h" #include "ui/native_theme/native_theme_switches.h"
...@@ -371,7 +371,7 @@ bool RenderViewHostImpl::CreateRenderView( ...@@ -371,7 +371,7 @@ bool RenderViewHostImpl::CreateRenderView(
params.max_size = GetWidget()->max_size_for_auto_resize(); params.max_size = GetWidget()->max_size_for_auto_resize();
params.page_zoom_level = delegate_->GetPendingPageZoomLevel(); params.page_zoom_level = delegate_->GetPendingPageZoomLevel();
params.image_decode_color_profile = params.image_decode_color_profile =
gfx::ColorProfile::GetFromBestMonitor().profile(); gfx::ColorSpace::FromBestMonitor().GetICCProfile();
GetWidget()->GetResizeParams(&params.initial_size); GetWidget()->GetResizeParams(&params.initial_size);
if (!Send(new ViewMsg_New(params))) if (!Send(new ViewMsg_New(params)))
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
#include "third_party/WebKit/public/web/WebCompositionUnderline.h" #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/color_profile.h" #include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h" #include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/skbitmap_operations.h" #include "ui/gfx/skbitmap_operations.h"
...@@ -221,10 +221,10 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, ...@@ -221,10 +221,10 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
#if defined(OS_WIN) #if defined(OS_WIN)
// Update the display color profile cache so that it is likely to be up to // Update the display color profile cache so that it is likely to be up to
// date when the renderer process requests the color profile. // date when the renderer process requests the color profile.
if (gfx::ColorProfile::CachedProfilesNeedUpdate()) { if (gfx::ColorSpace::CachedProfilesNeedUpdate()) {
BrowserThread::PostBlockingPoolTask( BrowserThread::PostBlockingPoolTask(
FROM_HERE, FROM_HERE,
base::Bind(&gfx::ColorProfile::UpdateCachedProfilesOnBackgroundThread)); base::Bind(&gfx::ColorSpace::UpdateCachedProfilesOnBackgroundThread));
} }
#endif #endif
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
#include "ui/events/gesture_detection/gesture_configuration.h" #include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/gestures/gesture_recognizer.h" #include "ui/events/gestures/gesture_recognizer.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_profile.h"
#include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/geometry/size_conversions.h"
......
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/color_profile.h"
#include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_conversions.h"
......
...@@ -103,7 +103,6 @@ ...@@ -103,7 +103,6 @@
#include "third_party/WebKit/public/platform/mime_registry.mojom.h" #include "third_party/WebKit/public/platform/mime_registry.mojom.h"
#include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionListener.h" #include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionListener.h"
#include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceOrientationListener.h" #include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceOrientationListener.h"
#include "ui/gfx/color_profile.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
...@@ -62,10 +62,10 @@ component("gfx") { ...@@ -62,10 +62,10 @@ component("gfx") {
"color_analysis.cc", "color_analysis.cc",
"color_analysis.h", "color_analysis.h",
"color_palette.h", "color_palette.h",
"color_profile.cc", "color_space.cc",
"color_profile.h", "color_space.h",
"color_profile_mac.mm", "color_space_mac.mm",
"color_profile_win.cc", "color_space_win.cc",
"color_utils.cc", "color_utils.cc",
"color_utils.h", "color_utils.h",
"favicon_size.cc", "favicon_size.cc",
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/gfx/color_profile.h" #include "ui/gfx/color_space.h"
namespace gfx { namespace gfx {
...@@ -12,27 +12,32 @@ static const size_t kMinProfileLength = 128; ...@@ -12,27 +12,32 @@ static const size_t kMinProfileLength = 128;
static const size_t kMaxProfileLength = 4 * 1024 * 1024; static const size_t kMaxProfileLength = 4 * 1024 * 1024;
} }
ColorProfile::ColorProfile(const std::vector<char>& profile) ColorSpace::ColorSpace() = default;
: profile_(profile) { ColorSpace::ColorSpace(ColorSpace&& other) = default;
if (!IsValidProfileLength(profile_.size())) ColorSpace::ColorSpace(const ColorSpace& other) = default;
profile_.clear(); ColorSpace& ColorSpace::operator=(const ColorSpace& other) = default;
ColorSpace::~ColorSpace() = default;
bool ColorSpace::operator==(const ColorSpace& other) const {
return icc_profile_ == other.icc_profile_;
} }
ColorProfile::ColorProfile() = default; ColorSpace ColorSpace::FromICCProfile(const std::vector<char>& icc_profile) {
ColorProfile::ColorProfile(ColorProfile&& other) = default; ColorSpace color_space;
ColorProfile::ColorProfile(const ColorProfile& other) = default; if (IsValidProfileLength(icc_profile.size()))
ColorProfile& ColorProfile::operator=(const ColorProfile& other) = default; color_space.icc_profile_ = icc_profile;
ColorProfile::~ColorProfile() = default; return color_space;
}
#if !defined(OS_WIN) && !defined(OS_MACOSX) #if !defined(OS_WIN) && !defined(OS_MACOSX)
// static // static
ColorProfile ColorProfile::GetFromBestMonitor() { ColorSpace ColorSpace::FromBestMonitor() {
return ColorProfile(); return ColorSpace();
} }
#endif #endif
// static // static
bool ColorProfile::IsValidProfileLength(size_t length) { bool ColorSpace::IsValidProfileLength(size_t length) {
return length >= kMinProfileLength && length <= kMaxProfileLength; return length >= kMinProfileLength && length <= kMaxProfileLength;
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_GFX_COLOR_PROFILE_H_ #ifndef UI_GFX_COLOR_SPACE_H_
#define UI_GFX_COLOR_PROFILE_H_ #define UI_GFX_COLOR_SPACE_H_
#include <vector> #include <vector>
...@@ -13,36 +13,36 @@ ...@@ -13,36 +13,36 @@
namespace gfx { namespace gfx {
class GFX_EXPORT ColorProfile { class GFX_EXPORT ColorSpace {
public: public:
ColorProfile(const std::vector<char>& profile); ColorSpace();
ColorProfile(); ColorSpace(ColorSpace&& other);
ColorProfile(ColorProfile&& other); ColorSpace(const ColorSpace& other);
ColorProfile(const ColorProfile& other); ColorSpace& operator=(const ColorSpace& other);
ColorProfile& operator=(const ColorProfile& other); ~ColorSpace();
~ColorProfile(); bool operator==(const ColorSpace& other) const;
const std::vector<char>& profile() const { return profile_; } // Returns the color profile of the monitor that can best represent color.
// This profile should be used for creating content that does not know on
// which monitor it will be displayed.
static ColorSpace FromBestMonitor();
static ColorSpace FromICCProfile(const std::vector<char>& icc_profile);
const std::vector<char>& GetICCProfile() const { return icc_profile_; }
#if defined(OS_WIN) #if defined(OS_WIN)
// This will read color profile information from disk and cache the results // This will read monitor ICC profiles from disk and cache the results for the
// for the other functions to read. This should not be called on the UI or IO // other functions to read. This should not be called on the UI or IO thread.
// thread.
static void UpdateCachedProfilesOnBackgroundThread(); static void UpdateCachedProfilesOnBackgroundThread();
static bool CachedProfilesNeedUpdate(); static bool CachedProfilesNeedUpdate();
#endif #endif
// Returns the color profile of the monitor that can best represent color.
// This profile should be used for creating content that does not know on
// which monitor it will be displayed.
static ColorProfile GetFromBestMonitor();
static bool IsValidProfileLength(size_t length); static bool IsValidProfileLength(size_t length);
private: private:
std::vector<char> profile_; std::vector<char> icc_profile_;
}; };
} // namespace gfx } // namespace gfx
#endif // UI_GFX_COLOR_PROFILE_H_ #endif // UI_GFX_COLOR_SPACE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/gfx/color_profile.h" #include "ui/gfx/color_space.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <stddef.h> #include <stddef.h>
...@@ -14,19 +14,19 @@ ...@@ -14,19 +14,19 @@
namespace gfx { namespace gfx {
// static // static
ColorProfile ColorProfile::GetFromBestMonitor() { ColorSpace ColorSpace::FromBestMonitor() {
ColorProfile profile; ColorSpace color_space;
CGColorSpaceRef monitor_color_space(base::mac::GetSystemColorSpace()); CGColorSpaceRef monitor_color_space(base::mac::GetSystemColorSpace());
base::ScopedCFTypeRef<CFDataRef> icc_profile( base::ScopedCFTypeRef<CFDataRef> icc_profile(
CGColorSpaceCopyICCProfile(monitor_color_space)); CGColorSpaceCopyICCProfile(monitor_color_space));
if (!icc_profile) if (!icc_profile)
return profile; return color_space;
size_t length = CFDataGetLength(icc_profile); size_t length = CFDataGetLength(icc_profile);
if (!IsValidProfileLength(length)) if (!IsValidProfileLength(length))
return profile; return color_space;
const unsigned char* data = CFDataGetBytePtr(icc_profile); const unsigned char* data = CFDataGetBytePtr(icc_profile);
profile.profile_.assign(data, data + length); color_space.icc_profile_.assign(data, data + length);
return profile; return color_space;
} }
} // namespace gfx } // namespace gfx
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/gfx/color_profile.h" #include "ui/gfx/color_space.h"
#include <windows.h> #include <windows.h>
#include <stddef.h> #include <stddef.h>
...@@ -17,7 +17,7 @@ namespace gfx { ...@@ -17,7 +17,7 @@ namespace gfx {
namespace { namespace {
void ReadBestMonitorColorProfile(std::vector<char>* profile) { void ReadBestMonitorICCProfile(std::vector<char>* profile) {
HDC screen_dc = GetDC(NULL); HDC screen_dc = GetDC(NULL);
DWORD path_len = MAX_PATH; DWORD path_len = MAX_PATH;
WCHAR path[MAX_PATH + 1]; WCHAR path[MAX_PATH + 1];
...@@ -26,43 +26,43 @@ void ReadBestMonitorColorProfile(std::vector<char>* profile) { ...@@ -26,43 +26,43 @@ void ReadBestMonitorColorProfile(std::vector<char>* profile) {
ReleaseDC(NULL, screen_dc); ReleaseDC(NULL, screen_dc);
if (!result) if (!result)
return; return;
std::string profileData; std::string profile_data;
if (!base::ReadFileToString(base::FilePath(path), &profileData)) if (!base::ReadFileToString(base::FilePath(path), &profile_data))
return; return;
size_t length = profileData.size(); size_t length = profile_data.size();
if (!ColorProfile::IsValidProfileLength(length)) if (!ColorSpace::IsValidProfileLength(length))
return; return;
profile->assign(profileData.data(), profileData.data() + length); profile->assign(profile_data.data(), profile_data.data() + length);
} }
base::LazyInstance<base::Lock> g_best_color_profile_lock = base::LazyInstance<base::Lock> g_best_monitor_color_space_lock =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<gfx::ColorProfile> g_best_color_profile = base::LazyInstance<gfx::ColorSpace> g_best_monitor_color_space =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
bool g_has_initialized_best_color_profile = false; bool g_has_initialized_best_monitor_color_space = false;
} // namespace } // namespace
// static // static
ColorProfile ColorProfile::GetFromBestMonitor() { ColorSpace ColorSpace::FromBestMonitor() {
base::AutoLock lock(g_best_color_profile_lock.Get()); base::AutoLock lock(g_best_monitor_color_space_lock.Get());
return g_best_color_profile.Get(); return g_best_monitor_color_space.Get();
} }
// static // static
bool ColorProfile::CachedProfilesNeedUpdate() { bool ColorSpace::CachedProfilesNeedUpdate() {
base::AutoLock lock(g_best_color_profile_lock.Get()); base::AutoLock lock(g_best_monitor_color_space_lock.Get());
return !g_has_initialized_best_color_profile; return !g_has_initialized_best_monitor_color_space;
} }
// static // static
void ColorProfile::UpdateCachedProfilesOnBackgroundThread() { void ColorSpace::UpdateCachedProfilesOnBackgroundThread() {
std::vector<char> profile; std::vector<char> icc_profile;
ReadBestMonitorColorProfile(&profile); ReadBestMonitorICCProfile(&icc_profile);
base::AutoLock lock(g_best_color_profile_lock.Get()); base::AutoLock lock(g_best_monitor_color_space_lock.Get());
g_best_color_profile.Get().profile_ = profile; g_best_monitor_color_space.Get().icc_profile_ = icc_profile;
g_has_initialized_best_color_profile = true; g_has_initialized_best_monitor_color_space = true;
} }
} // namespace gfx } // namespace gfx
...@@ -196,10 +196,10 @@ ...@@ -196,10 +196,10 @@
'color_analysis.cc', 'color_analysis.cc',
'color_analysis.h', 'color_analysis.h',
'color_palette.h', 'color_palette.h',
'color_profile.cc', 'color_space.cc',
'color_profile.h', 'color_space.h',
'color_profile_mac.mm', 'color_space_mac.mm',
'color_profile_win.cc', 'color_space_win.cc',
'color_utils.cc', 'color_utils.cc',
'color_utils.h', 'color_utils.h',
'favicon_size.cc', 'favicon_size.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment