Build most of the rest of the stream server core

Bug: 171711491
Change-Id: I5cc8a5304aec70b593e75ebbfc32376c6fab738f
diff --git a/base/StringUtils.cpp b/base/StringUtils.cpp
new file mode 100644
index 0000000..ce835b6
--- /dev/null
+++ b/base/StringUtils.cpp
@@ -0,0 +1,210 @@
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "android/base/misc/StringUtils.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _MSC_VER
+#include "msvc-posix.h"
+#endif
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#ifdef _WIN32
+const void* memmem(const void* haystack, size_t haystackLen,
+                   const void* needle, size_t needleLen) {
+    if (!haystack || !needle) {
+        return nullptr;
+    }
+
+    const auto it = std::search(
+                        static_cast<const char*>(haystack),
+                        static_cast<const char*>(haystack) + haystackLen,
+                        static_cast<const char*>(needle),
+                        static_cast<const char*>(needle) + needleLen);
+    return it == static_cast<const char*>(haystack) + haystackLen
+            ? nullptr
+            : it;
+}
+#endif  // _WIN32
+
+namespace android {
+namespace base {
+
+char* strDup(StringView view) {
+    // Same as strdup(str.c_str()) but avoids a strlen() call.
+    char* ret = static_cast<char*>(malloc(view.size() + 1u));
+    ::memcpy(ret, view.data(), view.size());
+    ret[view.size()] = '\0';
+    return ret;
+}
+
+bool strContains(StringView haystack, const char* needle) {
+    return ::memmem(haystack.data(), haystack.size(), needle,
+                    ::strlen(needle)) != nullptr;
+}
+
+std::string Trim(const std::string& s) {
+    std::string result;
+
+    if (s.size() == 0) {
+        return result;
+    }
+
+    size_t start_index = 0;
+    size_t end_index = s.size() - 1;
+
+    // Skip initial whitespace.
+    while (start_index < s.size()) {
+        if (!isspace(s[start_index])) {
+            break;
+        }
+        start_index++;
+    }
+
+    // Skip terminating whitespace.
+    while (end_index >= start_index) {
+        if (!isspace(s[end_index])) {
+            break;
+        }
+        end_index--;
+    }
+
+    // All spaces, no beef.
+    if (end_index < start_index) {
+        return "";
+    }
+    // Start_index is the first non-space, end_index is the last one.
+    return s.substr(start_index, end_index - start_index + 1);
+}
+
+std::string trim(const std::string& in) {
+    return Trim(in);
+}
+
+bool StartsWith(std::string_view s, std::string_view prefix) {
+    return s.substr(0, prefix.size()) == prefix;
+}
+
+bool startsWith(StringView string, StringView prefix) {
+    return string.size() >= prefix.size() &&
+            memcmp(string.data(), prefix.data(), prefix.size()) == 0;
+}
+
+bool endsWith(StringView string, StringView suffix) {
+    return string.size() >= suffix.size() &&
+            memcmp(string.data() + string.size() - suffix.size(),
+                   suffix.data(), suffix.size()) == 0;
+}
+
+void splitTokens(const std::string& input,
+                 std::vector<std::string>* out,
+                 StringView splitBy) {
+    auto removeWhiteSpace = [out](StringView strView) {
+        std::string s = strView.str();
+        s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
+        out->push_back(s);
+    };
+    out->clear();
+    split(input, splitBy, removeWhiteSpace);
+}
+
+#define CHECK_NE(a, b) \
+    if ((a) == (b))    \
+        abort();
+
+std::vector<std::string> Split(const std::string& s,
+                               const std::string& delimiters) {
+    CHECK_NE(delimiters.size(), 0U);
+
+    std::vector<std::string> result;
+
+    size_t base = 0;
+    size_t found;
+    while (true) {
+        found = s.find_first_of(delimiters, base);
+        result.push_back(s.substr(base, found - base));
+        if (found == s.npos)
+            break;
+        base = found + 1;
+    }
+
+    return result;
+}
+
+// These cases are probably the norm, so we mark them extern in the header to
+// aid compile time and binary size.
+template std::string Join(const std::vector<std::string>&, char);
+template std::string Join(const std::vector<const char*>&, char);
+template std::string Join(const std::vector<std::string>&, const std::string&);
+template std::string Join(const std::vector<const char*>&, const std::string&);
+
+bool StartsWith(std::string_view s, char prefix) {
+    return !s.empty() && s.front() == prefix;
+}
+
+bool StartsWithIgnoreCase(std::string_view s, std::string_view prefix) {
+    return s.size() >= prefix.size() &&
+           strncasecmp(s.data(), prefix.data(), prefix.size()) == 0;
+}
+
+bool EndsWith(std::string_view s, std::string_view suffix) {
+    return s.size() >= suffix.size() &&
+           s.substr(s.size() - suffix.size(), suffix.size()) == suffix;
+}
+
+bool EndsWith(std::string_view s, char suffix) {
+    return !s.empty() && s.back() == suffix;
+}
+
+bool EndsWithIgnoreCase(std::string_view s, std::string_view suffix) {
+    return s.size() >= suffix.size() &&
+           strncasecmp(s.data() + (s.size() - suffix.size()), suffix.data(),
+                       suffix.size()) == 0;
+}
+
+bool EqualsIgnoreCase(std::string_view lhs, std::string_view rhs) {
+    return lhs.size() == rhs.size() &&
+           strncasecmp(lhs.data(), rhs.data(), lhs.size()) == 0;
+}
+
+std::string StringReplace(std::string_view s,
+                          std::string_view from,
+                          std::string_view to,
+                          bool all) {
+    if (from.empty())
+        return std::string(s);
+
+    std::string result;
+    std::string_view::size_type start_pos = 0;
+    do {
+        std::string_view::size_type pos = s.find(from, start_pos);
+        if (pos == std::string_view::npos)
+            break;
+
+        result.append(s.data() + start_pos, pos - start_pos);
+        result.append(to.data(), to.size());
+
+        start_pos = pos + from.size();
+    } while (all);
+    result.append(s.data() + start_pos, s.size() - start_pos);
+    return result;
+}
+
+}  // namespace base
+}  // namespace android
diff --git a/base/StringUtils.h b/base/StringUtils.h
new file mode 100644
index 0000000..c5a452a
--- /dev/null
+++ b/base/StringUtils.h
@@ -0,0 +1,133 @@
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#include <functional>
+#include <iterator>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include <stddef.h>
+
+#ifdef _WIN32
+// Returns a pointer to the first occurrence of |needle| in |haystack|, or a
+// NULL pointer if |needle| is not part of |haystack|.
+// Intentionally in global namespace. This is already provided by the system
+// C library on Linux and OS X.
+extern "C" const void* memmem(const void* haystack, size_t haystack_len,
+                              const void* needle, size_t needlelen);
+#endif  // _WIN32
+
+namespace android {
+namespace base {
+
+// Iterates over a string's parts using |splitBy| as a delimiter.
+// |splitBy| must be a nonempty string well, or it's a no-op.
+// Otherwise, |func| is called on each of the splits, excluding the
+// characters that are part of |splitBy|.  If two |splitBy|'s occur in a row,
+// |func| will be called on a StringView("") in between. See
+// StringUtils_unittest.cpp for the full story.
+template <class String>
+void split(String str, String splitBy, std::function<void(const String&)> func) {
+    if (splitBy.empty()) return;
+
+    size_t splitSize = splitBy.size();
+    size_t begin = 0;
+    size_t end = str.find(splitBy);
+
+    while (true) {
+        func(str.substr(begin, end - begin));
+        if (end == std::string::npos) return;
+        begin = end + splitSize;
+        end = str.find(splitBy, begin);
+    }
+}
+
+// Splits a string into a vector of strings.
+//
+// The string is split at each occurrence of a character in delimiters.
+//
+// The empty string is not a valid delimiter list.
+std::vector<std::string> Split(const std::string& s,
+                               const std::string& delimiters);
+
+// Trims whitespace off both ends of the given string.
+std::string Trim(const std::string& s);
+
+// Joins a container of things into a single string, using the given separator.
+template <typename ContainerT, typename SeparatorT>
+std::string Join(const ContainerT& things, SeparatorT separator) {
+    if (things.empty()) {
+        return "";
+    }
+
+    std::ostringstream result;
+    result << *things.begin();
+    for (auto it = std::next(things.begin()); it != things.end(); ++it) {
+        result << separator << *it;
+    }
+    return result.str();
+}
+
+// We instantiate the common cases in strings.cpp.
+extern template std::string Join(const std::vector<std::string>&, char);
+extern template std::string Join(const std::vector<const char*>&, char);
+extern template std::string Join(const std::vector<std::string>&,
+                                 const std::string&);
+extern template std::string Join(const std::vector<const char*>&,
+                                 const std::string&);
+
+// Tests whether 's' starts with 'prefix'.
+bool StartsWith(std::string_view s, std::string_view prefix);
+bool StartsWith(std::string_view s, char prefix);
+bool StartsWithIgnoreCase(std::string_view s, std::string_view prefix);
+
+// Tests whether 's' ends with 'suffix'.
+bool EndsWith(std::string_view s, std::string_view suffix);
+bool EndsWith(std::string_view s, char suffix);
+bool EndsWithIgnoreCase(std::string_view s, std::string_view suffix);
+
+// Tests whether 'lhs' equals 'rhs', ignoring case.
+bool EqualsIgnoreCase(std::string_view lhs, std::string_view rhs);
+
+// Removes `prefix` from the start of the given string and returns true (if
+// it was present), false otherwise.
+inline bool ConsumePrefix(std::string_view* s, std::string_view prefix) {
+    if (!StartsWith(*s, prefix))
+        return false;
+    s->remove_prefix(prefix.size());
+    return true;
+}
+
+// Removes `suffix` from the end of the given string and returns true (if
+// it was present), false otherwise.
+inline bool ConsumeSuffix(std::string_view* s, std::string_view suffix) {
+    if (!EndsWith(*s, suffix))
+        return false;
+    s->remove_suffix(suffix.size());
+    return true;
+}
+
+// Replaces `from` with `to` in `s`, once if `all == false`, or as many times as
+// there are matches if `all == true`.
+[[nodiscard]] std::string StringReplace(std::string_view s,
+                                        std::string_view from,
+                                        std::string_view to,
+                                        bool all);
+
+}  // namespace base
+}  // namespace android
diff --git a/base/System.h b/base/System.h
index b40cf7c..7cd2aa5 100644
--- a/base/System.h
+++ b/base/System.h
@@ -18,6 +18,7 @@
 uint64_t getFileSize(int fd, uint64_t* size);
 
 void sleepMs(uint64_t ms);
+void sleepUs(uint64_t us);
 
 CpuTime cpuTime();
 
diff --git a/host-common/CMakeLists.txt b/host-common/CMakeLists.txt
index fc9f6a7..8976ed4 100644
--- a/host-common/CMakeLists.txt
+++ b/host-common/CMakeLists.txt
@@ -4,7 +4,8 @@
     vm_operations.cpp
     feature_control.cpp
     dma_device.cpp
-    sync_device.cpp)
+    sync_device.cpp
+    misc.cpp)
 target_include_directories(
     gfxstream-host-common
     PRIVATE
diff --git a/host-common/misc.cpp b/host-common/misc.cpp
new file mode 100644
index 0000000..aaf9f46
--- /dev/null
+++ b/host-common/misc.cpp
@@ -0,0 +1,104 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "misc.h"
+
+#include "base/GLObjectCounter.h"
+#include "base/MemoryTracker.h"
+
+#include <cstring>
+
+static int s_apiLevel = -1;
+static bool s_isPhone = false;
+
+static int s_glesMajorVersion = 2;
+static int s_glesMinorVersion = 0;
+
+android::base::GLObjectCounter* s_default_gl_object_counter = nullptr;
+
+android::base::GLObjectCounter* s_gl_object_counter = nullptr;
+android::base::CpuUsage* s_cpu_usage = nullptr;
+android::base::MemoryTracker* s_mem_usage = nullptr;
+
+static SelectedRenderer s_renderer =
+    SELECTED_RENDERER_HOST;
+
+void emugl::setAvdInfo(bool phone, int apiLevel) {
+    s_isPhone = phone;
+    s_apiLevel = apiLevel;
+}
+
+void emugl::getAvdInfo(bool* phone, int* apiLevel) {
+    if (phone) *phone = s_isPhone;
+    if (apiLevel) *apiLevel = s_apiLevel;
+}
+
+void emugl::setGlesVersion(int maj, int min) {
+    s_glesMajorVersion = maj;
+    s_glesMinorVersion = min;
+}
+
+void emugl::getGlesVersion(int* maj, int* min) {
+    if (maj) *maj = s_glesMajorVersion;
+    if (min) *min = s_glesMinorVersion;
+}
+
+void emugl::setRenderer(SelectedRenderer renderer) {
+    s_renderer = renderer;
+}
+
+SelectedRenderer emugl::getRenderer() {
+    return s_renderer;
+}
+
+bool emugl::hasExtension(const char* extensionsStr, const char* wantedExtension) {
+    const char* match = strstr(extensionsStr, wantedExtension);
+    size_t wantedTerminatorOffset = strlen(wantedExtension);
+    if (match &&
+        (match[wantedTerminatorOffset] == ' ' ||
+         match[wantedTerminatorOffset] == '\0')) {
+        return true;
+    }
+    return false;
+}
+
+void emugl::setGLObjectCounter(android::base::GLObjectCounter* counter) {
+    s_gl_object_counter = counter;
+}
+
+android::base::GLObjectCounter* emugl::getGLObjectCounter() {
+    if (!s_gl_object_counter) {
+        if (!s_default_gl_object_counter) {
+            s_default_gl_object_counter = new android::base::GLObjectCounter;
+        }
+        return s_default_gl_object_counter;
+    }
+    return s_gl_object_counter;
+}
+
+void emugl::setCpuUsage(android::base::CpuUsage* usage) {
+    s_cpu_usage = usage;
+}
+
+android::base::CpuUsage* emugl::getCpuUsage() {
+    return s_cpu_usage;
+}
+
+void emugl::setMemoryTracker(android::base::MemoryTracker* usage) {
+    s_mem_usage = usage;
+}
+
+android::base::MemoryTracker* emugl::getMemoryTracker() {
+    return s_mem_usage;
+}
diff --git a/host-common/misc.h b/host-common/misc.h
new file mode 100644
index 0000000..54e4960
--- /dev/null
+++ b/host-common/misc.h
@@ -0,0 +1,89 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#include "multi_display_agent.h"
+#include "window_agent.h"
+#include "emugl_config.h"
+
+#ifdef _MSC_VER
+# ifdef BUILDING_EMUGL_COMMON_SHARED
+#  define EMUGL_COMMON_API __declspec(dllexport)
+# else
+#  define EMUGL_COMMON_API __declspec(dllimport)
+#endif
+#else
+# define EMUGL_COMMON_API
+#endif
+
+// List of values used to identify a clockwise 90-degree rotation.
+typedef enum {
+    SKIN_ROTATION_0,
+    SKIN_ROTATION_90,
+    SKIN_ROTATION_180,
+    SKIN_ROTATION_270
+} SkinRotation;
+
+namespace android {
+
+namespace base {
+
+class CpuUsage;
+class MemoryTracker;
+class GLObjectCounter;
+
+} // namespace base
+} // namespace android
+
+namespace emugl {
+
+    // Set and get API version of system image.
+    EMUGL_COMMON_API void setAvdInfo(bool isPhone, int apiLevel);
+    EMUGL_COMMON_API void getAvdInfo(bool* isPhone, int* apiLevel);
+
+    // Set/get GLES major/minor version.
+    EMUGL_COMMON_API void setGlesVersion(int maj, int min);
+    EMUGL_COMMON_API void getGlesVersion(int* maj, int* min);
+
+    // Set/get renderer
+    EMUGL_COMMON_API void setRenderer(SelectedRenderer renderer);
+    EMUGL_COMMON_API SelectedRenderer getRenderer();
+
+    // Extension string query
+    EMUGL_COMMON_API bool hasExtension(const char* extensionsStr,
+                      const char* wantedExtension);
+
+    // GL object counter get/set
+    EMUGL_COMMON_API void setGLObjectCounter(
+            android::base::GLObjectCounter* counter);
+    EMUGL_COMMON_API android::base::GLObjectCounter* getGLObjectCounter();
+
+    // CPU usage get/set.
+    EMUGL_COMMON_API void setCpuUsage(android::base::CpuUsage* usage);
+    EMUGL_COMMON_API android::base::CpuUsage* getCpuUsage();
+
+    // Memory usage get/set
+    EMUGL_COMMON_API void setMemoryTracker(android::base::MemoryTracker* usage);
+    EMUGL_COMMON_API android::base::MemoryTracker* getMemoryTracker();
+
+    // Window operation agent
+    EMUGL_COMMON_API void set_emugl_window_operations(const QAndroidEmulatorWindowAgent &voperations);
+    EMUGL_COMMON_API const QAndroidEmulatorWindowAgent &get_emugl_window_operations();
+
+    // MultiDisplay operation agent
+    EMUGL_COMMON_API void set_emugl_multi_display_operations(const QAndroidMultiDisplayAgent &operations);
+    EMUGL_COMMON_API const QAndroidMultiDisplayAgent &get_emugl_multi_display_operations();
+
+}
diff --git a/host-common/multi_display_agent.h b/host-common/multi_display_agent.h
new file mode 100644
index 0000000..b487dfa
--- /dev/null
+++ b/host-common/multi_display_agent.h
@@ -0,0 +1,64 @@
+// Copyright 2019 The Android Open Source Project
+//
+// This software is licensed under the terms of the GNU General Public
+// License version 2, as published by the Free Software Foundation, and
+// may be copied, distributed, and modified under those terms.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+#pragma once
+
+#include <stdint.h>
+
+typedef struct QAndroidMultiDisplayAgent {
+    int (*setMultiDisplay)(uint32_t id,
+                           int32_t x,
+                           int32_t y,
+                           uint32_t w,
+                           uint32_t h,
+                           uint32_t dpi,
+                           uint32_t flag,
+                           bool add);
+    bool (*getMultiDisplay)(uint32_t id,
+                            int32_t* x,
+                            int32_t* y,
+                            uint32_t* w,
+                            uint32_t* h,
+                            uint32_t* dpi,
+                            uint32_t* flag,
+                            bool* enable);
+    bool (*getNextMultiDisplay)(int32_t start_id,
+                                uint32_t* id,
+                                int32_t* x,
+                                int32_t* y,
+                                uint32_t* w,
+                                uint32_t* h,
+                                uint32_t* dpi,
+                                uint32_t* flag,
+                                uint32_t* cb);
+    bool (*isMultiDisplayEnabled)(void);
+    void (*getCombinedDisplaySize)(uint32_t* width, uint32_t* height);
+    bool (*multiDisplayParamValidate)(uint32_t id, uint32_t w, uint32_t h,
+                                      uint32_t dpi, uint32_t flag);
+    bool (*translateCoordination)(uint32_t* x, uint32_t*y, uint32_t* displayId);
+    void (*setGpuMode)(bool isGuestMode, uint32_t w, uint32_t h);
+    int (*createDisplay)(uint32_t* displayId);
+    int (*destroyDisplay)(uint32_t displayId);
+    int (*setDisplayPose)(uint32_t displayId,
+                          int32_t x,
+                          int32_t y,
+                          uint32_t w,
+                          uint32_t h,
+                          uint32_t dpi);
+    int (*getDisplayPose)(uint32_t displayId,
+                         int32_t* x,
+                         int32_t* y,
+                         uint32_t* w,
+                         uint32_t* h);
+    int (*getDisplayColorBuffer)(uint32_t displayId, uint32_t* colorBuffer);
+    int (*getColorBufferDisplay)(uint32_t colorBuffer, uint32_t* displayId);
+    int (*setDisplayColorBuffer)(uint32_t displayId, uint32_t colorBuffer);
+} QAndroidMultiDisplayAgent;
diff --git a/snapshot/common.h b/snapshot/common.h
index 686c223..a3c0521 100644
--- a/snapshot/common.h
+++ b/snapshot/common.h
@@ -130,5 +130,15 @@
 #define SNAPSHOT_METRICS 1
 #endif
 
+enum SnapshotterOperation {
+    SNAPSHOTTER_OPERATION_SAVE,
+    SNAPSHOTTER_OPERATION_LOAD,
+};
+
+enum SnapshotterStage {
+    SNAPSHOTTER_STAGE_START,
+    SNAPSHOTTER_STAGE_END,
+};
+
 }  // namespace snapshot
 }  // namespace android
diff --git a/stream-servers/CMakeLists.txt b/stream-servers/CMakeLists.txt
index 7ad4288..caa8a1e 100644
--- a/stream-servers/CMakeLists.txt
+++ b/stream-servers/CMakeLists.txt
@@ -16,9 +16,40 @@
 add_subdirectory(renderControl_dec)
 
 # Stream server core
+set(gfxstream-server-common-sources
+    ChannelStream.cpp
+    ColorBuffer.cpp
+    FbConfig.cpp
+    FenceSync.cpp
+    GLESVersionDetector.cpp
+    PostWorker.cpp
+    ReadbackWorker.cpp
+    ReadBuffer.cpp
+    render_api.cpp
+    RenderChannelImpl.cpp
+    RenderThreadInfo.cpp
+    RingStream.cpp
+    SyncThread.cpp
+    TextureDraw.cpp
+    TextureResize.cpp
+    WindowSurface.cpp
+    YUVConverter.cpp
+    RenderThread.cpp
+    RenderWindow.cpp
+    RenderLibImpl.cpp
+    RendererImpl.cpp)
+if (APPLE)
+    set(gfxstream-server-platform-sources NativeSubWindow_cocoa.m)
+elseif (WIN32)
+    set(gfxstream-server-platform-sources NativeSubWindow_win32.cpp)
+else()
+    set(gfxstream-server-platform-sources NativeSubWindow_x11.cpp)
+endif()
+
 add_library(
     gfxstream-server
-    ChannelStream.cpp)
+    ${gfxstream-server-common-sources}
+    ${gfxstream-server-platform-sources})
 target_link_libraries(
     gfxstream-server
     gfxstream-host-common
diff --git a/stream-servers/ColorBuffer.cpp b/stream-servers/ColorBuffer.cpp
index 76dfdb8..c036fce 100644
--- a/stream-servers/ColorBuffer.cpp
+++ b/stream-servers/ColorBuffer.cpp
@@ -15,18 +15,17 @@
 */
 #include "ColorBuffer.h"
 
-#include "android/base/memory/ScopedPtr.h"
-
 #include "DispatchTables.h"
-#include "GLcommon/GLutils.h"
+#include "glestranslator/include/GLcommon/GLutils.h"
 #include "RenderThreadInfo.h"
 #include "TextureDraw.h"
 #include "TextureResize.h"
 #include "YUVConverter.h"
 
+#include "OpenGLESDispatch/DispatchTables.h"
 #include "OpenGLESDispatch/EGLDispatch.h"
 
-#include "emugl/common/misc.h"
+#include "host-common/misc.h"
 
 #include <GLES2/gl2ext.h>
 
@@ -218,16 +217,6 @@
 
     const unsigned long bufsize = ((unsigned long)bytesPerPixel) * p_width
             * p_height;
-    android::base::ScopedCPtr<char> initialImage(
-                static_cast<char*>(::malloc(bufsize)));
-    if (!initialImage) {
-        fprintf(stderr,
-                "error: failed to allocate initial memory for ColorBuffer "
-                "of size %dx%dx%d (%lu KB)\n",
-                p_width, p_height, bytesPerPixel * 8, bufsize / 1024);
-        return nullptr;
-    }
-    memset(initialImage.get(), 0x0, bufsize);
 
     RecursiveScopedHelperContext context(helper);
     if (!context.isOk()) {
@@ -244,9 +233,7 @@
     s_gles2.glBindTexture(GL_TEXTURE_2D, cb->m_tex);
 
     s_gles2.glTexImage2D(GL_TEXTURE_2D, 0, p_internalFormat, p_width, p_height,
-                         0, texFormat, pixelType,
-                         initialImage.get());
-    initialImage.reset();
+                         0, texFormat, pixelType, nullptr);
 
     s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -375,7 +362,7 @@
                                    int height,
                                    GLenum p_format,
                                    GLenum p_type,
-                                   SkinRotation rotation,
+                                   int rotation,
                                    void* pixels) {
     RecursiveScopedHelperContext context(m_helper);
     if (!context.isOk()) {
diff --git a/stream-servers/FbConfig.cpp b/stream-servers/FbConfig.cpp
index ebc559b..c334d50 100644
--- a/stream-servers/FbConfig.cpp
+++ b/stream-servers/FbConfig.cpp
@@ -14,9 +14,9 @@
 
 #include "FbConfig.h"
 
-#include "android/opengl/emugl_config.h"
-#include "emugl/common/feature_control.h"
-#include "emugl/common/misc.h"
+#include "host-common/emugl_config.h"
+#include "host-common/feature_control.h"
+#include "host-common/misc.h"
 #include "FrameBuffer.h"
 #include "OpenGLESDispatch/EGLDispatch.h"
 
@@ -121,8 +121,8 @@
 
         // Don't report ES3 renderable type if we don't support it.
         if (kConfigAttributes[i] == EGL_RENDERABLE_TYPE) {
-            if (!emugl::emugl_feature_is_enabled(
-                        android::featurecontrol::GLESDynamicVersion) &&
+            if (!feature_is_enabled(
+                        kFeature_GLESDynamicVersion) &&
                 mAttribValues[i] & EGL_OPENGL_ES3_BIT) {
                 mAttribValues[i] &= ~EGL_OPENGL_ES3_BIT;
             }
@@ -197,8 +197,8 @@
         if (attribs[numAttribs] == EGL_RENDERABLE_TYPE) {
             if (attribs[numAttribs + 1] != EGL_DONT_CARE &&
                 attribs[numAttribs + 1] & EGL_OPENGL_ES3_BIT_KHR &&
-                (!emugl::emugl_feature_is_enabled(
-                         android::featurecontrol::GLESDynamicVersion) ||
+                (!feature_is_enabled(
+                         kFeature_GLESDynamicVersion) ||
                  FrameBuffer::getMaxGLESVersion() <
                          GLES_DISPATCH_MAX_VERSION_3_0)) {
                 return 0;
diff --git a/stream-servers/FenceSync.cpp b/stream-servers/FenceSync.cpp
index 0867bca..0d37176 100644
--- a/stream-servers/FenceSync.cpp
+++ b/stream-servers/FenceSync.cpp
@@ -22,16 +22,14 @@
 #include "RenderThreadInfo.h"
 #include "StalePtrRegistry.h"
 
-#include "android/base/containers/Lookup.h"
-#include "android/base/containers/StaticMap.h"
-#include "android/base/files/StreamSerializing.h"
-#include "android/base/memory/LazyInstance.h"
-#include "android/base/synchronization/Lock.h"
+#include "base/Lookup.h"
+#include "base/StaticMap.h"
+#include "base/StreamSerializing.h"
+#include "base/Lock.h"
 
 #include <unordered_set>
 
 using android::base::AutoLock;
-using android::base::LazyInstance;
 using android::base::Lock;
 using android::base::StaticMap;
 
@@ -79,11 +77,14 @@
     StaticMap<FenceSync*, int> mFences;
 };
 
-static LazyInstance<Timeline> sTimeline = LAZY_INSTANCE_INIT;
+static Timeline* sTimeline() {
+    static Timeline* t = new Timeline;
+    return t;
+}
 
 // static
 void FenceSync::incrementTimelineAndDeleteOldFences() {
-    sTimeline->incrementTimelineAndDeleteOldFences();
+    sTimeline()->incrementTimelineAndDeleteOldFences();
 }
 
 FenceSync::FenceSync(bool hasNativeFence,
@@ -95,7 +96,7 @@
     assert(mCount == 1);
     if (hasNativeFence) {
         incRef();
-        sTimeline->addFence(this);
+        sTimeline()->addFence(this);
     }
 
     // assumes that there is a valid + current OpenGL context
@@ -157,31 +158,33 @@
 // snapshot.
 
 // Maintain a StalePtrRegistry<FenceSync>:
-static android::base::LazyInstance<StalePtrRegistry<FenceSync> >
-    sFenceRegistry = LAZY_INSTANCE_INIT;
+static StalePtrRegistry<FenceSync>* sFenceRegistry() {
+    static StalePtrRegistry<FenceSync>* s = new StalePtrRegistry<FenceSync>;
+    return s;
+}
 
 // static
 void FenceSync::addToRegistry() {
-    sFenceRegistry->addPtr(this);
+    sFenceRegistry()->addPtr(this);
 }
 
 // static
 void FenceSync::removeFromRegistry() {
-    sFenceRegistry->removePtr(this);
+    sFenceRegistry()->removePtr(this);
 }
 
 // static
 void FenceSync::onSave(android::base::Stream* stream) {
-    sFenceRegistry->makeCurrentPtrsStale();
-    sFenceRegistry->onSave(stream);
+    sFenceRegistry()->makeCurrentPtrsStale();
+    sFenceRegistry()->onSave(stream);
 }
 
 // static
 void FenceSync::onLoad(android::base::Stream* stream) {
-    sFenceRegistry->onLoad(stream);
+    sFenceRegistry()->onLoad(stream);
 }
 
 // static
 FenceSync* FenceSync::getFromHandle(uint64_t handle) {
-    return sFenceRegistry->getPtr(handle);
+    return sFenceRegistry()->getPtr(handle);
 }
diff --git a/stream-servers/FenceSync.h b/stream-servers/FenceSync.h
index b61d025..62d2048 100644
--- a/stream-servers/FenceSync.h
+++ b/stream-servers/FenceSync.h
@@ -16,10 +16,9 @@
 
 #pragma once
 
-#include "android/base/Compiler.h"
-#include "android/base/files/Stream.h"
-#include "android/base/memory/LazyInstance.h"
-#include "android/base/synchronization/Lock.h"
+#include "base/Compiler.h"
+#include "base/Stream.h"
+#include "base/Lock.h"
 
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
diff --git a/stream-servers/GLESVersionDetector.cpp b/stream-servers/GLESVersionDetector.cpp
index 7164a71..6bcf950 100644
--- a/stream-servers/GLESVersionDetector.cpp
+++ b/stream-servers/GLESVersionDetector.cpp
@@ -18,19 +18,13 @@
 
 #include "EGLDispatch.h"
 
-#include "android/base/misc/StringUtils.h"
-#include "android/base/StringView.h"
-#include "android/base/system/System.h"
-#include "emugl/common/feature_control.h"
-#include "emugl/common/misc.h"
+#include "base/System.h"
+#include "base/StringUtils.h"
+#include "host-common/feature_control.h"
+#include "host-common/misc.h"
 
 #include <algorithm>
 
-using android::base::c_str;
-using android::base::OsType;
-using android::base::StringView;
-using android::base::System;
-
 // Config + context attributes to query the underlying OpenGL if it is
 // a OpenGL ES backend. Only try for OpenGL ES 3, and assume OpenGL ES 2
 // exists (if it doesn't, this is the least of our problems).
@@ -103,8 +97,8 @@
        GLES_DISPATCH_MAX_VERSION_3_1;
 
     // TODO: CTS conformance for OpenGL ES 3.1
-    bool playStoreImage = emugl::emugl_feature_is_enabled(
-            android::featurecontrol::PlayStoreImage);
+    bool playStoreImage = feature_is_enabled(
+            kFeature_PlayStoreImage);
 
     if (emugl::getRenderer() == SELECTED_RENDERER_HOST
         || emugl::getRenderer() == SELECTED_RENDERER_SWIFTSHADER_INDIRECT
@@ -163,19 +157,19 @@
 void sAddExtensionIfSupported(GLESDispatchMaxVersion currVersion,
                               const std::string& from,
                               GLESDispatchMaxVersion extVersion,
-                              StringView ext,
+                              const std::string& ext,
                               std::string& to) {
     // If we chose a GLES version less than or equal to
     // the |extVersion| the extension |ext| is tagged with,
     // filter it according to the whitelist.
-    if (emugl::hasExtension(from.c_str(), c_str(ext)) &&
+    if (emugl::hasExtension(from.c_str(), ext.c_str()) &&
         currVersion > extVersion) {
         to += ext;
         to += " ";
     }
 }
 
-static bool sWhitelistedExtensionsGLES2(StringView hostExt) {
+static bool sWhitelistedExtensionsGLES2(const std::string& hostExt) {
 
 #define WHITELIST(ext) \
     if (hostExt == #ext) return true; \
@@ -228,14 +222,14 @@
     // b. the guest image is not updated for ES 3+
     // (GLESDynamicVersion is disabled)
     if (ver > GLES_DISPATCH_MAX_VERSION_2 &&
-        emugl::emugl_feature_is_enabled(
-                android::featurecontrol::GLESDynamicVersion)) {
+        feature_is_enabled(
+            kFeature_GLESDynamicVersion)) {
         return exts;
     }
 
     std::string filteredExtensions;
     filteredExtensions.reserve(4096);
-    auto add = [ver, &filteredExtensions](StringView hostExt) {
+    auto add = [ver, &filteredExtensions](const std::string& hostExt) {
         if (!hostExt.empty() &&
             sWhitelistedExtensionsGLES2(hostExt)) {
             filteredExtensions += hostExt;
@@ -243,7 +237,7 @@
         }
     };
 
-    android::base::split(exts, " ", add);
+    android::base::split<std::string>(exts, " ", add);
 
     return filteredExtensions;
 }
diff --git a/stream-servers/NativeSubWindow.h b/stream-servers/NativeSubWindow.h
index 745d670..17da64c 100644
--- a/stream-servers/NativeSubWindow.h
+++ b/stream-servers/NativeSubWindow.h
@@ -16,7 +16,7 @@
 #ifndef NATIVE_SUB_WINDOW_H
 #define NATIVE_SUB_WINDOW_H
 
-#include "OpenglRender/render_api_platform_types.h"
+#include "render_api_platform_types.h"
 
 #include <EGL/egl.h>
 
diff --git a/stream-servers/NativeSubWindow_cocoa.m b/stream-servers/NativeSubWindow_cocoa.m
new file mode 100644
index 0000000..c0f7db2
--- /dev/null
+++ b/stream-servers/NativeSubWindow_cocoa.m
@@ -0,0 +1,103 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "NativeSubWindow.h"
+#include <Cocoa/Cocoa.h>
+
+/*
+ * EmuGLView inherit from NSView and override the isOpaque
+ * method to return YES. That prevents drawing of underlying window/view
+ * when the view needs to be redrawn.
+ */
+@interface EmuGLView : NSView {
+} @end
+
+@implementation EmuGLView
+
+  - (BOOL)isOpaque {
+      return YES;
+  }
+
+@end
+
+EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
+                                    int x,
+                                    int y,
+                                    int width,
+                                    int height,
+                                    SubWindowRepaintCallback repaint_callback,
+                                    void* repaint_callback_param,
+                                    int hideWindow) {
+    NSWindow* win = (NSWindow *)p_window;
+    if (!win) {
+        return NULL;
+    }
+
+    /* (x,y) assume an upper-left origin, but Cocoa uses a lower-left origin */
+    NSRect content_rect = [win contentRectForFrameRect:[win frame]];
+    int cocoa_y = (int)content_rect.size.height - (y + height);
+    NSRect contentRect = NSMakeRect(x, cocoa_y, width, height);
+
+    NSView *glView = [[EmuGLView alloc] initWithFrame:contentRect];
+    if (glView) {
+        [glView setWantsBestResolutionOpenGLSurface:YES];
+        [[win contentView] addSubview:glView];
+        [win makeKeyAndOrderFront:nil];
+        if (hideWindow) {
+            [glView setHidden:YES];
+        }
+    }
+
+    return (EGLNativeWindowType)glView;
+}
+
+void destroySubWindow(EGLNativeWindowType win) {
+    if(win){
+        NSView *glView = (NSView *)win;
+        [glView removeFromSuperview];
+        [glView release];
+    }
+}
+
+int moveSubWindow(FBNativeWindowType p_parent_window,
+                  EGLNativeWindowType p_sub_window,
+                  int x,
+                  int y,
+                  int width,
+                  int height) {
+    NSWindow *win = (NSWindow *)p_parent_window;
+    if (!win) {
+        return 0;
+    }
+
+    NSView *glView = (NSView *)p_sub_window;
+    if (!glView) {
+        return 0;
+    }
+
+    /* The view must be removed from the hierarchy to be properly resized */
+    [glView removeFromSuperview];
+
+    /* (x,y) assume an upper-left origin, but Cocoa uses a lower-left origin */
+    NSRect content_rect = [win contentRectForFrameRect:[win frame]];
+    int cocoa_y = (int)content_rect.size.height - (y + height);
+    NSRect newFrame = NSMakeRect(x, cocoa_y, width, height);
+    [glView setFrame:newFrame];
+
+    /* Re-add the sub-window to the view hierarchy */
+    [[win contentView] addSubview:glView];
+
+    return 1;
+}
diff --git a/stream-servers/PostWorker.cpp b/stream-servers/PostWorker.cpp
index a979c97..d379773 100644
--- a/stream-servers/PostWorker.cpp
+++ b/stream-servers/PostWorker.cpp
@@ -6,7 +6,7 @@
 #include "RenderThreadInfo.h"
 #include "OpenGLESDispatch/EGLDispatch.h"
 #include "OpenGLESDispatch/GLESv2Dispatch.h"
-#include "emugl/common/misc.h"
+#include "host-common/misc.h"
 
 #define POST_DEBUG 0
 #if POST_DEBUG >= 1
@@ -267,7 +267,7 @@
     int height,
     GLenum format,
     GLenum type,
-    SkinRotation rotation,
+    int rotation,
     void* pixels) {
     cb->readPixelsScaled(
         width, height, format, type, rotation, pixels);
diff --git a/stream-servers/PostWorker.h b/stream-servers/PostWorker.h
index 069f116..f4a1d3c 100644
--- a/stream-servers/PostWorker.h
+++ b/stream-servers/PostWorker.h
@@ -10,7 +10,6 @@
 #include "Hwc2.h"
 #include "base/Compiler.h"
 #include "base/Lock.h"
-// #include "android/skin/rect.h"
 
 class ColorBuffer;
 class FrameBuffer;
diff --git a/stream-servers/ReadBuffer.h b/stream-servers/ReadBuffer.h
index cabea68..b7a970c 100644
--- a/stream-servers/ReadBuffer.h
+++ b/stream-servers/ReadBuffer.h
@@ -14,8 +14,8 @@
 * limitations under the License.
 */
 #pragma once
-#include "android/base/files/Stream.h"
-#include "OpenglRender/IOStream.h"
+#include "base/Stream.h"
+#include "IOStream.h"
 
 namespace emugl {
 
diff --git a/stream-servers/ReadbackWorker.cpp b/stream-servers/ReadbackWorker.cpp
index 275fda9..21a21b0 100644
--- a/stream-servers/ReadbackWorker.cpp
+++ b/stream-servers/ReadbackWorker.cpp
@@ -9,7 +9,7 @@
 #include "FrameBuffer.h"                      // for FrameBuffer
 #include "OpenGLESDispatch/EGLDispatch.h"     // for EGLDispatch, s_egl
 #include "OpenGLESDispatch/GLESv2Dispatch.h"  // for GLESv2Dispatch
-#include "emugl/common/misc.h"                // for getGlesVersion
+#include "host-common/misc.h"                // for getGlesVersion
 
 ReadbackWorker::recordDisplay::recordDisplay(uint32_t displayId, uint32_t w, uint32_t h)
     : mBufferSize(4 * w * h /* RGBA8 (4 bpp) */),
diff --git a/stream-servers/RenderChannelImpl.cpp b/stream-servers/RenderChannelImpl.cpp
index aae7dac..a0f8ecc 100644
--- a/stream-servers/RenderChannelImpl.cpp
+++ b/stream-servers/RenderChannelImpl.cpp
@@ -14,7 +14,7 @@
 #include "RenderChannelImpl.h"
 
 #include "RenderThread.h"
-#include "android/base/synchronization/Lock.h"
+#include "base/Lock.h"
 
 #include <algorithm>
 #include <utility>
@@ -23,7 +23,7 @@
 #include <string.h>
 
 #define EMUGL_DEBUG_LEVEL 0
-#include "emugl/common/debug.h"
+#include "host-common/debug.h"
 
 namespace emugl {
 
diff --git a/stream-servers/RenderControl.h b/stream-servers/RenderControl.h
index 0b24627..625549e 100644
--- a/stream-servers/RenderControl.h
+++ b/stream-servers/RenderControl.h
@@ -16,7 +16,7 @@
 #ifndef _RENDER_CONTROL_H
 #define _RENDER_CONTROL_H
 
-#include "renderControl_dec.h"
+#include "renderControl_dec/renderControl_dec.h"
 
 void initRenderControlContext(renderControl_decoder_context_t *dec);
 void registerTriggerWait();
diff --git a/stream-servers/RenderLib.h b/stream-servers/RenderLib.h
index 64f1966..97bf28c 100644
--- a/stream-servers/RenderLib.h
+++ b/stream-servers/RenderLib.h
@@ -21,8 +21,15 @@
 #include "host-common/RefcountPipe.h"
 #include "host-common/vm_operations.h"
 #include "host-common/window_agent.h"
+#include "host-common/multi_display_agent.h"
 #include "host-common/emugl_config.h"
 
+extern "C" {
+
+struct address_space_device_control_ops;
+
+} // extern "C"
+
 namespace android {
 namespace base {
 
@@ -73,15 +80,17 @@
     virtual void setDmaOps(emugl_dma_ops) = 0;
 
     virtual void setVmOps(const QAndroidVmOperations &vm_operations) = 0;
+    virtual void setAddressSpaceDeviceControlOps(struct address_space_device_control_ops* ops) = 0;
 
-    virtual void setWindowOps(const QAndroidEmulatorWindowAgent &window_operations) = 0;
+    virtual void setWindowOps(const QAndroidEmulatorWindowAgent &window_operations,
+                              const QAndroidMultiDisplayAgent &multi_display_operations) = 0;
 
     virtual void setUsageTracker(android::base::CpuUsage* cpuUsage,
                                  android::base::MemoryTracker* memUsage) = 0;
 
-    virtual void* getGL(void) = 0;
+    virtual void* getGLESv2Dispatch(void) = 0;
 
-    virtual void* getEGL(void) = 0;
+    virtual void* getEGLDispatch(void) = 0;
 
     virtual bool getOpt(RenderOpt* opt) = 0;
 
diff --git a/stream-servers/RenderLibImpl.cpp b/stream-servers/RenderLibImpl.cpp
index 636ddf1..220fed0 100644
--- a/stream-servers/RenderLibImpl.cpp
+++ b/stream-servers/RenderLibImpl.cpp
@@ -16,15 +16,14 @@
 #include "FrameBuffer.h"
 #include "RendererImpl.h"
 
-#include "android/base/CpuUsage.h"
-#include "android/base/files/Stream.h"
-#include "emugl/common/address_space_device_control_ops.h"
-#include "emugl/common/crash_reporter.h"
-#include "emugl/common/dma_device.h"
-#include "emugl/common/feature_control.h"
-#include "emugl/common/logging.h"
-#include "emugl/common/misc.h"
-#include "emugl/common/sync_device.h"
+#include "base/Stream.h"
+#include "host-common/address_space_device_control_ops.h"
+#include "host-common/crash_reporter.h"
+#include "host-common/dma_device.h"
+#include "host-common/feature_control.h"
+#include "host-common/logging.h"
+#include "host-common/misc.h"
+#include "host-common/sync_device.h"
 
 #include "OpenGLESDispatch/EGLDispatch.h"
 #include "OpenGLESDispatch/DispatchTables.h"
@@ -44,8 +43,8 @@
 }
 
 void RenderLibImpl::setLogger(emugl_logger_struct logger) {
-    set_emugl_logger(logger.coarse);
-    set_emugl_cxt_logger(logger.fine);
+    // set_emugl_logger(logger.coarse);
+    // set_emugl_cxt_logger(logger.fine);
 }
 
 void RenderLibImpl::setGLObjectCounter(
@@ -54,11 +53,11 @@
 }
 
 void RenderLibImpl::setCrashReporter(emugl_crash_reporter_t reporter) {
-    set_emugl_crash_reporter(reporter);
+    // set_emugl_crash_reporter(reporter);
 }
 
 void RenderLibImpl::setFeatureController(emugl_feature_is_enabled_t featureController) {
-    set_emugl_feature_is_enabled(featureController);
+    // set_emugl_feature_is_enabled(featureController);
 }
 
 void RenderLibImpl::setSyncDevice
diff --git a/stream-servers/RenderLibImpl.h b/stream-servers/RenderLibImpl.h
index e7ef37a..6304345 100644
--- a/stream-servers/RenderLibImpl.h
+++ b/stream-servers/RenderLibImpl.h
@@ -13,11 +13,11 @@
 // limitations under the License.
 #pragma once
 
-#include "OpenglRender/RenderLib.h"
+#include "RenderLib.h"
 
-#include "android/base/Compiler.h"
-#include "emugl/common/vm_operations.h"
-#include "emugl/common/misc.h"
+#include "base/Compiler.h"
+#include "host-common/vm_operations.h"
+#include "host-common/misc.h"
 
 #include <memory>
 
diff --git a/stream-servers/RenderThread.cpp b/stream-servers/RenderThread.cpp
index 470e847..638278b 100644
--- a/stream-servers/RenderThread.cpp
+++ b/stream-servers/RenderThread.cpp
@@ -28,20 +28,19 @@
 #include "OpenGLESDispatch/EGLDispatch.h"
 #include "OpenGLESDispatch/GLESv2Dispatch.h"
 #include "OpenGLESDispatch/GLESv1Dispatch.h"
-#include "../../../shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h"
+#include "apigen-codec-common/ChecksumCalculatorThreadInfo.h"
 
-#include "android/base/system/System.h"
-#include "android/base/Tracing.h"
-#include "android/base/files/StreamSerializing.h"
-#include "android/base/synchronization/MessageChannel.h"
-#include "android/utils/path.h"
-#include "android/utils/file_io.h"
+#include "base/System.h"
+#include "base/Tracing.h"
+#include "base/StreamSerializing.h"
+#include "base/MessageChannel.h"
 
 #define EMUGL_DEBUG_LEVEL 0
-#include "emugl/common/crash_reporter.h"
-#include "emugl/common/debug.h"
+#include "host-common/crash_reporter.h"
+#include "host-common/debug.h"
 
 #include <assert.h>
+#include <string.h>
 
 using android::base::AutoLock;
 using android::base::MessageChannel;
@@ -57,14 +56,14 @@
 };
 
 static bool getBenchmarkEnabledFromEnv() {
-    auto threadEnabled = android::base::System::getEnvironmentVariable("ANDROID_EMUGL_RENDERTHREAD_STATS");
+    auto threadEnabled = android::base::getEnvironmentVariable("ANDROID_EMUGL_RENDERTHREAD_STATS");
     if (threadEnabled == "1") return true;
     return false;
 }
 
 static uint64_t currTimeUs(bool enable) {
     if (enable) {
-        return android::base::System::get()->getHighResTimeUs();
+        return android::base::getHighResTimeUs();
     } else {
         return 0;
     }
@@ -75,7 +74,7 @@
 
 RenderThread::RenderThread(RenderChannelImpl* channel,
                            android::base::Stream* loadStream)
-    : emugl::Thread(android::base::ThreadFlags::MaskSignals, 2 * 1024 * 1024),
+    : android::base::Thread(android::base::ThreadFlags::MaskSignals, 2 * 1024 * 1024),
       mChannel(channel) {
     if (loadStream) {
         const bool success = loadStream->getByte();
@@ -93,7 +92,7 @@
         struct asg_context context,
         android::emulation::asg::ConsumerCallbacks callbacks,
         android::base::Stream* loadStream)
-    : emugl::Thread(android::base::ThreadFlags::MaskSignals, 2 * 1024 * 1024),
+    : android::base::Thread(android::base::ThreadFlags::MaskSignals, 2 * 1024 * 1024),
       mRingStream(
           new RingStream(context, callbacks, kStreamBufferSize)) {
     if (loadStream) {
@@ -298,7 +297,7 @@
 
     int stats_totalBytes = 0;
     uint64_t stats_progressTimeUs = 0;
-    auto stats_t0 = android::base::System::get()->getHighResTimeUs() / 1000;
+    auto stats_t0 = android::base::getHighResTimeUs() / 1000;
     bool benchmarkEnabled = getBenchmarkEnabledFromEnv();
 
     //
@@ -307,15 +306,15 @@
     const char* dump_dir = getenv("RENDERER_DUMP_DIR");
     FILE* dumpFP = nullptr;
     if (dump_dir) {
-        size_t bsize = strlen(dump_dir) + 32;
-        char* fname = new char[bsize];
-        snprintf(fname, bsize, "%s" PATH_SEP "stream_%p", dump_dir, this);
-        dumpFP = android_fopen(fname, "wb");
-        if (!dumpFP) {
-            fprintf(stderr, "Warning: stream dump failed to open file %s\n",
-                    fname);
-        }
-        delete[] fname;
+        // size_t bsize = strlen(dump_dir) + 32;
+        // char* fname = new char[bsize];
+        // snprintf(fname, bsize, "%s" PATH_SEP "stream_%p", dump_dir, this);
+        // dumpFP = android_fopen(fname, "wb");
+        // if (!dumpFP) {
+        //     fprintf(stderr, "Warning: stream dump failed to open file %s\n",
+        //             fname);
+        // }
+        // delete[] fname;
     }
 
     while (1) {
@@ -327,8 +326,8 @@
             if (!packetSize) {
                 // Emulator will get live-stuck here if packet size is read to be zero;
                 // crash right away so we can see these events.
-                emugl::emugl_crash_reporter(
-                    "Guest should never send a size-0 GL packet\n");
+                // emugl::emugl_crash_reporter(
+                //     "Guest should never send a size-0 GL packet\n");
             }
         } else {
             // Read enough data to at least be able to get the packet size next
@@ -369,14 +368,14 @@
         //
         if (benchmarkEnabled) {
             stats_totalBytes += readBuf.validData();
-            auto dt = android::base::System::get()->getHighResTimeUs() / 1000 - stats_t0;
+            auto dt = android::base::getHighResTimeUs() / 1000 - stats_t0;
             if (dt > 1000) {
                 float dts = (float)dt / 1000.0f;
                 printf("Used Bandwidth %5.3f MB/s, time in progress %f ms total %f ms\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f),
                         stats_progressTimeUs / 1000.0f,
                         (float)dt);
                 readBuf.printStats();
-                stats_t0 = android::base::System::get()->getHighResTimeUs() / 1000;
+                stats_t0 = android::base::getHighResTimeUs() / 1000;
                 stats_progressTimeUs = 0;
                 stats_totalBytes = 0;
             }
diff --git a/stream-servers/RenderThreadInfo.cpp b/stream-servers/RenderThreadInfo.cpp
index 2625ffb..4279af0 100644
--- a/stream-servers/RenderThreadInfo.cpp
+++ b/stream-servers/RenderThreadInfo.cpp
@@ -16,11 +16,10 @@
 
 #include "RenderThreadInfo.h"
 
-#include "android/base/containers/Lookup.h"
-#include "android/base/files/StreamSerializing.h"
-#include "android/base/synchronization/Lock.h"
+#include "base/Lookup.h"
+#include "base/StreamSerializing.h"
+#include "base/Lock.h"
 
-#include "emugl/common/lazy_instance.h"
 #include "FrameBuffer.h"
 
 #include <unordered_map>
diff --git a/stream-servers/RenderThreadInfo.h b/stream-servers/RenderThreadInfo.h
index 2a877d3..fc69370 100644
--- a/stream-servers/RenderThreadInfo.h
+++ b/stream-servers/RenderThreadInfo.h
@@ -16,12 +16,12 @@
 #ifndef _LIB_OPENGL_RENDER_THREAD_INFO_H
 #define _LIB_OPENGL_RENDER_THREAD_INFO_H
 
-#include "android/base/files/Stream.h"
+#include "base/Stream.h"
 #include "RenderContext.h"
 #include "WindowSurface.h"
-#include "GLESv1Decoder.h"
-#include "GLESv2Decoder.h"
-#include "renderControl_dec.h"
+#include "gles1_dec/GLESv1Decoder.h"
+#include "gles2_dec/GLESv2Decoder.h"
+#include "renderControl_dec/renderControl_dec.h"
 #include "VkDecoder.h"
 #include "StalePtrRegistry.h"
 #include "SyncThread.h"
diff --git a/stream-servers/RenderWindow.cpp b/stream-servers/RenderWindow.cpp
index a04702f..cf972a5 100644
--- a/stream-servers/RenderWindow.cpp
+++ b/stream-servers/RenderWindow.cpp
@@ -14,10 +14,9 @@
 
 #include "RenderWindow.h"
 
-#include "emugl/common/logging.h"
-#include "emugl/common/message_channel.h"
-#include "emugl/common/mutex.h"
-#include "emugl/common/thread.h"
+#include "base/Thread.h"
+#include "base/MessageChannel.h"
+#include "host-common/logging.h"
 #include "FrameBuffer.h"
 #include "RendererImpl.h"
 
@@ -40,7 +39,7 @@
 
 #if DEBUG
 void my_debug(const char* function, int line, const char* format, ...) {
-    static ::emugl::Mutex mutex;
+    static ::android::base::Lock mutex;
     va_list args;
     va_start(args, format);
     mutex.lock();
@@ -318,8 +317,8 @@
     }
 
 private:
-    emugl::MessageChannel<RenderWindowMessage, 16U> mIn;
-    emugl::MessageChannel<bool, 16U> mOut;
+    android::base::MessageChannel<RenderWindowMessage, 16U> mIn;
+    android::base::MessageChannel<bool, 16U> mOut;
 };
 
 namespace {
@@ -330,7 +329,7 @@
 //
 // The thread ends with a CMD_FINALIZE.
 //
-class RenderWindowThread : public emugl::Thread {
+class RenderWindowThread : public android::base::Thread {
 public:
     RenderWindowThread(RenderWindowChannel* channel) : mChannel(channel) {}
 
diff --git a/stream-servers/RendererImpl.cpp b/stream-servers/RendererImpl.cpp
index 7dd6508..7b478ef 100644
--- a/stream-servers/RendererImpl.cpp
+++ b/stream-servers/RendererImpl.cpp
@@ -16,10 +16,10 @@
 #include "RenderChannelImpl.h"
 #include "RenderThread.h"
 
-#include "android/base/system/System.h"
-#include "android/utils/debug.h"
+#include "base/System.h"
+#include "snapshot/common.h"
+#include "host-common/logging.h"
 
-#include "emugl/common/logging.h"
 #include "ErrorLog.h"
 #include "FenceSync.h"
 #include "FrameBuffer.h"
@@ -101,8 +101,8 @@
 }
 
 bool RendererImpl::initialize(int width, int height, bool useSubWindow, bool egl2egl) {
-    if (android::base::System::get()->envGet("ANDROID_EMUGL_VERBOSE") == "1") {
-        base_enable_verbose_logs();
+    if (android::base::getEnvironmentVariable("ANDROID_EMUGL_VERBOSE") == "1") {
+        // base_enable_verbose_logs();
     }
 
     if (mRenderWindow) {
@@ -325,7 +325,7 @@
 
 void RendererImpl::getScreenshot(unsigned int nChannels, unsigned int* width,
         unsigned int* height, std::vector<unsigned char>& pixels, int displayId,
-        int desiredWidth, int desiredHeight, SkinRotation desiredRotation) {
+        int desiredWidth, int desiredHeight, int desiredRotation) {
     auto fb = FrameBuffer::getFB();
     if (fb) fb->getScreenshot(nChannels, width, height, pixels, displayId,
                               desiredWidth, desiredHeight, desiredRotation);
@@ -572,13 +572,11 @@
     return &sVirtioGpuOps;
 }
 
-void RendererImpl::snapshotOperationCallback(
-        android::snapshot::Snapshotter::Operation op,
-        android::snapshot::Snapshotter::Stage stage) {
+void RendererImpl::snapshotOperationCallback(int op, int stage) {
     using namespace android::snapshot;
     switch (op) {
-        case Snapshotter::Operation::Load:
-            if (stage == Snapshotter::Stage::Start) {
+        case SNAPSHOTTER_OPERATION_LOAD:
+            if (stage == SNAPSHOTTER_STAGE_START) {
 #ifdef SNAPSHOT_PROFILE
              android::base::System::Duration startTime =
                      android::base::System::get()->getUnixTimeUs();
@@ -593,7 +591,7 @@
                                1000);
 #endif
             }
-            if (stage == Snapshotter::Stage::End) {
+            if (stage == SNAPSHOTTER_STAGE_END) {
                 mRenderWindow->setPaused(false);
             }
             break;
diff --git a/stream-servers/RingStream.cpp b/stream-servers/RingStream.cpp
index 8559a26..df388d6 100644
--- a/stream-servers/RingStream.cpp
+++ b/stream-servers/RingStream.cpp
@@ -13,24 +13,22 @@
 // limitations under the License.
 #include "RingStream.h"
 
-#include "android/base/system/System.h"
+#include "base/System.h"
 
 #define EMUGL_DEBUG_LEVEL  0
 
-#include "emugl/common/crash_reporter.h"
-#include "emugl/common/debug.h"
-#include "emugl/common/dma_device.h"
+#include "host-common/crash_reporter.h"
+#include "host-common/debug.h"
+#include "host-common/dma_device.h"
 
 #include <assert.h>
 #include <memory.h>
 
-using android::base::System;
-
 namespace emugl {
 
 static bool getBenchmarkEnabledFromEnv() {
     auto threadEnabled =
-        System::getEnvironmentVariable("ANDROID_EMUGL_RENDERTHREAD_STATS");
+        android::base::getEnvironmentVariable("ANDROID_EMUGL_RENDERTHREAD_STATS");
     if (threadEnabled == "1") return true;
     return false;
 }
@@ -75,7 +73,7 @@
             } else {
                 ring_buffer_yield();
                 if (iters > kBackoffIters) {
-                    System::get()->sleepUs(10);
+                    android::base::sleepUs(10);
                     ++backedOffIters;
                 }
             }
@@ -158,13 +156,13 @@
                     type2Read(ringAvailable, &count, &current, ptrEnd);
                     break;
                 case 3:
-                    emugl::emugl_crash_reporter(
-                        "Guest should never set to "
-                        "transfer mode 3 with ringAvailable != 0\n");
+                    // emugl::emugl_crash_reporter(
+                    //     "Guest should never set to "
+                    //     "transfer mode 3 with ringAvailable != 0\n");
                 default:
-                    emugl::emugl_crash_reporter(
-                        "Unknown transfer mode %u\n",
-                        transferMode);
+                    // emugl::emugl_crash_reporter(
+                    //     "Unknown transfer mode %u\n",
+                    //     transferMode);
                     break;
             }
         } else if (ringLargeXferAvailable) {
diff --git a/stream-servers/RingStream.h b/stream-servers/RingStream.h
index ece1f52..359ae13 100644
--- a/stream-servers/RingStream.h
+++ b/stream-servers/RingStream.h
@@ -13,11 +13,11 @@
 // limitations under the License.
 #pragma once
 
-#include "OpenglRender/IOStream.h"
-#include "OpenglRender/RenderChannel.h"
+#include "IOStream.h"
+#include "RenderChannel.h"
 
-#include "android/base/ring_buffer.h"
-#include "android/emulation/address_space_graphics_types.h"
+#include "base/ring_buffer.h"
+#include "host-common/address_space_graphics_types.h"
 
 #include <functional>
 #include <vector>
diff --git a/stream-servers/StalePtrRegistry.h b/stream-servers/StalePtrRegistry.h
index f0a2566..bb53331 100644
--- a/stream-servers/StalePtrRegistry.h
+++ b/stream-servers/StalePtrRegistry.h
@@ -15,11 +15,11 @@
 */
 #pragma once
 
-#include "android/base/containers/Lookup.h"
-#include "android/base/files/Stream.h"
-#include "android/base/files/StreamSerializing.h"
-#include "android/base/synchronization/Lock.h"
-#include "android/base/Compiler.h"
+#include "base/Lookup.h"
+#include "base/Stream.h"
+#include "base/StreamSerializing.h"
+#include "base/Lock.h"
+#include "base/Compiler.h"
 
 #include <algorithm>
 #include <cstdint>
diff --git a/stream-servers/SyncThread.cpp b/stream-servers/SyncThread.cpp
index 0ce1f8b..5becd66 100644
--- a/stream-servers/SyncThread.cpp
+++ b/stream-servers/SyncThread.cpp
@@ -16,12 +16,11 @@
 
 #include "SyncThread.h"
 
-#include "android/base/memory/LazyInstance.h"
-#include "android/base/system/System.h"
-#include "android/utils/debug.h"
-#include "emugl/common/crash_reporter.h"
-#include "emugl/common/OpenGLDispatchLoader.h"
-#include "emugl/common/sync_device.h"
+#include "base/System.h"
+#include "base/Thread.h"
+#include "OpenGLESDispatch/OpenGLDispatchLoader.h"
+#include "host-common/crash_reporter.h"
+#include "host-common/sync_device.h"
 
 #ifndef _MSC_VER
 #include <sys/time.h>
@@ -49,8 +48,6 @@
 
 #endif
 
-using android::base::LazyInstance;
-
 // The single global sync thread instance.
 class GlobalSyncThread {
 public:
@@ -62,13 +59,16 @@
     SyncThread mSyncThread;
 };
 
-static LazyInstance<GlobalSyncThread> sGlobalSyncThread = LAZY_INSTANCE_INIT;
+static GlobalSyncThread* sGlobalSyncThread() {
+    static GlobalSyncThread* t = new GlobalSyncThread;
+    return t;
+}
 
 static const uint32_t kTimelineInterval = 1;
 static const uint64_t kDefaultTimeoutNsecs = 5ULL * 1000ULL * 1000ULL * 1000ULL;
 
 SyncThread::SyncThread() :
-    emugl::Thread(android::base::ThreadFlags::MaskSignals, 512 * 1024) {
+    android::base::Thread(android::base::ThreadFlags::MaskSignals, 512 * 1024) {
     this->start();
     initSyncContext();
 }
@@ -325,5 +325,5 @@
 
 /* static */
 SyncThread* SyncThread::get() {
-    return sGlobalSyncThread->syncThreadPtr();
+    return sGlobalSyncThread()->syncThreadPtr();
 }
diff --git a/stream-servers/SyncThread.h b/stream-servers/SyncThread.h
index a27b547..e7df3bb 100644
--- a/stream-servers/SyncThread.h
+++ b/stream-servers/SyncThread.h
@@ -22,10 +22,9 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include "android/base/synchronization/Lock.h"
-#include "android/base/synchronization/MessageChannel.h"
-
-#include "emugl/common/thread.h"
+#include "base/Lock.h"
+#include "base/Thread.h"
+#include "base/MessageChannel.h"
 
 // SyncThread///////////////////////////////////////////////////////////////////
 // The purpose of SyncThread is to track sync device timelines and give out +
@@ -55,7 +54,7 @@
 };
 
 struct RenderThreadInfo;
-class SyncThread : public emugl::Thread {
+class SyncThread : public android::base::Thread {
 public:
     // - constructor: start up the sync thread for a given context.
     // The initialization of the sync thread is nonblocking.
diff --git a/stream-servers/TextureDraw.cpp b/stream-servers/TextureDraw.cpp
index 1dca789..5c5f3fd 100644
--- a/stream-servers/TextureDraw.cpp
+++ b/stream-servers/TextureDraw.cpp
@@ -16,7 +16,7 @@
 
 #include "DispatchTables.h"
 
-#include "emugl/common/crash_reporter.h"
+#include "host-common/crash_reporter.h"
 
 #include <string>
 #include <assert.h>
@@ -58,11 +58,11 @@
 
         // No point in continuing as it's going to be a black screen.
         // Send a crash report.
-        emugl::emugl_crash_reporter(
-            "FATAL: Could not compile shader for guest framebuffer blit. "
-            "There may be an issue with the GPU drivers on your machine. "
-            "Try using software rendering; launch the emulator "
-            "from the command line with -gpu swiftshader_indirect. ");
+        // emugl::emugl_crash_reporter(
+        //     "FATAL: Could not compile shader for guest framebuffer blit. "
+        //     "There may be an issue with the GPU drivers on your machine. "
+        //     "Try using software rendering; launch the emulator "
+        //     "from the command line with -gpu swiftshader_indirect. ");
     }
 
     return shader;
diff --git a/stream-servers/TextureDraw.h b/stream-servers/TextureDraw.h
index be220fa..cafbec6 100644
--- a/stream-servers/TextureDraw.h
+++ b/stream-servers/TextureDraw.h
@@ -21,6 +21,7 @@
 #include "Hwc2.h"
 #include "base/Lock.h"
 
+#include <vector>
 
 // Helper class used to draw a simple texture to the current framebuffer.
 // Usage is pretty simple:
diff --git a/stream-servers/TextureResize.cpp b/stream-servers/TextureResize.cpp
index c6a17df..6689b7e 100644
--- a/stream-servers/TextureResize.cpp
+++ b/stream-servers/TextureResize.cpp
@@ -18,9 +18,8 @@
 
 #include "DispatchTables.h"
 #include "FrameBuffer.h"
-#include "android/utils/debug.h"
 
-#include "emugl/common/misc.h"
+#include "host-common/misc.h"
 
 #include "GLES2/gl2ext.h"
 
@@ -31,7 +30,8 @@
 #include <utility>
 
 #define ERR(...)  fprintf(stderr, __VA_ARGS__)
-#define V(...)  VERBOSE_PRINT(gles,__VA_ARGS__)
+// #define V(...)  VERBOSE_PRINT(gles,__VA_ARGS__)
+#define V(...)
 #define MAX_FACTOR_POWER 4
 
 static const char kCommonShaderSource[] =
@@ -336,7 +336,7 @@
     return mFBHeight.texture;
 }
 
-GLuint TextureResize::update(GLuint texture, int width, int height, SkinRotation rotation) {
+GLuint TextureResize::update(GLuint texture, int width, int height, int rotation) {
     if (mGenericResizer.get() == nullptr) {
         mGenericResizer.reset(new TextureResize::GenericResizer());
     }
@@ -532,7 +532,7 @@
 }
 
 GLuint TextureResize::GenericResizer::draw(GLuint texture, int width, int height,
-                                           SkinRotation rotation) {
+                                           int rotation) {
     if (mWidth != width || mHeight != height) {
         // update the framebuffer to match the new resolution
         mWidth = width;
diff --git a/stream-servers/TextureResize.h b/stream-servers/TextureResize.h
index 731bd23..74f34ac 100644
--- a/stream-servers/TextureResize.h
+++ b/stream-servers/TextureResize.h
@@ -16,7 +16,6 @@
 #ifndef _LIBRENDER_TEXTURERESIZE_H
 #define _LIBRENDER_TEXTURERESIZE_H
 
-#include "android/skin/rect.h"
 #include <GLES2/gl2.h>
 #include <memory>
 
@@ -28,7 +27,7 @@
     // Scales the given texture for the current viewport and returns the scaled
     // texture. May return the input if no scaling is required.
     GLuint update(GLuint texture);
-    GLuint update(GLuint texture, int width, int height, SkinRotation rotation);
+    GLuint update(GLuint texture, int width, int height, int skinRotation);
 
     struct Framebuffer {
         GLuint texture;
@@ -45,7 +44,7 @@
 
         // Renders the contents of 2D |input_texture| on screen
         // |width| and |height| are the dimensions of the texture.
-        GLuint draw(GLuint texture, int width, int height, SkinRotation rotation);
+        GLuint draw(GLuint texture, int width, int height, int skinRotation);
 
     private:
         GLuint mProgram;
diff --git a/stream-servers/YUVConverter.cpp b/stream-servers/YUVConverter.cpp
index 84c2333..1f27b05 100644
--- a/stream-servers/YUVConverter.cpp
+++ b/stream-servers/YUVConverter.cpp
@@ -17,7 +17,7 @@
 #include "YUVConverter.h"
 
 #include "DispatchTables.h"
-#include "emugl/common/feature_control.h"
+#include "host-common/feature_control.h"
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
@@ -70,8 +70,8 @@
         *alignwidthc = cStride;
         break;
     case FRAMEWORK_FORMAT_YUV_420_888:
-        if (emugl::emugl_feature_is_enabled(
-            android::featurecontrol::YUV420888toNV21)) {
+        if (feature_is_enabled(
+                kFeature_YUV420888toNV21)) {
             align = 1;
             yStride = (width + (align - 1)) & ~(align - 1);
             cStride = yStride;
@@ -553,8 +553,8 @@
                               &mPosLoc);
             break;
         case FRAMEWORK_FORMAT_YUV_420_888:
-            if (emugl::emugl_feature_is_enabled(
-                    android::featurecontrol::YUV420888toNV21)) {
+            if (feature_is_enabled(
+                    kFeature_YUV420888toNV21)) {
                 if (!mVUtex)
                     createYUVGLTex(GL_TEXTURE1, cwidth, cheight, &mVUtex, true);
                 createYUVInterleavedGLShader(&mProgram,
@@ -650,8 +650,8 @@
                   &cwidth);
 
     if (mFormat == FRAMEWORK_FORMAT_YUV_420_888) {
-        if (emugl::emugl_feature_is_enabled(
-                    android::featurecontrol::YUV420888toNV21)) {
+        if (feature_is_enabled(
+                kFeature_YUV420888toNV21)) {
             readYUVTex(mVUtex, pixels + voff, true);
             DDD("done");
         } else {
@@ -765,8 +765,8 @@
                                 false);
             break;
         case FRAMEWORK_FORMAT_YUV_420_888:
-            if (emugl::emugl_feature_is_enabled(
-                android::featurecontrol::YUV420888toNV21)) {
+            if (feature_is_enabled(
+                    kFeature_YUV420888toNV21)) {
                 subUpdateYUVGLTex(GL_TEXTURE1, mVUtex,
                                   x, y, cwidth, cheight,
                                   pixels + voff, true);
diff --git a/stream-servers/render_api.cpp b/stream-servers/render_api.cpp
index b437a0e..7859013 100644
--- a/stream-servers/render_api.cpp
+++ b/stream-servers/render_api.cpp
@@ -13,13 +13,14 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include "OpenglRender/render_api.h"
+#include "render_api.h"
 
-#include "emugl/common/OpenGLDispatchLoader.h"
 #include "ErrorLog.h"
-#include "OpenGLESDispatch/DispatchTables.h"
 #include "RenderLibImpl.h"
 
+#include "OpenGLESDispatch/OpenGLDispatchLoader.h"
+#include "OpenGLESDispatch/DispatchTables.h"
+
 #include <memory>
 
 RENDER_APICALL emugl::RenderLibPtr RENDER_APIENTRY initLibrary() {