WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-118331-20131025151451.patch (text/plain), 89.36 KB, created by
Hugo Parente Lima
on 2013-10-25 11:12:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Hugo Parente Lima
Created:
2013-10-25 11:12:11 PDT
Size:
89.36 KB
patch
obsolete
>Subversion Revision: 157800 >diff --git a/Source/Platform/ChangeLog b/Source/Platform/ChangeLog >index ecb85887df278ea08e8835f0eb2812d2a1e1733d..4f80738fc0e6f1878a672f5554041e4c193f6c9d 100644 >--- a/Source/Platform/ChangeLog >+++ b/Source/Platform/ChangeLog >@@ -1,3 +1,30 @@ >+2013-10-25 Hugo Parente Lima <hugo.lima@openbossa.org> >+ >+ Adding Nix files in Source/Platform to trunk >+ https://bugs.webkit.org/show_bug.cgi?id=118331 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add files part of Nix public API used to implement >+ backends for some WebKit subsystems on Application side. >+ >+ * nix/public/AudioDevice.h: Added. >+ * nix/public/Canvas.h: Added. >+ * nix/public/Color.h: Added. >+ * nix/public/Common.h: Added. >+ * nix/public/FFTFrame.h: Added. >+ * nix/public/Gamepad.h: Added. >+ * nix/public/Gamepads.h: Added. >+ * nix/public/MediaPlayer.h: Added. >+ * nix/public/MultiChannelPCMData.h: Added. >+ * nix/public/Platform.h: Added. >+ * nix/public/Rect.h: Added. >+ * nix/public/Size.h: Added. >+ * nix/public/ThemeEngine.h: Added. >+ * nix/src/DefaultWebThemeEngine.cpp: Added. >+ * nix/src/DefaultWebThemeEngine.h: Added. >+ * nix/src/Platform.cpp: Added. >+ > 2013-06-14 Zan Dobersek <zdobersek@igalia.com> > > Unreviewed GTK build fix. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f184bba66fca73dc10b4e33b3d9c2c02ccd78f0b..31d10d9b9bee0eae12794c01c842d6ff51e344ce 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2013-10-25 Hugo Parente Lima <hugo.lima@openbossa.org> >+ >+ Adding Nix files in Source/Platform to trunk >+ https://bugs.webkit.org/show_bug.cgi?id=118331 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add Nix WebAudio implementation that just forward some calls to our API. >+ This patch is part of the upstream process, tests will be landed by other patches. >+ >+ * platform/audio/nix/AudioBusNix.cpp: Added. >+ * platform/audio/nix/AudioDestinationNix.cpp: Added. >+ * platform/audio/nix/AudioDestinationNix.h: Added. >+ * platform/audio/nix/FFTFrameNix.cpp: Added. >+ * platform/nix/support/MultiChannelPCMData.cpp: Added. >+ > 2013-10-22 peavo@outlook.com <peavo@outlook.com> > > [WinCairo] Compile error. >diff --git a/Source/Platform/nix/public/AudioDevice.h b/Source/Platform/nix/public/AudioDevice.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7a0faa4d6ed6a56dfdbeed6279308c8ab4859dc9 >--- /dev/null >+++ b/Source/Platform/nix/public/AudioDevice.h >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2010 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_AudioDevice_h >+#define Nix_AudioDevice_h >+ >+#include <cstddef> >+#include <vector> >+ >+namespace Nix { >+ >+class AudioDevice { >+public: >+ class RenderCallback { >+ public: >+ virtual void render(const std::vector<float*>& /*sourceData*/, const std::vector<float*>& /*destinationData*/, size_t /*numberOfFrames*/) = 0; >+ >+ protected: >+ virtual ~RenderCallback() { } >+ }; >+ >+ virtual ~AudioDevice() { } >+ >+ virtual void start() = 0; >+ virtual void stop() = 0; >+ virtual double sampleRate() = 0; >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_AudioDevice_h >diff --git a/Source/Platform/nix/public/Canvas.h b/Source/Platform/nix/public/Canvas.h >new file mode 100644 >index 0000000000000000000000000000000000000000..92edd373ef7449747fe83b99cadb3ba8cdeb1799 >--- /dev/null >+++ b/Source/Platform/nix/public/Canvas.h >@@ -0,0 +1,36 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+#ifndef Nix_Canvas_h >+#define Nix_Canvas_h >+ >+#include <cairo/cairo.h> >+ >+namespace Nix { >+ >+typedef cairo_t Canvas; >+ >+} // namespace Nix >+ >+#endif // Nix_Canvas_h >diff --git a/Source/Platform/nix/public/Color.h b/Source/Platform/nix/public/Color.h >new file mode 100644 >index 0000000000000000000000000000000000000000..91a22f4741abb9d54ffe9986b1da63bcbe956ee3 >--- /dev/null >+++ b/Source/Platform/nix/public/Color.h >@@ -0,0 +1,108 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+*/ >+ >+#ifndef Nix_Color_h >+#define Nix_Color_h >+ >+#include <algorithm> >+#include <cstddef> >+ >+namespace Nix { >+ >+class Color { >+public: >+ typedef u_int32_t ARGB32; // ARGB quadruplet >+ >+ static const ARGB32 black = 0xFF000000; >+ static const ARGB32 white = 0xFFFFFFFF; >+ static const ARGB32 red = 0xFFFF0000; >+ static const ARGB32 green = 0xFF00FF00; >+ static const ARGB32 blue = 0xFF0000FF; >+ static const ARGB32 darkGray = 0xFF808080; >+ static const ARGB32 gray = 0xFFA0A0A0; >+ static const ARGB32 lightGray = 0xFFC0C0C0; >+ static const ARGB32 transparent = 0x00000000; >+ >+ Color(ARGB32 rgba) >+ : m_argb(rgba) >+ { >+ } >+ >+ Color(int r, int g, int b, int a = 255) >+ : m_argb(fixValue(a) << 24 | fixValue(r) << 16 | fixValue(g) << 8 | fixValue(b)) >+ { >+ } >+ >+ operator ARGB32() const >+ { >+ return m_argb; >+ } >+ >+ unsigned char r() const >+ { >+ return (m_argb & 0x00FF0000) >> 16; >+ } >+ >+ unsigned char g() const >+ { >+ return (m_argb & 0x0000FF00) >> 8; >+ } >+ >+ unsigned char b() const >+ { >+ return (m_argb & 0x000000FF); >+ } >+ >+ unsigned char a() const >+ { >+ return (m_argb & 0xFF000000) >> 24; >+ } >+ >+ ARGB32 argb32() const >+ { >+ return m_argb; >+ } >+ >+ bool operator==(const Color& other) >+ { >+ return m_argb == other.m_argb; >+ } >+ >+ bool operator!=(const Color& other) >+ { >+ return m_argb != other.m_argb; >+ } >+ >+private: >+ ARGB32 m_argb; >+ static inline ARGB32 fixValue(int value) >+ { >+ return std::max(0, std::min(value, 255)); >+ } >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_Color_h >diff --git a/Source/Platform/nix/public/Common.h b/Source/Platform/nix/public/Common.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0769e5b2cd836b1234aac97c73ebe1e86b2d7961 >--- /dev/null >+++ b/Source/Platform/nix/public/Common.h >@@ -0,0 +1,34 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_Common_h >+#define Nix_Common_h >+ >+// Exported symbols need to be annotated with NIX_EXPORT >+#define NIX_EXPORT __attribute__((visibility("default"))) >+ >+#include <stddef.h> // For size_t >+ >+#endif // Nix_Common_h >diff --git a/Source/Platform/nix/public/FFTFrame.h b/Source/Platform/nix/public/FFTFrame.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0219a721f77af0ecb4c2e5fa8a4fbfead632c8d1 >--- /dev/null >+++ b/Source/Platform/nix/public/FFTFrame.h >@@ -0,0 +1,56 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+#ifndef Nix_FFTFrame_h >+#define Nix_FFTFrame_h >+ >+namespace Nix { >+ >+class FFTFrame { >+public: >+ FFTFrame() { } >+ virtual ~FFTFrame() { } >+ >+ virtual FFTFrame* copy() const = 0; >+ >+ virtual void doFFT(const float*) = 0; >+ virtual void doInverseFFT(float*) = 0; >+ >+ virtual unsigned frequencyDomainSampleCount() const = 0; >+ // After multiplication and transform operations, the data is scaled >+ // to take in account the scale used internally in WebKit, originally >+ // from Mac's vecLib. >+ // After multiplication: Planar data is scaled by 0.5. >+ // After direct transform: Planar data is scaled by 2.0. >+ // After inverse transform: Time domain data is scaled by 1.0/(2* FFT size). >+ virtual float* realData() const = 0; >+ virtual float* imagData() const = 0; >+private: >+ FFTFrame(const FFTFrame&); >+ FFTFrame& operator=(const FFTFrame&); >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_FFTFrame_h >diff --git a/Source/Platform/nix/public/Gamepad.h b/Source/Platform/nix/public/Gamepad.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d2e7e36ddd6f3fc233c9188ad1f4a50bd37ebf0f >--- /dev/null >+++ b/Source/Platform/nix/public/Gamepad.h >@@ -0,0 +1,74 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_Gamepad_h >+#define Nix_Gamepad_h >+ >+#include "Common.h" >+ >+namespace Nix { >+ >+class Gamepad { >+public: >+ static const size_t idLengthCap = 128; >+ static const size_t axesLengthCap = 16; >+ static const size_t buttonsLengthCap = 32; >+ >+ Gamepad() >+ : connected(false) >+ , timestamp(0) >+ , axesLength(0) >+ , buttonsLength(0) >+ { >+ id[0] = 0; >+ } >+ >+ // Is there a gamepad connected at this index? >+ bool connected; >+ >+ // Device identifier (based on manufacturer, model, etc.). >+ char id[idLengthCap]; >+ >+ // Monotonically increasing value referring to when the data were last >+ // updated. >+ unsigned long long timestamp; >+ >+ // Number of valid entries in the axes array. >+ unsigned axesLength; >+ >+ // Normalized values representing axes, in the range [-1..1]. >+ float axes[axesLengthCap]; >+ >+ // Number of valid entries in the buttons array. >+ unsigned buttonsLength; >+ >+ // Normalized values representing buttons, in the range [0..1]. >+ float buttons[buttonsLengthCap]; >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_Gamepad_h >diff --git a/Source/Platform/nix/public/Gamepads.h b/Source/Platform/nix/public/Gamepads.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0b38eb8ce8708cffabc2adedd0c2d55887dda5e4 >--- /dev/null >+++ b/Source/Platform/nix/public/Gamepads.h >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_Gamepads_h >+#define Nix_Gamepads_h >+ >+#include "Gamepad.h" >+ >+namespace Nix { >+ >+class Gamepads { >+public: >+ Gamepads() >+ : length(0) >+ { } >+ >+ static const size_t itemsLengthCap = 4; >+ >+ // Number of valid entries in the items array. >+ unsigned length; >+ >+ // Gamepad data for N separate gamepad devices. >+ Gamepad items[itemsLengthCap]; >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_Gamepads_h >diff --git a/Source/Platform/nix/public/MediaPlayer.h b/Source/Platform/nix/public/MediaPlayer.h >new file mode 100644 >index 0000000000000000000000000000000000000000..265d4868d830009384ff4609557e7440c53df418 >--- /dev/null >+++ b/Source/Platform/nix/public/MediaPlayer.h >@@ -0,0 +1,76 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_MediaPlayer >+#define Nix_MediaPlayer >+ >+namespace Nix { >+ >+class MediaPlayerClient { >+public: >+ enum ReadyState { HaveNothing, HaveMetadata, HaveCurrentData, HaveFutureData, HaveEnoughData }; >+ enum NetworkState { Empty, Idle, Loading, Loaded, FormatError, NetworkError, DecodeError }; >+ >+ virtual ~MediaPlayerClient() { } >+ virtual void durationChanged() const = 0; >+ virtual void currentTimeChanged() const = 0; >+ virtual void readyStateChanged(ReadyState) = 0; >+ virtual void networkStateChanged(NetworkState) = 0; >+}; >+ >+class MediaPlayer { >+public: >+ // Derivated classes shouldn't do any job on constructor, MediaPlayers could be >+ // created for probing purposes with a null client. >+ MediaPlayer(MediaPlayerClient* client) >+ : m_playerClient(client) >+ { >+ } >+ >+ virtual ~MediaPlayer() >+ { >+ delete m_playerClient; >+ } >+ >+ virtual void play() = 0; >+ virtual void pause() = 0; >+ virtual void seek(float) = 0; >+ virtual float duration() const = 0; >+ virtual float currentTime() const = 0; >+ virtual void setVolume(float) = 0; >+ virtual void setMuted(bool) = 0; >+ virtual void load(const char* url) = 0; >+ virtual bool seeking() const = 0; >+ virtual float maxTimeSeekable() const = 0; >+ virtual void setPlaybackRate(float) = 0; >+ virtual bool isLiveStream() const = 0; >+ >+protected: >+ MediaPlayerClient* m_playerClient; >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_MediaPlayer_h >diff --git a/Source/Platform/nix/public/MultiChannelPCMData.h b/Source/Platform/nix/public/MultiChannelPCMData.h >new file mode 100644 >index 0000000000000000000000000000000000000000..abbef8bff0f8051a375d63e11520bfb2dc31f212 >--- /dev/null >+++ b/Source/Platform/nix/public/MultiChannelPCMData.h >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_MultiChannelPCMData_h >+#define Nix_MultiChannelPCMData_h >+ >+#include "Common.h" >+ >+namespace Nix { >+ >+// A container for multi-channel linear PCM audio data. >+class NIX_EXPORT MultiChannelPCMData { >+public: >+ MultiChannelPCMData(unsigned numberOfChannels, size_t length, double sampleRate); >+ ~MultiChannelPCMData(); >+ >+ unsigned numberOfChannels() const; >+ size_t length() const; >+ double sampleRate() const; >+ >+ // This can return null if Nix was compiled without WebAudio support. >+ float* channelData(unsigned channelIndex); >+ >+#ifdef BUILDING_NIX__ >+ void* getInternalData(); >+#endif >+ >+private: >+ MultiChannelPCMData(const MultiChannelPCMData&); >+ void operator=(const MultiChannelPCMData&); >+ >+ void* m_data; >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_MultiChannelPCMData_h >diff --git a/Source/Platform/nix/public/Platform.h b/Source/Platform/nix/public/Platform.h >new file mode 100644 >index 0000000000000000000000000000000000000000..f82a87caa1a0acc2081b8360996eda4bdd276953 >--- /dev/null >+++ b/Source/Platform/nix/public/Platform.h >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_Platform_h >+#define Nix_Platform_h >+ >+#include "AudioDevice.h" >+#include "Gamepads.h" >+#include <stdint.h> >+ >+namespace Nix { >+ >+class MultiChannelPCMData; >+class FFTFrame; >+class ThemeEngine; >+class MediaPlayer; >+class MediaPlayerClient; >+ >+class NIX_EXPORT Platform { >+public: >+ >+ static void initialize(Platform*); >+ static Platform* current(); >+ >+ // Audio >+ virtual float audioHardwareSampleRate() { return 0; } >+ virtual size_t audioHardwareBufferSize() { return 0; } >+ virtual unsigned audioHardwareOutputChannels() { return 0; } >+ >+ // Creates a device for audio I/O. >+ // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. >+ virtual AudioDevice* createAudioDevice(const char* /*inputDeviceId*/, size_t /*bufferSize*/, unsigned /*numberOfInputChannels*/, unsigned /*numberOfOutputChannels*/, double /*sampleRate*/, AudioDevice::RenderCallback*) { return nullptr; } >+ >+ // Gamepad >+ virtual void sampleGamepads(Gamepads& into) { into.length = 0; } >+ >+ // FFTFrame >+ virtual FFTFrame* createFFTFrame(unsigned /*fftsize*/) { return nullptr; } >+ >+ // Decodes the in-memory audio file data and returns the linear PCM audio data. >+ virtual MultiChannelPCMData* decodeAudioResource(const void* /*audioData*/, size_t /*dataSize*/, double /*sampleRate*/) { return nullptr; } >+ >+ // Theme engine >+ virtual ThemeEngine* themeEngine(); >+ >+ // Create a MediaPlayer, used to... play media :-) >+ virtual MediaPlayer* createMediaPlayer(MediaPlayerClient*) { return nullptr; } >+protected: >+ virtual ~Platform() { } >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_Platform_h >diff --git a/Source/Platform/nix/public/Rect.h b/Source/Platform/nix/public/Rect.h >new file mode 100644 >index 0000000000000000000000000000000000000000..13516184b21cd4a04e2a6c383ecc78330785a411 >--- /dev/null >+++ b/Source/Platform/nix/public/Rect.h >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_Rect_h >+#define Nix_Rect_h >+ >+namespace Nix { >+ >+class Rect { >+public: >+ int x; >+ int y; >+ int width; >+ int height; >+ >+ Rect(int x, int y, int width, int height) >+ : x(x) >+ , y(y) >+ , width(width) >+ , height(height) >+ { >+ } >+ >+ Rect(const Rect& r) >+ : x(r.x) >+ , y(r.y) >+ , width(r.width) >+ , height(r.height) >+ { >+ } >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_Rect_h >diff --git a/Source/Platform/nix/public/Size.h b/Source/Platform/nix/public/Size.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0360b44fc88698b5d372bda343b416e993e6ccc6 >--- /dev/null >+++ b/Source/Platform/nix/public/Size.h >@@ -0,0 +1,71 @@ >+/* >+ * Copyright (C) 2009 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_Size_h >+#define Nix_Size_h >+ >+namespace Nix { >+ >+struct Size { >+ int width; >+ int height; >+ >+ bool isEmpty() const >+ { >+ return width <= 0 || height <= 0; >+ } >+ >+ Size() >+ : width(0) >+ , height(0) >+ { >+ } >+ >+ Size(int width, int height) >+ : width(width) >+ , height(height) >+ { >+ } >+ >+ bool operator==(const Size& other) const >+ { >+ return width == other.width && height == other.height; >+ } >+ >+ bool operator!=(const Size& other) const >+ { >+ return !(*this == other); >+ } >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_Size_h >diff --git a/Source/Platform/nix/public/ThemeEngine.h b/Source/Platform/nix/public/ThemeEngine.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e8e52238653e16067c22837d34d4e01b3d42f34c >--- /dev/null >+++ b/Source/Platform/nix/public/ThemeEngine.h >@@ -0,0 +1,158 @@ >+/* >+ * Copyright (C) 2010 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Nix_ThemeEngine_h >+#define Nix_ThemeEngine_h >+ >+#include "Canvas.h" >+#include "Color.h" >+#include "Size.h" >+ >+namespace Nix { >+ >+class Rect; >+ >+class ThemeEngine { >+public: >+ // The current state of the associated Part. >+ enum State { >+ StateDisabled, >+ StateHover, >+ StateNormal, >+ StatePressed >+ }; >+ >+ enum MediaPlayerState { >+ StatePlaying, >+ StatePaused, >+ StateMuted, >+ StateNotMuted >+ }; >+ >+ // Extra parameters for drawing the PartScrollbarHorizontalTrack and >+ // PartScrollbarVerticalTrack. >+ struct ScrollbarTrackExtraParams { >+ // The bounds of the entire track, as opposed to the part being painted. >+ int trackX; >+ int trackY; >+ int trackWidth; >+ int trackHeight; >+ }; >+ >+ // Extra parameters for PartCheckbox, PartPushButton and PartRadio. >+ struct ButtonExtraParams { >+ bool checked; >+ bool indeterminate; // Whether the button state is indeterminate. >+ bool isDefault; // Whether the button is default button. >+ bool hasBorder; >+ }; >+ >+ // Extra parameters for PartInnerSpinButton >+ struct InnerSpinButtonExtraParams { >+ bool spinUp; >+ bool readOnly; >+ }; >+ >+ // Extra parameters for PartProgressBar >+ struct ProgressBarExtraParams { >+ bool isDeterminate; >+ double position; >+ double animationProgress; >+ double animationStartTime; >+ }; >+ >+ struct MeterExtraParams { >+ double min; >+ double max; >+ double value; >+ double low; >+ double high; >+ double optimum; >+ double valueRatio() const >+ { >+ if (max <= min) >+ return 0; >+ return (value - min) / (max - min); >+ } >+ }; >+ >+ virtual const char* extraDefaultStyleSheet() const { return ""; } >+ virtual const char* extraQuirksStyleSheet() const { return ""; } >+ virtual const char* extraPlugInsStyleSheet() const { return ""; } >+ >+ // Text selection colors. >+ virtual Color activeSelectionBackgroundColor() const = 0; >+ virtual Color activeSelectionForegroundColor() const = 0; >+ virtual Color inactiveSelectionBackgroundColor() const = 0; >+ virtual Color inactiveSelectionForegroundColor() const = 0; >+ >+ // List box selection colors >+ virtual Color activeListBoxSelectionBackgroundColor() const = 0; >+ virtual Color activeListBoxSelectionForegroundColor() const = 0; >+ virtual Color inactiveListBoxSelectionBackgroundColor() const = 0; >+ virtual Color inactiveListBoxSelectionForegroundColor() const = 0; >+ >+ virtual Color activeTextSearchHighlightColor() const = 0; >+ virtual Color inactiveTextSearchHighlightColor() const = 0; >+ >+ virtual Color focusRingColor() const = 0; >+ >+ virtual Color tapHighlightColor() const = 0; >+ >+ virtual void paintButton(Canvas*, State, const Rect&, const ButtonExtraParams&) const = 0; >+ virtual void paintTextField(Canvas*, State, const Rect&) const = 0; >+ virtual Size getCheckboxSize() const = 0; >+ virtual void paintCheckbox(Canvas*, State, const Rect&, const ButtonExtraParams&) const = 0; >+ virtual Size getRadioSize() const = 0; >+ virtual void paintRadio(Canvas*, State, const Rect&, const ButtonExtraParams&) const = 0; >+ virtual void paintTextArea(Canvas*, State, const Rect&) const = 0; >+ virtual void getMenuListPadding(int& paddingTop, int& paddingLeft, int& paddingBottom, int& paddingRight) const = 0; >+ virtual void paintMenuList(Canvas*, State, const Rect&) const = 0; >+ virtual void paintProgressBar(Canvas*, State, const Rect&, const ProgressBarExtraParams&) const = 0; >+ virtual double getAnimationRepeatIntervalForProgressBar() const = 0; >+ virtual double getAnimationDurationForProgressBar() const = 0; >+ virtual void getInnerSpinButtonPadding(int& paddingTop, int& paddingLeft, int& paddingBottom, int& paddingRight) const = 0; >+ virtual void paintInnerSpinButton(Canvas*, State, const Rect&, const InnerSpinButtonExtraParams&) const = 0; >+ virtual void paintMeter(Canvas*, State, const Rect&, const MeterExtraParams&) const = 0; >+ virtual void paintSliderTrack(Canvas*, State, const Rect&) const = 0; >+ virtual void paintSliderThumb(Canvas*, State, const Rect&) const = 0; >+ >+ // MediaPlayer (audio and video elements) >+ virtual void paintMediaPlayButton(Canvas*, MediaPlayerState, const Rect&) const = 0; >+ virtual void paintMediaMuteButton(Canvas*, MediaPlayerState, const Rect&) const = 0; >+ virtual void paintMediaSeekBackButton(Canvas*, const Rect&) const = 0; >+ virtual void paintMediaSeekForwardButton(Canvas*, const Rect&) const = 0; >+ virtual void paintMediaRewindButton(Canvas*, const Rect&) const = 0; >+}; >+ >+} // namespace Nix >+ >+#endif // Nix_ThemeEngine_h >diff --git a/Source/Platform/nix/src/DefaultWebThemeEngine.cpp b/Source/Platform/nix/src/DefaultWebThemeEngine.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..507ccdcc4ad172071baa6672d66ad433eaef8936 >--- /dev/null >+++ b/Source/Platform/nix/src/DefaultWebThemeEngine.cpp >@@ -0,0 +1,489 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include "DefaultWebThemeEngine.h" >+ >+#include "public/Color.h" >+#include "public/Rect.h" >+#include "public/Size.h" >+#include <algorithm> >+#include <cairo/cairo.h> >+#include <cmath> >+ >+const double BGColor1 = 0xF6 / 255.0; >+const double BGColor2 = 0xDE / 255.0; >+const double BorderColor = 0xA4 / 255.0; >+const double BorderOnHoverColor = 0x7A / 255.0; >+const double CheckColor = 0x66 / 255.0; >+const double TextFieldDarkBorderColor = 0x9A / 255.0; >+const double TextFieldLightBorderColor = 0xEE / 255.0; >+ >+const int MenuListBorder = 5; >+const int MenuListArrowSize = 6; >+ >+const int InnerSpinButtonBorder = 3; >+const int InnerSpinButtonArrowSize = 2; >+ >+const Nix::Color TapHighLightColor(0x66000000); >+ >+namespace Nix { >+ >+Color DefaultWebThemeEngine::activeSelectionBackgroundColor() const >+{ >+ return Color::blue; >+} >+ >+Color DefaultWebThemeEngine::activeSelectionForegroundColor() const >+{ >+ return Color::white; >+} >+ >+Color DefaultWebThemeEngine::inactiveSelectionBackgroundColor() const >+{ >+ return Color(176, 176, 176); >+} >+ >+Color DefaultWebThemeEngine::inactiveSelectionForegroundColor() const >+{ >+ return Color::black; >+} >+ >+Color DefaultWebThemeEngine::activeListBoxSelectionBackgroundColor() const >+{ >+ return activeSelectionBackgroundColor(); >+} >+ >+Color DefaultWebThemeEngine::activeListBoxSelectionForegroundColor() const >+{ >+ return activeSelectionForegroundColor(); >+} >+ >+Color DefaultWebThemeEngine::inactiveListBoxSelectionBackgroundColor() const >+{ >+ return inactiveSelectionBackgroundColor(); >+} >+ >+Color DefaultWebThemeEngine::inactiveListBoxSelectionForegroundColor() const >+{ >+ return inactiveSelectionForegroundColor(); >+} >+ >+Color DefaultWebThemeEngine::activeTextSearchHighlightColor() const >+{ >+ return Color(255, 150, 50); // Orange. >+} >+ >+Color DefaultWebThemeEngine::inactiveTextSearchHighlightColor() const >+{ >+ return Color(255, 255, 0); // Yellow. >+} >+ >+Color DefaultWebThemeEngine::focusRingColor() const >+{ >+ return Color::black; >+} >+ >+Color DefaultWebThemeEngine::tapHighlightColor() const >+{ >+ return TapHighLightColor; >+} >+ >+static void gradientFill(cairo_t* cairo, double yStart, double yLength, bool inverted = false) >+{ >+ double gradStartColor = BGColor1; >+ double gradEndColor = BGColor2; >+ if (inverted) >+ std::swap(gradStartColor, gradEndColor); >+ >+ cairo_pattern_t* gradient = cairo_pattern_create_linear(0, yStart, 0, yStart + yLength); >+ cairo_pattern_add_color_stop_rgb(gradient, 0, gradStartColor, gradStartColor, gradStartColor); >+ cairo_pattern_add_color_stop_rgb(gradient, 1, gradEndColor, gradEndColor, gradEndColor); >+ cairo_set_source(cairo, gradient); >+ cairo_fill(cairo); >+ cairo_pattern_destroy(gradient); >+} >+ >+static void setupBorder(cairo_t * cairo, ThemeEngine::State state) >+{ >+ double borderColor = state == ThemeEngine::StateHover ? BorderOnHoverColor : BorderColor; >+ cairo_set_source_rgb(cairo, borderColor, borderColor, borderColor); >+ cairo_set_line_width(cairo, 1); >+} >+ >+void DefaultWebThemeEngine::paintButton(Canvas* canvas, State state, const Rect& rect, const ButtonExtraParams&) const >+{ >+ cairo_save(canvas); >+ setupBorder(canvas, state); >+ // Cairo uses a coordinate system not based on pixel coordinates, so >+ // we need to add 0.5 to x and y coord or the line will stay between >+ // two pixels instead of in the middle of a pixel. >+ cairo_rectangle(canvas, rect.x + 0.5, rect.y + 0.5, rect.width, rect.height); >+ cairo_stroke_preserve(canvas); >+ >+ gradientFill(canvas, rect.y, rect.height, state == StatePressed); >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintTextField(Canvas* canvas, State, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ >+ const double lineWidth = 2; >+ const double correction = lineWidth / 2.0; >+ >+ cairo_set_line_width(canvas, lineWidth); >+ cairo_set_source_rgb(canvas, TextFieldDarkBorderColor, TextFieldDarkBorderColor, TextFieldDarkBorderColor); >+ cairo_move_to(canvas, rect.x + correction, rect.y + correction + rect.height); >+ cairo_rel_line_to(canvas, 0, -rect.height); >+ cairo_rel_line_to(canvas, rect.width, 0); >+ cairo_stroke(canvas); >+ >+ cairo_set_source_rgb(canvas, TextFieldLightBorderColor, TextFieldLightBorderColor, TextFieldLightBorderColor); >+ cairo_move_to(canvas, rect.x + correction + rect.width, rect.y + correction); >+ cairo_rel_line_to(canvas, 0, rect.height); >+ cairo_rel_line_to(canvas, -rect.width, 0); >+ cairo_stroke(canvas); >+ >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintTextArea(Canvas* canvas, State state, const Rect& rect) const >+{ >+ paintTextField(canvas, state, rect); >+} >+ >+Size DefaultWebThemeEngine::getCheckboxSize() const >+{ >+ return Size(13, 13); >+} >+ >+void DefaultWebThemeEngine::paintCheckbox(Canvas* canvas, State state, const Rect& rect, const ButtonExtraParams& param) const >+{ >+ cairo_save(canvas); >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x + 0.5, rect.y + 0.5, rect.width, rect.height); >+ cairo_stroke_preserve(canvas); >+ >+ gradientFill(canvas, rect.y, rect.height, state == StatePressed); >+ >+ if (param.checked) { >+ const double border = 3; >+ cairo_set_line_width(canvas, 2); >+ cairo_set_source_rgb(canvas, CheckColor, CheckColor, CheckColor); >+ cairo_move_to(canvas, rect.x + 0.5 + border, rect.y + 0.5 + rect.height - border); >+ cairo_rel_line_to(canvas, rect.width - border * 2, -rect.height + border * 2); >+ cairo_move_to(canvas, rect.x + 0.5 + border, rect.y + 0.5 + border); >+ cairo_rel_line_to(canvas, rect.width - border * 2, rect.height - border * 2); >+ cairo_stroke(canvas); >+ } >+ >+ cairo_restore(canvas); >+} >+ >+Size DefaultWebThemeEngine::getRadioSize() const >+{ >+ return Size(13, 13); >+} >+ >+void DefaultWebThemeEngine::paintRadio(Canvas* canvas, State state, const Rect& rect, const ButtonExtraParams& param) const >+{ >+ cairo_save(canvas); >+ setupBorder(canvas, state); >+ cairo_arc(canvas, rect.x + rect.width / 2.0, rect.y + rect.height / 2.0, rect.width / 2.0, 0, 2 * M_PI); >+ cairo_stroke_preserve(canvas); >+ >+ gradientFill(canvas, rect.y, rect.height); >+ >+ if (param.checked) { >+ cairo_set_source_rgb(canvas, CheckColor, CheckColor, CheckColor); >+ cairo_arc(canvas, rect.x + rect.width / 2.0, rect.y + rect.height / 2.0, rect.width / 4.0, 0, 2 * M_PI); >+ cairo_fill(canvas); >+ } >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::getMenuListPadding(int& paddingTop, int& paddingLeft, int& paddingBottom, int& paddingRight) const >+{ >+ paddingTop = MenuListBorder; >+ paddingLeft = MenuListBorder; >+ paddingBottom = MenuListBorder; >+ paddingRight = 2 * MenuListBorder + MenuListArrowSize; >+} >+ >+void DefaultWebThemeEngine::paintMenuList(Canvas* canvas, State state, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x + 0.5, rect.y + 0.5, rect.width, rect.height); >+ cairo_stroke_preserve(canvas); >+ >+ gradientFill(canvas, rect.y, rect.height, state == StatePressed); >+ >+ cairo_move_to(canvas, rect.x + rect.width - MenuListArrowSize - MenuListBorder, rect.y + 1 + rect.height / 2 - MenuListArrowSize / 2); >+ cairo_set_source_rgb(canvas, CheckColor, CheckColor, CheckColor); >+ cairo_rel_line_to(canvas, MenuListArrowSize, 0); >+ cairo_rel_line_to(canvas, -MenuListArrowSize / 2, MenuListArrowSize); >+ cairo_close_path(canvas); >+ cairo_fill(canvas); >+ >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintProgressBar(Canvas* canvas, State state, const Rect& rect, const ProgressBarExtraParams& params) const >+{ >+ cairo_save(canvas); >+ >+ if (params.isDeterminate) { >+ // Background >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x, rect.y, rect.width, rect.height); >+ cairo_fill(canvas); >+ // Progress >+ cairo_rectangle(canvas, rect.x, rect.y, rect.width * params.position, rect.height); >+ gradientFill(canvas, rect.y, rect.height); >+ } else { >+ cairo_rectangle(canvas, rect.x, rect.y, rect.width, rect.height); >+ gradientFill(canvas, rect.y, rect.height, true); >+ } >+ >+ cairo_restore(canvas); >+} >+ >+// These values have been copied from RenderThemeChromiumSkia.cpp >+static const int progressActivityBlocks = 5; >+static const int progressAnimationFrames = 10; >+static const double progressAnimationInterval = 0.125; >+ >+double DefaultWebThemeEngine::getAnimationRepeatIntervalForProgressBar() const >+{ >+ return progressAnimationInterval; >+} >+ >+double DefaultWebThemeEngine::getAnimationDurationForProgressBar() const >+{ >+ return progressAnimationInterval * progressAnimationFrames * 2; // "2" for back and forth; >+} >+ >+void DefaultWebThemeEngine::getInnerSpinButtonPadding(int& paddingTop, int& paddingLeft, int& paddingBottom, int& paddingRight) const >+{ >+ paddingTop = InnerSpinButtonBorder; >+ paddingLeft = InnerSpinButtonBorder; >+ paddingBottom = InnerSpinButtonBorder; >+ paddingRight = 2 * InnerSpinButtonBorder + InnerSpinButtonArrowSize; >+} >+ >+void DefaultWebThemeEngine::paintInnerSpinButton(Canvas* canvas, State state, const Rect& rect, const InnerSpinButtonExtraParams& param) const >+{ >+ double rectHalfHeight = rect.height / 2; >+ >+ cairo_save(canvas); >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x + 0.5, rect.y + 1.5, rect.width, rectHalfHeight); >+ cairo_stroke_preserve(canvas); >+ >+ gradientFill(canvas, rect.y, rectHalfHeight, state == StatePressed && param.spinUp); >+ >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x + 0.5, rect.y + 0.5 + rectHalfHeight, rect.width, rectHalfHeight); >+ cairo_stroke_preserve(canvas); >+ >+ gradientFill(canvas, rect.y + rectHalfHeight, rectHalfHeight, state == StatePressed && !param.spinUp); >+ >+ cairo_move_to(canvas, rect.x + rect.width - InnerSpinButtonArrowSize - InnerSpinButtonBorder * 2, rect.y + rectHalfHeight + rect.height / 4 - InnerSpinButtonArrowSize + 1.5); >+ cairo_set_source_rgb(canvas, CheckColor, CheckColor, CheckColor); >+ cairo_rel_line_to(canvas, MenuListArrowSize, 0); >+ cairo_rel_line_to(canvas, -MenuListArrowSize / 2, MenuListArrowSize); >+ cairo_close_path(canvas); >+ >+ cairo_move_to(canvas, rect.x + rect.width - InnerSpinButtonArrowSize - InnerSpinButtonBorder * 2, rect.y + rect.height / 4 + InnerSpinButtonArrowSize); >+ cairo_set_source_rgb(canvas, CheckColor, CheckColor, CheckColor); >+ cairo_rel_line_to(canvas, MenuListArrowSize, 0); >+ cairo_rel_line_to(canvas, -MenuListArrowSize / 2, -MenuListArrowSize); >+ cairo_close_path(canvas); >+ >+ cairo_fill(canvas); >+} >+ >+void DefaultWebThemeEngine::paintMeter(Canvas* canvas, State state, const Rect& rect, const MeterExtraParams& params) const >+{ >+ cairo_save(canvas); >+ >+ // Background >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x, rect.y, rect.width, rect.height); >+ cairo_fill(canvas); >+ // Meter >+ cairo_rectangle(canvas, rect.x, rect.y, rect.width * params.valueRatio(), rect.height); >+ gradientFill(canvas, rect.y, rect.height); >+ >+ cairo_restore(canvas); >+} >+ >+const int SliderTrackHeight = 6; >+ >+void DefaultWebThemeEngine::paintSliderTrack(Canvas* canvas, State, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ cairo_rectangle(canvas, rect.x, rect.y + (rect.height - SliderTrackHeight) / 2.0, rect.width, SliderTrackHeight); >+ gradientFill(canvas, rect.y, rect.height, true); >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintSliderThumb(Canvas* canvas, State state, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ setupBorder(canvas, state); >+ cairo_rectangle(canvas, rect.x, rect.y, rect.width, rect.height); >+ cairo_stroke_preserve(canvas); >+ gradientFill(canvas, rect.y, rect.height, state == StatePressed); >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintMediaPlayButton(Canvas* canvas, MediaPlayerState state, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ cairo_set_source_rgb(canvas, 1, 1, 1); >+ if (state == StatePaused) { >+ cairo_move_to(canvas, rect.x + (rect.width * 0.3), rect.y + (rect.height * 0.25)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.75), rect.y + (rect.height * 0.5)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.3), rect.y + (rect.height * 0.75)); >+ cairo_close_path(canvas); >+ cairo_fill(canvas); >+ } else { // If state is StatePlaying. >+ cairo_rectangle(canvas, rect.x + (rect.width * 0.3), rect.y + (rect.height * 0.25), (rect.width * 0.15), (rect.height * 0.5)); >+ cairo_fill(canvas); >+ cairo_rectangle(canvas, rect.x + (rect.width * 0.55), rect.y + (rect.height * 0.25), (rect.width * 0.15), (rect.height * 0.5)); >+ cairo_fill(canvas); >+ } >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintMediaMuteButton(Canvas* canvas, MediaPlayerState state, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ if (state == StateMuted) { >+ cairo_set_line_width(canvas, 1); >+ cairo_set_source_rgb(canvas, 139, 0, 0); >+ >+ cairo_move_to(canvas, rect.x + (rect.width * 0.59), rect.y + (rect.height * 0.67)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.87), rect.y + (rect.height * 0.34)); >+ cairo_stroke(canvas); >+ >+ cairo_move_to(canvas, rect.x + (rect.width * 0.87), rect.y + (rect.height * 0.67)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.59), rect.y + (rect.height * 0.34)); >+ cairo_stroke(canvas); >+ } else { // If state is StateNotMuted >+ cairo_set_line_width(canvas, 5); >+ cairo_set_source_rgb(canvas, 1, 1, 1); >+ >+ cairo_arc(canvas, rect.x + (rect.width * 0.3), rect.y + (rect.height * 0.5), rect.width * 0.34, 11 * (M_PI / 6), M_PI / 6); >+ cairo_fill(canvas); >+ cairo_arc(canvas, rect.x + (rect.width * 0.3), rect.y + (rect.height * 0.5), rect.width * 0.45, 11 * (M_PI / 6), M_PI / 6); >+ cairo_fill(canvas); >+ cairo_arc(canvas, rect.x + (rect.width * 0.3), rect.y + (rect.height * 0.5), rect.width * 0.57, 11 * (M_PI / 6), M_PI / 6); >+ cairo_fill(canvas); >+ } >+ >+ // Speaker >+ cairo_move_to(canvas, rect.x + (rect.width * 0.52), rect.y + (rect.height * 0.18)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.29), rect.y + (rect.height * 0.38)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.08), rect.y + (rect.height * 0.38)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.08), rect.y + (rect.height * 0.62)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.29), rect.y + (rect.height * 0.62)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.52), rect.y + (rect.height * 0.82)); >+ cairo_close_path(canvas); >+ cairo_fill(canvas); >+ >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintMediaSeekBackButton(Canvas* canvas, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ cairo_set_source_rgb(canvas, 1, 1, 1); >+ cairo_move_to(canvas, rect.x + (rect.width * 0.90), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.58), rect.y + (rect.height * 0.51)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.58), rect.y + (rect.height * 0.70)); >+ >+ cairo_line_to(canvas, rect.x + (rect.width * 0.23), rect.y + (rect.height * 0.51)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.23), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.11), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.11), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.23), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.23), rect.y + (rect.height * 0.48)); >+ >+ cairo_line_to(canvas, rect.x + (rect.width * 0.58), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.58), rect.y + (rect.height * 0.48)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.90), rect.y + (rect.height * 0.29)); >+ cairo_close_path(canvas); >+ cairo_fill(canvas); >+ >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintMediaSeekForwardButton(Canvas* canvas, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ cairo_set_source_rgb(canvas, 1, 1, 1); >+ cairo_move_to(canvas, rect.x + (rect.width * 0.10), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.42), rect.y + (rect.height * 0.51)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.42), rect.y + (rect.height * 0.70)); >+ >+ cairo_line_to(canvas, rect.x + (rect.width * 0.77), rect.y + (rect.height * 0.51)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.77), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.89), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.89), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.77), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.77), rect.y + (rect.height * 0.48)); >+ >+ cairo_line_to(canvas, rect.x + (rect.width * 0.42), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.42), rect.y + (rect.height * 0.48)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.10), rect.y + (rect.height * 0.29)); >+ cairo_close_path(canvas); >+ cairo_fill(canvas); >+ >+ cairo_restore(canvas); >+} >+ >+void DefaultWebThemeEngine::paintMediaRewindButton(Canvas* canvas, const Rect& rect) const >+{ >+ cairo_save(canvas); >+ cairo_set_source_rgb(canvas, 1, 1, 1); >+ cairo_move_to(canvas, rect.x + (rect.width * 0.84), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.52), rect.y + (rect.height * 0.51)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.52), rect.y + (rect.height * 0.70)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.17), rect.y + (rect.height * 0.50)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.52), rect.y + (rect.height * 0.29)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.52), rect.y + (rect.height * 0.48)); >+ cairo_line_to(canvas, rect.x + (rect.width * 0.84), rect.y + (rect.height * 0.29)); >+ cairo_close_path(canvas); >+ cairo_fill(canvas); >+ >+ cairo_restore(canvas); >+} >+ >+} >diff --git a/Source/Platform/nix/src/DefaultWebThemeEngine.h b/Source/Platform/nix/src/DefaultWebThemeEngine.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0dff53eec677b5fbf30f29debfdd0fc5a5744a6b >--- /dev/null >+++ b/Source/Platform/nix/src/DefaultWebThemeEngine.h >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef DefaultWebThemeEngine_h >+#define DefaultWebThemeEngine_h >+ >+#include "public/ThemeEngine.h" >+ >+namespace Nix { >+ >+class DefaultWebThemeEngine FINAL : public ThemeEngine { >+public: >+ // Text selection colors. >+ virtual Color activeSelectionBackgroundColor() const OVERRIDE; >+ virtual Color activeSelectionForegroundColor() const OVERRIDE; >+ virtual Color inactiveSelectionBackgroundColor() const OVERRIDE; >+ virtual Color inactiveSelectionForegroundColor() const OVERRIDE; >+ >+ // List box selection colors >+ virtual Color activeListBoxSelectionBackgroundColor() const OVERRIDE; >+ virtual Color activeListBoxSelectionForegroundColor() const OVERRIDE; >+ virtual Color inactiveListBoxSelectionBackgroundColor() const OVERRIDE; >+ virtual Color inactiveListBoxSelectionForegroundColor() const OVERRIDE; >+ >+ virtual Color activeTextSearchHighlightColor() const OVERRIDE; >+ virtual Color inactiveTextSearchHighlightColor() const OVERRIDE; >+ >+ virtual Color focusRingColor() const OVERRIDE; >+ >+ virtual Color tapHighlightColor() const OVERRIDE; >+ >+ virtual void paintButton(Canvas*, State, const Rect&, const ButtonExtraParams&) const OVERRIDE; >+ virtual void paintTextField(Canvas*, State, const Rect&) const OVERRIDE; >+ virtual void paintTextArea(Canvas*, State, const Rect&) const OVERRIDE; >+ virtual Size getCheckboxSize() const OVERRIDE; >+ virtual void paintCheckbox(Canvas*, State, const Rect&, const ButtonExtraParams&) const OVERRIDE; >+ virtual Size getRadioSize() const OVERRIDE; >+ virtual void paintRadio(Canvas*, State, const Rect&, const ButtonExtraParams&) const OVERRIDE; >+ virtual void paintMenuList(Canvas *, State, const Rect &) const OVERRIDE; >+ virtual void getMenuListPadding(int& paddingTop, int& paddingLeft, int& paddingBottom, int& paddingRight) const OVERRIDE; >+ virtual void paintProgressBar(Canvas*, State, const Rect&, const ProgressBarExtraParams&) const OVERRIDE; >+ virtual double getAnimationRepeatIntervalForProgressBar() const OVERRIDE; >+ virtual double getAnimationDurationForProgressBar() const OVERRIDE; >+ virtual void paintInnerSpinButton(Canvas *, State, const Rect &, const InnerSpinButtonExtraParams&) const OVERRIDE; >+ virtual void getInnerSpinButtonPadding(int& paddingTop, int& paddingLeft, int& paddingBottom, int& paddingRight) const OVERRIDE; >+ virtual void paintMeter(Canvas*, State, const Rect&, const MeterExtraParams&) const OVERRIDE; >+ virtual void paintSliderTrack(Canvas*, State, const Rect&) const OVERRIDE; >+ virtual void paintSliderThumb(Canvas*, State, const Rect&) const OVERRIDE; >+ >+ // Media Player >+ virtual void paintMediaPlayButton(Canvas*, MediaPlayerState, const Rect&) const OVERRIDE; >+ virtual void paintMediaMuteButton(Canvas*, MediaPlayerState, const Rect&) const OVERRIDE; >+ virtual void paintMediaSeekBackButton(Canvas*, const Rect&) const OVERRIDE; >+ virtual void paintMediaSeekForwardButton(Canvas*, const Rect&) const OVERRIDE; >+ virtual void paintMediaRewindButton(Canvas*, const Rect&) const OVERRIDE; >+}; >+ >+} // namespace Nix >+ >+#endif // DefaultWebThemeEngine_h >diff --git a/Source/Platform/nix/src/Platform.cpp b/Source/Platform/nix/src/Platform.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..784d247651cf7c96d41cf2087a699dbf7a030f19 >--- /dev/null >+++ b/Source/Platform/nix/src/Platform.cpp >@@ -0,0 +1,52 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "public/Platform.h" >+ >+#include "DefaultWebThemeEngine.h" >+ >+namespace Nix { >+ >+static Platform* s_platform; >+ >+void Platform::initialize(Platform* platform) >+{ >+ s_platform = platform; >+} >+ >+Platform* Platform::current() >+{ >+ static Platform emptyPlatform; >+ return s_platform ? s_platform : &emptyPlatform; >+} >+ >+ThemeEngine* Platform::themeEngine() >+{ >+ static DefaultWebThemeEngine theme; >+ return &theme; >+} >+ >+} // namespace Nix >diff --git a/Source/WebCore/platform/audio/nix/AudioBusNix.cpp b/Source/WebCore/platform/audio/nix/AudioBusNix.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..0de07bffc8d7f3f676b404e02e044b9970670b02 >--- /dev/null >+++ b/Source/WebCore/platform/audio/nix/AudioBusNix.cpp >@@ -0,0 +1,86 @@ >+/* >+ * Copyright (C) 2010, Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(WEB_AUDIO) >+ >+#include "AudioBus.h" >+ >+#include "AudioFileReader.h" >+#include <cstdio> >+#include <public/MultiChannelPCMData.h> >+#include <public/Platform.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/Vector.h> >+#include <wtf/text/CString.h> >+#include <wtf/text/StringConcatenate.h> >+ >+namespace WebCore { >+ >+PassRefPtr<AudioBus> decodeAudioFileData(const char* data, size_t size, double sampleRate) >+{ >+ OwnPtr<Nix::MultiChannelPCMData> pcmData = adoptPtr(Nix::Platform::current()->decodeAudioResource(data, size, sampleRate)); >+ if (pcmData) >+ return adoptRef(static_cast<AudioBus*>(pcmData->getInternalData())); >+ return nullptr; >+} >+ >+PassRefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float sampleRate) >+{ >+ String absoluteFilename(makeString(DATA_DIR, "/webaudio/resources/", name, ".wav")); >+ >+ FILE* file = fopen(absoluteFilename.utf8().data(), "rb"); >+ if (!file) >+ return nullptr; >+ >+ fseek(file, 0, SEEK_END); >+ WTF::Vector<char> fileContents; >+ fileContents.resize(ftell(file)); >+ rewind(file); >+ size_t bytesRead = fread(&fileContents[0], fileContents.size(), 1, file); >+ if (bytesRead < fileContents.size()) >+ fileContents.resize(bytesRead); >+ fclose(file); >+ >+ return decodeAudioFileData(&fileContents[0], fileContents.size(), sampleRate); >+} >+ >+PassRefPtr<AudioBus> createBusFromInMemoryAudioFile(const void* data, size_t dataSize, bool mixToMono, float sampleRate) >+{ >+ RefPtr<AudioBus> audioBus = decodeAudioFileData(static_cast<const char*>(data), dataSize, sampleRate); >+ if (!audioBus) >+ return nullptr; >+ >+ // If the bus needs no conversion then return as is. >+ if (!mixToMono || audioBus->numberOfChannels() == 1) >+ return audioBus.release(); >+ >+ return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, sampleRate); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEB_AUDIO) >diff --git a/Source/WebCore/platform/audio/nix/AudioDestinationNix.cpp b/Source/WebCore/platform/audio/nix/AudioDestinationNix.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..004b3d449a1ccd325b672d44221bbbe0959ffcc4 >--- /dev/null >+++ b/Source/WebCore/platform/audio/nix/AudioDestinationNix.cpp >@@ -0,0 +1,171 @@ >+/* >+ * Copyright (C) 2010 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(WEB_AUDIO) >+ >+#include "AudioDestinationNix.h" >+ >+#include "AudioFIFO.h" >+#include "AudioPullFIFO.h" >+#include <public/Platform.h> >+#include <wtf/text/CString.h> >+ >+namespace WebCore { >+ >+// Buffer size at which the web audio engine will render. >+const unsigned renderBufferSize = 128; >+ >+// Size of the FIFO >+const size_t fifoSize = 8192; >+ >+// Factory method: Chromium-implementation >+PassOwnPtr<AudioDestination> AudioDestination::create(AudioIOCallback& callback, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) >+{ >+ return adoptPtr(new AudioDestinationNix(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate)); >+} >+ >+AudioDestinationNix::AudioDestinationNix(AudioIOCallback& callback, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) >+ : m_callback(callback) >+ , m_numberOfOutputChannels(numberOfOutputChannels) >+ , m_inputBus(AudioBus::create(numberOfInputChannels, renderBufferSize)) >+ , m_renderBus(AudioBus::create(numberOfOutputChannels, renderBufferSize, false)) >+ , m_sampleRate(sampleRate) >+ , m_isPlaying(false) >+ , m_inputDeviceId(inputDeviceId) >+{ >+ // Use the optimal buffer size recommended by the audio backend. >+ m_callbackBufferSize = Nix::Platform::current()->audioHardwareBufferSize(); >+ >+ // Quick exit if the requested size is too large. >+ ASSERT(m_callbackBufferSize + renderBufferSize <= fifoSize); >+ if (m_callbackBufferSize + renderBufferSize > fifoSize) >+ return; >+ >+ m_audioDevice = adoptPtr(Nix::Platform::current()->createAudioDevice(m_inputDeviceId.utf8().data(), m_callbackBufferSize, numberOfInputChannels, numberOfOutputChannels, sampleRate, this)); >+ >+ ASSERT(m_audioDevice); >+ >+ // Create a FIFO to handle the possibility of the callback size >+ // not being a multiple of the render size. If the FIFO already >+ // contains enough data, the data will be provided directly. >+ // Otherwise, the FIFO will call the provider enough times to >+ // satisfy the request for data. >+ m_fifo = adoptPtr(new AudioPullFIFO(*this, numberOfOutputChannels, fifoSize, renderBufferSize)); >+ >+ // Input buffering. >+ m_inputFifo = adoptPtr(new AudioFIFO(numberOfInputChannels, fifoSize)); >+ >+ // If the callback size does not match the render size, then we need to buffer some >+ // extra silence for the input. Otherwise, we can over-consume the input FIFO. >+ if (m_callbackBufferSize != renderBufferSize) { >+ // FIXME: handle multi-channel input and don't hard-code to stereo. >+ RefPtr<AudioBus> silence = AudioBus::create(2, renderBufferSize); >+ m_inputFifo->push(silence.get()); >+ } >+} >+ >+AudioDestinationNix::~AudioDestinationNix() >+{ >+ stop(); >+} >+ >+void AudioDestinationNix::start() >+{ >+ if (!m_isPlaying && m_audioDevice) { >+ m_audioDevice->start(); >+ m_isPlaying = true; >+ } >+} >+ >+void AudioDestinationNix::stop() >+{ >+ if (m_isPlaying && m_audioDevice) { >+ m_audioDevice->stop(); >+ m_isPlaying = false; >+ } >+} >+ >+float AudioDestination::hardwareSampleRate() >+{ >+ return Nix::Platform::current()->audioHardwareSampleRate(); >+} >+ >+unsigned long AudioDestination::maxChannelCount() >+{ >+ return Nix::Platform::current()->audioHardwareOutputChannels(); >+} >+ >+void AudioDestinationNix::render(const std::vector<float*>& sourceData, const std::vector<float*>& audioData, size_t numberOfFrames) >+{ >+ if (!m_isPlaying || !m_audioDevice) >+ return; >+ >+ bool isNumberOfChannelsGood = audioData.size() == m_numberOfOutputChannels; >+ if (!isNumberOfChannelsGood) { >+ ASSERT_NOT_REACHED(); >+ return; >+ } >+ >+ bool isBufferSizeGood = numberOfFrames == m_callbackBufferSize; >+ if (!isBufferSizeGood) { >+ ASSERT_NOT_REACHED(); >+ return; >+ } >+ >+ // Buffer optional live input. >+ if (sourceData.size() >= 2) { >+ // FIXME: handle multi-channel input and don't hard-code to stereo. >+ RefPtr<AudioBus> wrapperBus = AudioBus::create(2, numberOfFrames, false); >+ wrapperBus->setChannelMemory(0, sourceData[0], numberOfFrames); >+ wrapperBus->setChannelMemory(1, sourceData[1], numberOfFrames); >+ m_inputFifo->push(wrapperBus.get()); >+ } >+ >+ for (unsigned i = 0; i < m_numberOfOutputChannels; ++i) >+ m_renderBus->setChannelMemory(i, audioData[i], numberOfFrames); >+ >+ m_fifo->consume(m_renderBus.get(), numberOfFrames); >+} >+ >+void AudioDestinationNix::provideInput(AudioBus* bus, size_t framesToProcess) >+{ >+ RefPtr<AudioBus> sourceBus; >+ if (m_inputFifo->framesInFifo() >= framesToProcess) { >+ m_inputFifo->consume(m_inputBus.get(), framesToProcess); >+ sourceBus = m_inputBus; >+ } >+ >+ m_callback.render(sourceBus.get(), bus, framesToProcess); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEB_AUDIO) >diff --git a/Source/WebCore/platform/audio/nix/AudioDestinationNix.h b/Source/WebCore/platform/audio/nix/AudioDestinationNix.h >new file mode 100644 >index 0000000000000000000000000000000000000000..791725fc29d4ee3cfaf1cb05a6fca2b2c2ecf9b9 >--- /dev/null >+++ b/Source/WebCore/platform/audio/nix/AudioDestinationNix.h >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (C) 2010 Google Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef AudioDestinationNix_h >+#define AudioDestinationNix_h >+ >+#include "AudioBus.h" >+#include "AudioDestination.h" >+#include "AudioIOCallback.h" >+#include "AudioSourceProvider.h" >+#include <public/AudioDevice.h> >+#include <vector> >+ >+namespace WebCore { >+ >+class AudioFIFO; >+class AudioPullFIFO; >+ >+class AudioDestinationNix : public AudioDestination, public Nix::AudioDevice::RenderCallback, public AudioSourceProvider { >+public: >+ AudioDestinationNix(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate); >+ virtual ~AudioDestinationNix(); >+ >+ virtual void start() OVERRIDE; >+ virtual void stop() OVERRIDE; >+ virtual bool isPlaying() OVERRIDE { return m_isPlaying; } >+ >+ virtual float sampleRate() const OVERRIDE { return m_sampleRate; } >+ >+ // WebKit::WebAudioDevice::RenderCallback >+ virtual void render(const std::vector<float*>& sourceData, const std::vector<float*>& audioData, size_t numberOfFrames) OVERRIDE; >+ >+ // WebCore::AudioSourceProvider >+ virtual void provideInput(AudioBus*, size_t framesToProcess) OVERRIDE; >+ >+private: >+ AudioIOCallback& m_callback; >+ unsigned m_numberOfOutputChannels; >+ RefPtr<AudioBus> m_inputBus; >+ RefPtr<AudioBus> m_renderBus; >+ float m_sampleRate; >+ bool m_isPlaying; >+ OwnPtr<Nix::AudioDevice> m_audioDevice; >+ size_t m_callbackBufferSize; >+ String m_inputDeviceId; >+ >+ OwnPtr<AudioFIFO> m_inputFifo; >+ OwnPtr<AudioPullFIFO> m_fifo; >+}; >+ >+} // namespace WebCore >+ >+#endif // AudioDestinationNix_h >diff --git a/Source/WebCore/platform/audio/nix/FFTFrameNix.cpp b/Source/WebCore/platform/audio/nix/FFTFrameNix.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..56adf0005247be3d913eef8ce882d09d70ef8fa5 >--- /dev/null >+++ b/Source/WebCore/platform/audio/nix/FFTFrameNix.cpp >@@ -0,0 +1,123 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+#include "config.h" >+ >+#if ENABLE(WEB_AUDIO) >+#include "FFTFrame.h" >+ >+#include "VectorMath.h" >+#include <cmath> >+#include <public/FFTFrame.h> >+#include <public/Platform.h> >+ >+namespace WebCore { >+ >+static inline void scalePlanarData(float* data, const unsigned size, const float scale) >+{ >+ VectorMath::vsmul(data, 1, &scale, data, 1, size); >+} >+ >+FFTFrame::FFTFrame(unsigned fftSize) >+ : m_FFTSize(fftSize) >+ , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) >+{ >+ m_fftFrame = adoptPtr(Nix::Platform::current()->createFFTFrame(fftSize)); >+} >+ >+FFTFrame::FFTFrame(const FFTFrame& frame) >+ : m_FFTSize(frame.m_FFTSize) >+ , m_log2FFTSize(frame.m_log2FFTSize) >+{ >+ m_fftFrame = adoptPtr(frame.m_fftFrame->copy()); >+} >+ >+FFTFrame::~FFTFrame() >+{ >+} >+ >+void FFTFrame::multiply(const FFTFrame& frame) >+{ >+ float* realP1 = realData(); >+ float* imagP1 = imagData(); >+ const float* realP2 = frame.realData(); >+ const float* imagP2 = frame.imagData(); >+ >+ const size_t size = m_fftFrame->frequencyDomainSampleCount(); >+ VectorMath::zvmul(realP1, imagP1, realP2, imagP2, realP1, imagP1, size); >+ >+ // Scale accounts the peculiar scaling of vecLib on the Mac. >+ // This ensures the right scaling all the way back to inverse FFT. >+ // FIXME: if we change the scaling on the Mac then this scale >+ // factor will need to change too. >+ const float scale = 0.5; >+ scalePlanarData(realP1, size, scale); >+ scalePlanarData(imagP1, size, scale); >+} >+ >+// Provides time domain samples in argument "data". Frame will store the transformed data. >+void FFTFrame::doFFT(const float* data) >+{ >+ m_fftFrame->doFFT(data); >+ // Scale the frequency domain data to match vecLib's scale factor >+ // on the Mac. FIXME: if we change the definition of FFTFrame to >+ // eliminate this scale factor then this code will need to change. >+ const float scale = 2; >+ const size_t size = m_fftFrame->frequencyDomainSampleCount(); >+ scalePlanarData(realData(), size, scale); >+ scalePlanarData(imagData(), size, scale); >+} >+ >+// Calculates inverse transform from the stored data, putting the results in argument 'data'. >+void FFTFrame::doInverseFFT(float* data) >+{ >+ m_fftFrame->doInverseFFT(data); >+ >+ // Scale so that a forward then inverse FFT yields exactly the original data. >+ const float scale = 1.0 / (2 * m_FFTSize); >+ for (unsigned i = 0; i < m_FFTSize; ++i) >+ data[i] = scale * data[i]; >+} >+ >+void FFTFrame::initialize() >+{ >+} >+ >+void FFTFrame::cleanup() >+{ >+} >+ >+float* FFTFrame::realData() const >+{ >+ return m_fftFrame->realData(); >+} >+ >+float* FFTFrame::imagData() const >+{ >+ return m_fftFrame->imagData(); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEB_AUDIO) >diff --git a/Source/WebCore/platform/nix/support/MultiChannelPCMData.cpp b/Source/WebCore/platform/nix/support/MultiChannelPCMData.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..3f2294c371373f4bef725499b0dbb6042f4b26e4 >--- /dev/null >+++ b/Source/WebCore/platform/nix/support/MultiChannelPCMData.cpp >@@ -0,0 +1,107 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <public/MultiChannelPCMData.h> >+ >+#if ENABLE(WEB_AUDIO) >+#include "AudioBus.h" >+#endif >+ >+namespace Nix { >+ >+static WebCore::AudioBus* toAudioBus(void* data) >+{ >+ return static_cast<WebCore::AudioBus*>(data); >+} >+ >+MultiChannelPCMData::MultiChannelPCMData(unsigned numberOfChannels, size_t length, double sampleRate) >+{ >+#if ENABLE(WEB_AUDIO) >+ WebCore::AudioBus* bus = WebCore::AudioBus::create(numberOfChannels, length).leakRef(); >+ bus->setSampleRate(sampleRate); >+ m_data = bus; >+#else >+ UNUSED_PARAM(numberOfChannels); >+ UNUSED_PARAM(length); >+ UNUSED_PARAM(sampleRate); >+ m_data = nullptr; >+#endif >+} >+ >+MultiChannelPCMData::~MultiChannelPCMData() >+{ >+ delete toAudioBus(m_data); >+} >+ >+void* MultiChannelPCMData::getInternalData() >+{ >+ // This transfer the ownership of m_data to the caller. >+ void* data = m_data; >+ m_data = 0; >+ return data; >+} >+ >+unsigned MultiChannelPCMData::numberOfChannels() const >+{ >+#if ENABLE(WEB_AUDIO) >+ if (m_data) >+ return toAudioBus(m_data)->numberOfChannels(); >+#endif >+ return 0; >+} >+ >+size_t MultiChannelPCMData::length() const >+{ >+#if ENABLE(WEB_AUDIO) >+ if (m_data) >+ return toAudioBus(m_data)->length(); >+#endif >+ return 0; >+} >+ >+double MultiChannelPCMData::sampleRate() const >+{ >+#if ENABLE(WEB_AUDIO) >+ if (m_data) >+ return toAudioBus(m_data)->sampleRate(); >+#endif >+ return 0; >+} >+ >+float* MultiChannelPCMData::channelData(unsigned channelIndex) >+{ >+#if ENABLE(WEB_AUDIO) >+ if (m_data) { >+ ASSERT(channelIndex < toAudioBus(m_data)->numberOfChannels()); >+ return toAudioBus(m_data)->channel(channelIndex)->mutableData(); >+ } >+#else >+ UNUSED_PARAM(channelIndex); >+#endif >+ return nullptr; >+} >+ >+} // namespace Nix >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index fb31e7c0e921e3a3398a57f2223e2324ff21f42d..e84e0f65661c352b160508364b8d7b743d0bb138 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2013-10-25 Hugo Parente Lima <hugo.lima@openbossa.org> >+ >+ Adding Nix files in Source/Platform to trunk >+ https://bugs.webkit.org/show_bug.cgi?id=118331 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a special rule for Nix API files located at Source/Platform/nix. >+ >+ * Scripts/webkitpy/style/checker.py: >+ > 2013-10-21 Tamas Gergely <gertom@inf.u-szeged.hu> > > Run tests as if they are expected to pass when --force is given. >diff --git a/Tools/Scripts/webkitpy/style/checker.py b/Tools/Scripts/webkitpy/style/checker.py >index f23d30773d292dcad10758842157ce2763533746..64513f136735e4077e7e52d11b20888319523603 100644 >--- a/Tools/Scripts/webkitpy/style/checker.py >+++ b/Tools/Scripts/webkitpy/style/checker.py >@@ -168,7 +168,11 @@ _PATH_RULES_SPECIFIER = [ > > ([# Header files in ForwardingHeaders have no header guards or > # exceptional header guards (e.g., WebCore_FWD_Debugger_h). >- "/ForwardingHeaders/"], >+ "/ForwardingHeaders/", >+ # Nix platform API classes uses common names under Nix namespace >+ # so the include guards should also include the namespace to avoid >+ # name clashes. >+ "Source/Platform/nix"], > ["-build/header_guard"]), > ([# assembler has lots of opcodes that use underscores, so > # we don't check for underscores in that directory.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 118331
:
205952
|
206015
|
206016
|
211064
|
211220
|
215193
|
215422
|
215435