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

Unified Diff: Source/platform/graphics/ColorSpace.cpp

Issue 134733016: Add support for converting Colors to linear RGB; Fix relevant filters (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: Source/platform/graphics/ColorSpace.cpp
diff --git a/Source/core/inspector/ScriptCallStack.cpp b/Source/platform/graphics/ColorSpace.cpp
similarity index 56%
copy from Source/core/inspector/ScriptCallStack.cpp
copy to Source/platform/graphics/ColorSpace.cpp
index 0a23bb4fae5e220311cfbca54f8400416864c56c..cb77ac8fead467f9a79b4131842db2b1bd99179d 100644
--- a/Source/core/inspector/ScriptCallStack.cpp
+++ b/Source/platform/graphics/ColorSpace.cpp
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
+ * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,59 +31,42 @@
*/
#include "config.h"
-#include "core/inspector/ScriptCallStack.h"
+#include "platform/graphics/ColorSpace.h"
+#include "wtf/MathExtras.h"
namespace WebCore {
-PassRefPtr<ScriptCallStack> ScriptCallStack::create(Vector<ScriptCallFrame>& frames)
+const Vector<uint8_t>& getLinearRgbLUT()
{
- return adoptRef(new ScriptCallStack(frames));
-}
-
-ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames)
-{
- m_frames.swap(frames);
-}
-
-ScriptCallStack::~ScriptCallStack()
-{
-}
-
-const ScriptCallFrame &ScriptCallStack::at(size_t index) const
-{
- ASSERT(m_frames.size() > index);
- return m_frames[index];
-}
-
-size_t ScriptCallStack::size() const
-{
- return m_frames.size();
-}
-
-bool ScriptCallStack::isEqual(ScriptCallStack* o) const
-{
- if (!o)
- return false;
-
- size_t frameCount = o->m_frames.size();
- if (frameCount != m_frames.size())
- return false;
-
- for (size_t i = 0; i < frameCount; ++i) {
- if (!m_frames[i].isEqual(o->m_frames[i]))
- return false;
+ DEFINE_STATIC_LOCAL(Vector<uint8_t>, linearRgbLUT, ());
+ if (linearRgbLUT.isEmpty()) {
+ linearRgbLUT.reserveCapacity(256);
+ for (unsigned i = 0; i < 256; i++) {
+ float color = i / 255.0f;
+ color = (color <= 0.04045f ? color / 12.92f : pow((color + 0.055f) / 1.055f, 2.4f));
+ color = std::max(0.0f, color);
+ color = std::min(1.0f, color);
+ linearRgbLUT.append(static_cast<uint8_t>(round(color * 255)));
+ }
}
-
- return true;
+ return linearRgbLUT;
}
-PassRefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > ScriptCallStack::buildInspectorArray() const
+const Vector<uint8_t>& getDeviceRgbLUT()
{
- RefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > frames = TypeBuilder::Array<TypeBuilder::Console::CallFrame>::create();
- for (size_t i = 0; i < m_frames.size(); i++)
- frames->addItem(m_frames.at(i).buildInspectorObject());
- return frames;
+ DEFINE_STATIC_LOCAL(Vector<uint8_t>, deviceRgbLUT, ());
+ if (deviceRgbLUT.isEmpty()) {
+ deviceRgbLUT.reserveCapacity(256);
+ for (unsigned i = 0; i < 256; i++) {
+ float color = i / 255.0f;
+ color = (powf(color, 1.0f / 2.4f) * 1.055f) - 0.055f;
+ color = std::max(0.0f, color);
+ color = std::min(1.0f, color);
+ deviceRgbLUT.append(static_cast<uint8_t>(round(color * 255)));
+ }
+ }
+ return deviceRgbLUT;
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698