ADD_SUBDIRECTORY(frame-provider)
ADD_SUBDIRECTORY(ambient-viewer)
ADD_SUBDIRECTORY(tool)
-ADD_SUBDIRECTORY(unittest)
+#ADD_SUBDIRECTORY(unittest)
-ADD_DEPENDENCIES(widget-viewer_unittests widget_viewer_evas)
+#ADD_DEPENDENCIES(widget-viewer_unittests widget_viewer_evas)
ADD_DEPENDENCIES(widget_viewer_sdk widget_viewer_evas)
ADD_DEPENDENCIES(widget_viewer_sdk watch-holder)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer.h DESTINATION include/${PROJECT_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer_surface.h DESTINATION include/${PROJECT_NAME})
+#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION include/${PROJECT_NAME}
+# FILES_MATCHING PATTERN "*.h")
+#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src DESTINATION include/${PROJECT_NAME}
+# FILES_MATCHING PATTERN "*.h")
Name: ui_app_ambient_viewer
Description: Support development of the ambient viewer
Version: @VERSION@
-Libs: -L${libdir} -lambient_viewer
+Libs: -L${libdir} -lambient-viewer
Cflags: -I${includedir}
cppflags: -I${includedir}
typedef void *ambient_viewer_h;
typedef enum {
+ AMBIENT_VIEWER_EVENT_AOD_PREPARE,
AMBIENT_VIEWER_EVENT_AOD_READY,
AMBIENT_VIEWER_EVENT_WATCH_CHANGED,
} ambient_event_type_e;
typedef enum {
- AMBIENT_VIEWER_DIRECTION_WATCH,
- AMBIENT_VIEWER_DIRECTION_TOP_APP,
- AMBIENT_VIEWER_DIRECTION_BOTH,
+ AMBIENT_VIEWER_DIRECTION_VIEWER_AND_WATCH,
+ AMBIENT_VIEWER_DIRECTION_VIEWER_TOP_APP,
+ AMBIENT_VIEWER_DIRECTION_ALL,
} ambient_viewer_direction_e;
typedef void (*ambient_viewer_lifecycle_added_cb)(
typedef struct _ambient_viewer_lifecycle{
ambient_viewer_lifecycle_added_cb added;
- ambient_viewer_lifecycle_removed_cb deleted;
+ ambient_viewer_lifecycle_removed_cb removed;
ambient_viewer_lifecycle_updated_cb updated;
} ambient_viewer_lifecycle_s;
extern "C" {
#endif
+/**
+ * @brief Enumeration for ambient_viewer error.
+ * @since_tizen 5.5
+ */
+
+typedef enum _ambient_viewer_error {
+ AMBIENT_VIEWER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
+ AMBIENT_VIEWER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ AMBIENT_VIEWER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**<I/O error */
+ AMBIENT_VIEWER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ AMBIENT_VIEWER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+} ambient_viewer_error_e;
+
#ifdef __cplusplus
}
#endif
* @{
*/
-typedef void *ambient_viewer_surface_h;
+typedef const void *ambient_viewer_surface_h;
int ambient_viewer_surface_get_cur_image(ambient_viewer_surface_h handle,
- Evas_Object *image);
+ Evas_Object **image);
int ambient_viewer_surface_is_watch(ambient_viewer_surface_h handle,
bool *is_watch);
#include <bundle.h>
#include "ambient-viewer.h"
+#include "top-app-surface.h"
+#include "watch-surface.h"
namespace ambient_viewer {
-AmbientViewer::AmbientViewer() {
+AmbientViewer::AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win)
+ : win_(win) {
}
AmbientViewer::~AmbientViewer() = default;
void AmbientViewer::Monitor() {
+ //top_app_surface_listener_ = new IAmbientViewer;
+ //watch_surface_listener_ = new Event;
+
+ //top_app_surface_ = std::make_shared<TopAppSurface>(win_, top_app_surface_listener_);
+ //To do
+ //WatchSurface got error, need to check
+ //watch_surface_ = std::make_shared<WatchSurface>(win_, watch_surface_listener_);
}
void AmbientViewer::Unmonitor() {
+ top_app_surface_.reset();
+ //watch_surface_.reset();
}
void AmbientViewer::OnReceived(AmbientViewer::EventType ev, std::string sender,
int AmbientViewer::NotifyAmbientEvent(bool enter, AmbientViewer::Direction dir,
bundle* extra) {
- /*
- bundle* b = bundle_create();
- bundle_raw* raw;
- int len;
-
- //watch
-
- //top app
-
- //both
-
- bundle_add_byte(b, "enter", enter);
- bundle_encode(extra, &raw, &len);
- bundle_add_str(b, "extra", raw);
- aul_app_com_send("endpoint", b);
- */
-
return 0;
}
+
const ISurface& AmbientViewer::GetWatchSurface() const {
return *watch_surface_;
}
const ISurface& AmbientViewer::GetTopAppSurface() const {
- return *app_surface_;
+ return *top_app_surface_;
}
+
} // namespace ambient_viewer
#include <string>
#include <memory>
+#include "iambient-viewer.h"
#include "isurface.h"
#ifndef EXPORT_API
namespace ambient_viewer {
-class EXPORT_API AmbientViewer {
+class EXPORT_API AmbientViewer : public IAmbientViewer {
public:
enum EventType {
EVENT_AOD_PREPARE,
};
public:
- class IEvent {
- public:
- virtual void OnAdded(const ISurface& surface) = 0;
- virtual void OnUpdated(const ISurface& surface) = 0;
- virtual void OnRemoved(const ISurface& surface) = 0;
- };
-
- AmbientViewer();
+ AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win);
virtual ~AmbientViewer();
void Monitor();
void Unmonitor();
const ISurface& GetTopAppSurface() const;
private:
+ std::shared_ptr<screen_connector::EvasObject> win_;
std::shared_ptr<ISurface> watch_surface_;
- std::shared_ptr<ISurface> app_surface_;
+ std::shared_ptr<ISurface> top_app_surface_;
};
} // namespace ambient_viewer
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
+#define __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#include <string>
+
+#include "isurface.h"
+
+namespace ambient_viewer {
+
+class EXPORT_API IAmbientViewer {
+ public:
+ virtual ~IAmbientViewer() = default;
+ virtual void OnAdded(const ISurface& surface) = 0;
+ virtual void OnUpdated(const ISurface& surface) = 0;
+ virtual void OnRemoved(const ISurface& surface) = 0;
+};
+
+} //namespace ambient_viewer
+
+#endif // __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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 <system_info.h>
+
+#include "internal.h"
+
+#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
+
+namespace ambient_viewer::internal {
+
+float _GetOpr(void* source_data, int width, int height) {
+ int *source;
+ int x;
+ int y;
+ int idx;
+ int max_rad;
+ int rad;
+ int pos;
+ unsigned int r = 0;
+ unsigned int g = 0;
+ unsigned int b = 0;
+ unsigned int pixel_sum;
+ float opr;
+ float max_opr;
+ bool shape_circle = false;
+
+ system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle);;
+
+ source = static_cast<int*>(source_data);
+ pos = width / 2;
+ max_rad = (height * height) >> 2;
+
+ for (y = 0; y < height; ++y) {
+ for (x = 0; x < width; ++x) {
+ if (shape_circle) {
+ rad = (pos - x) * (pos - x) + (pos - y) * (pos - y);
+ if (rad <= max_rad) {
+ idx = y * width + x;
+ r += ((source[idx] & 0x00ff0000) >> 16);
+ g += ((source[idx] & 0x0000ff00) >> 8);
+ b += (source[idx] & 0x000000ff);
+ }
+ } else {
+ idx = y * width + x;
+ r += ((source[idx] & 0x00ff0000) >> 16);
+ g += ((source[idx] & 0x0000ff00) >> 8);
+ b += (source[idx] & 0x000000ff);
+ }
+ }
+ }
+
+ if (shape_circle)
+ max_opr = (width / 2) * (height / 2) * 3.14 * 3 * 255;
+ else
+ max_opr = width * height * 3 * 255;
+
+ pixel_sum = r + g + b;
+ opr = ((float)pixel_sum) / max_opr;
+
+ return opr;
+}
+
+} // namespace ambient_viewer::internal
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __AMBIENT_VIEWER_INTERNAL_H__
+#define __AMBIENT_VIEWER_INTERNAL_H__
+
+namespace ambient_viewer::internal {
+
+ float _GetOpr(void* source_data, int width, int height);
+
+} // namespace ambient_viewer::internal
+
+#endif // __AMBIENT_VIEWER_INTERNAL_H__
+
+
+
};
} //namespace ambient_viewer
+
#endif // __AMBIENT_VIEWER_ISURFACE_H__
* limitations under the License.
*/
+#include <dlog.h>
+#include <remote_surface_watcher.h>
#include "ambient_viewer.h"
#include "ambient_viewer_surface.h"
#include "ambient_viewer_common.h"
#include "ambient-viewer.h"
+#include "isurface.h"
-namespace ambient_viewer {
+using namespace std;
+using namespace ambient_viewer;
+using namespace screen_connector;
-class AmbientViewerStub : public AmbientViewer {
+class MonitorCallbackInfo {
public:
- AmbientViewerStub()
- : AmbientViewer() {
+ MonitorCallbackInfo(ambient_viewer_lifecycle_s cb, void* user_data)
+ : user_data_(user_data) {
+ cb_.added = cb.added;
+ cb_.updated = cb.updated;
+ cb_.removed = cb.removed;
+ }
+
+ void InvokeAdded(const ISurface& surface) {
+ if (cb_.added)
+ cb_.added(static_cast<ambient_viewer_surface_h>(&surface), user_data_);
}
+
+ void InvokeUpdated(const ISurface& surface) {
+ if (cb_.updated)
+ cb_.updated(static_cast<ambient_viewer_surface_h>(&surface), user_data_);
+ }
+
+ void InvokeRemoved(const ISurface& surface) {
+ if (cb_.removed)
+ cb_.removed(static_cast<ambient_viewer_surface_h>(&surface), user_data_);
+ }
+
+ private:
+ ambient_viewer_lifecycle_s cb_;
+ void* user_data_;
};
-} // namespace ambient_viewer
+class EventCallbackInfo {
+ public:
+ EventCallbackInfo(ambient_viewer_event_cb cb, void* user_data)
+ : cb_(cb), user_data_(user_data) {
+ }
+
+ void InvokeEventCallback(AmbientViewer::EventType event, std::string sender,
+ bundle *extra) {
+ cb_(static_cast<ambient_event_type_e>(event), sender.c_str(), extra,
+ user_data_);
+ }
+
+ private:
+ ambient_viewer_event_cb cb_;
+ void* user_data_;
+};
+
+class AmbientViewerStub : public AmbientViewer {
+ public:
+ AmbientViewerStub(std::shared_ptr<EvasObject> win)
+ : AmbientViewer(win) {
+ }
+
+ void OnAdded(const ISurface& surface) {
+ monitor_cb_->InvokeAdded(surface);
+ }
+
+ void OnUpdated(const ISurface& surface) {
+ monitor_cb_->InvokeUpdated(surface);
+ }
+
+ void OnRemoved(const ISurface& surface) {
+ monitor_cb_->InvokeRemoved(surface);
+ }
+
+ void OnEvent(EventType ev, string sender, bundle* extra) {
+ event_cb_->InvokeEventCallback(ev, sender, extra);
+ }
+
+ int SetMonitorCallbackInfo(unique_ptr<MonitorCallbackInfo> info) {
+ monitor_cb_ = move(info);
+ return AMBIENT_VIEWER_ERROR_NONE;
+ }
+
+ int ClearMonitorCallbackInfo() {
+ monitor_cb_.reset();
+ return AMBIENT_VIEWER_ERROR_NONE;
+ }
+
+ int SetEventCallbackInfo (unique_ptr<EventCallbackInfo> info) {
+ event_cb_ = move(info);
+ return AMBIENT_VIEWER_ERROR_NONE;
+ }
+
+ int ClearEventCallbackInfo() {
+ event_cb_.reset();
+ return AMBIENT_VIEWER_ERROR_NONE;
+ }
+
+ private:
+ unique_ptr<MonitorCallbackInfo> monitor_cb_;
+ unique_ptr<EventCallbackInfo> event_cb_;
+};
extern "C" EXPORT_API int ambient_viewer_create(Evas_Object *win,
ambient_viewer_h *handle)
{
- ambient_viewer_h ambient_viewer = NULL;
+ if (win == nullptr || handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
- *handle = ambient_viewer;
+ AmbientViewerStub* h = new (std::nothrow) AmbientViewerStub(
+ shared_ptr<EvasObject>(new EvasObject(win, false)));
+ if (h == nullptr) {
+ LOGE("out of memory");
+ return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
+ }
+
+ *handle = static_cast<ambient_viewer_h>(h);
- return 0;
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_destroy(ambient_viewer_h handle)
{
- free (handle);
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
- return 0;
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+ delete stub;
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_notify_ambient_event(
ambient_viewer_h handle, bool enter,
ambient_viewer_direction_e dir, bundle *extra)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+ stub->NotifyAmbientEvent(enter, static_cast<AmbientViewer::Direction>(dir), extra);
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_monitor(ambient_viewer_h handle,
ambient_viewer_lifecycle_s lifecycle, void *user_data)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+
+ unique_ptr<MonitorCallbackInfo> info (
+ new (nothrow)MonitorCallbackInfo(lifecycle, user_data));
+ if (info.get() == nullptr) {
+ LOGE("out of memory");
+ return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
+ }
+
+ stub->SetMonitorCallbackInfo(move(info));
+ stub->Monitor();
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_unmonitor(ambient_viewer_h handle)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+ stub->ClearMonitorCallbackInfo();
+ stub->Unmonitor();
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_set_event_listener(
ambient_viewer_h handle,
ambient_viewer_event_cb callback, void *user_data)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+
+ unique_ptr<EventCallbackInfo> info (
+ new (nothrow)EventCallbackInfo(callback, user_data));
+ if (info.get() == nullptr) {
+ LOGE("out of memory");
+ return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
+ }
+
+ stub->SetEventCallbackInfo(move(info));
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_unset_event_listener(
ambient_viewer_h handle)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+ stub->ClearEventCallbackInfo();
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_get_watch_surface(
ambient_viewer_h handle,
ambient_viewer_surface_h *surface)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+ *surface = static_cast<ambient_viewer_surface_h>(&(stub->GetWatchSurface()));
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_get_top_app_surface(
ambient_viewer_h handle,
ambient_viewer_surface_h *surface)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+ *surface = static_cast<ambient_viewer_surface_h>(&(stub->GetTopAppSurface()));
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_surface_get_cur_image(
- ambient_viewer_surface_h handle, Evas_Object *image)
+ ambient_viewer_surface_h handle, Evas_Object **image)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ const ISurface* surface = static_cast<const ISurface*>(handle);
+ *image = surface->GetCurrentImage().GetRaw();
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_surface_is_watch(
ambient_viewer_surface_h handle, bool *is_watch)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ const ISurface* surface = static_cast<const ISurface*>(handle);
+ *is_watch = surface->IsWatch();
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_surface_get_app_id(
ambient_viewer_surface_h handle, char **app_id)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ const ISurface* surface = static_cast<const ISurface*>(handle);
+ if (surface->GetAppId().empty())
+ *app_id = nullptr;
+ else
+ *app_id = strdup(surface->GetAppId().c_str());
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_surface_get_inst_id(
ambient_viewer_surface_h handle, char **inst_id)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ const ISurface* surface = static_cast<const ISurface*>(handle);
+ if (surface->GetInstId().empty())
+ *inst_id = nullptr;
+ else
+ *inst_id = strdup(surface->GetInstId().c_str());
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
extern "C" EXPORT_API int ambient_viewer_surface_get_opr(
ambient_viewer_surface_h handle, float *opr)
{
- return 0;
+ if (handle == nullptr) {
+ LOGE("Invalid parameter");
+ return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+ }
+
+ const ISurface* surface = static_cast<const ISurface*>(handle);
+ *opr = surface->GetOpr();
+
+ return AMBIENT_VIEWER_ERROR_NONE;
}
* limitations under the License.
*/
-#include <system_info.h>
#include "top-app-surface.h"
+#include "internal.h"
-#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
+using namespace ambient_viewer::internal;
namespace ambient_viewer {
TopAppSurface::TopAppSurface(
std::shared_ptr<screen_connector::EvasObject> surface,
- AmbientViewer::IEvent* listener)
+ IAmbientViewer* listener)
: RemoteSurfaceWatcher(screen_connector::RemoteSurface::Type::UI, surface),
listener_(listener) {
}
return inst_id_;
}
-static float _GetOpr(void* source_data, int width, int height) {
- int *source;
- int x;
- int y;
- int idx;
- int max_rad;
- int rad;
- int pos;
- unsigned int r = 0;
- unsigned int g = 0;
- unsigned int b = 0;
- unsigned int pixel_sum;
- float opr;
- float max_opr;
- bool shape_circle = false;
-
- system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle);;
-
- source = static_cast<int*>(source_data);
- pos = width / 2;
- max_rad = (height * height) >> 2;
-
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- if (shape_circle) {
- rad = (pos - x) * (pos - x) + (pos - y) * (pos - y);
- if (rad <= max_rad) {
- idx = y * width + x;
- r += ((source[idx] & 0x00ff0000) >> 16);
- g += ((source[idx] & 0x0000ff00) >> 8);
- b += (source[idx] & 0x000000ff);
- }
- } else {
- idx = y * width + x;
- r += ((source[idx] & 0x00ff0000) >> 16);
- g += ((source[idx] & 0x0000ff00) >> 8);
- b += (source[idx] & 0x000000ff);
- }
- }
- }
-
- if (shape_circle)
- max_opr = (width / 2) * (height / 2) * 3.14 * 3 * 255;
- else
- max_opr = width * height * 3 * 255;
-
- pixel_sum = r + g + b;
- opr = ((float)pixel_sum) / max_opr;
-
- return opr;
-}
-
float TopAppSurface::GetOpr() const {
float opr = 0.0f;
int width;
app_id_ = appId;
inst_id_ = instId;
- listener_->OnAdded(*surface_);
+ listener_->OnAdded(*this);
}
void TopAppSurface::OnWatcherChanged(const std::string& appId,
const std::string& instId, const int pid,
const screen_connector::EvasObject& image) {
- //image_ = image;
- listener_->OnUpdated(*surface_);
+ *image_ = image;
+ listener_->OnUpdated(*this);
}
void TopAppSurface::OnWatcherRemoved(const std::string& appId,
const std::string& instId, const int pid) {
- listener_->OnRemoved(*surface_);
+ listener_->OnRemoved(*this);
image_ = nullptr;
}
#include <string>
#include <memory>
+#include "iambient-viewer.h"
#include "isurface.h"
#include "ambient-viewer.h"
-#define WATCH_SMART_SIGNAL_ADDED "watch,added"
-#define WATCH_SMART_SIGNAL_REMOVED "watch,removed"
-#define WATCH_SMART_SIGNAL_UPDATED "watch,updated"
-
namespace ambient_viewer {
class TopAppSurface : public screen_connector::RemoteSurfaceWatcher, public ISurface {
std::string GetInstId() const override;
float GetOpr() const override;
- TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface, AmbientViewer::IEvent* listener);
+ TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface, IAmbientViewer* listener);
virtual ~TopAppSurface();
private:
std::string app_id_;
std::string inst_id_;
- std::shared_ptr<ISurface> surface_;
- AmbientViewer::IEvent* listener_;
+ IAmbientViewer* listener_;
};
} // namespace ambient_viewer
+
#endif // __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
* limitations under the License.
*/
-#include <system_info.h>
-
#include "watch-surface.h"
+#include "internal.h"
-#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
+using namespace ambient_viewer::internal;
namespace ambient_viewer {
WatchSurface::WatchSurface(
std::shared_ptr<screen_connector::EvasObject> surface,
- AmbientViewer::IEvent* listener)
+ IAmbientViewer* listener)
: screen_connector::RemoteSurfaceEvas("",
screen_connector::RemoteSurface::Type::WATCH, surface),
listener_(listener) {
return inst_id_;
}
-static float _GetOpr(void* source_data, int width, int height) {
- int *source;
- int x;
- int y;
- int idx;
- int max_rad;
- int rad;
- int pos;
- unsigned int r = 0;
- unsigned int g = 0;
- unsigned int b = 0;
- unsigned int pixel_sum;
- float opr;
- float max_opr;
- bool shape_circle = false;
-
- system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle);;
-
- source = static_cast<int*>(source_data);
- pos = width / 2;
- max_rad = (height * height) >> 2;
-
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- if (shape_circle) {
- rad = (pos - x) * (pos - x) + (pos - y) * (pos - y);
- if (rad <= max_rad) {
- idx = y * width + x;
- r += ((source[idx] & 0x00ff0000) >> 16);
- g += ((source[idx] & 0x0000ff00) >> 8);
- b += (source[idx] & 0x000000ff);
- }
- } else {
- idx = y * width + x;
- r += ((source[idx] & 0x00ff0000) >> 16);
- g += ((source[idx] & 0x0000ff00) >> 8);
- b += (source[idx] & 0x000000ff);
- }
- }
- }
-
- if (shape_circle)
- max_opr = (width / 2) * (height / 2) * 3.14 * 3 * 255;
- else
- max_opr = width * height * 3 * 255;
-
- pixel_sum = r + g + b;
- opr = ((float)pixel_sum) / max_opr;
-
- return opr;
-}
-
float WatchSurface::GetOpr() const {
float opr = 0.0f;
int width;
const screen_connector::EvasObject& image) {
app_id_ = appId;
inst_id_ = instId;
- //image_ = image;
+ *image_ = image;
- listener_->OnAdded(*surface_);
+ listener_->OnAdded(*this);
}
void WatchSurface::OnEvasRemoved(const std::string& appId,
const std::string& instId, int pid,
const screen_connector::EvasObject& image) {
- listener_->OnRemoved(*surface_);
image_ = nullptr;
+ listener_->OnRemoved(*this);
}
void WatchSurface::OnEvasChanged(const std::string& appId,
const std::string& instId, int pid,
const screen_connector::EvasObject& image) {
- listener_->OnUpdated(*surface_);
+ *image_ = image;
+ listener_->OnUpdated(*this);
}
} // namespace ambient_viewer
#include <string>
#include <memory>
+#include "iambient-viewer.h"
#include "isurface.h"
#include "ambient-viewer.h"
std::string GetInstId() const override;
float GetOpr() const override;
- WatchSurface(std::shared_ptr<screen_connector::EvasObject> surface, AmbientViewer::IEvent* listener);
+ WatchSurface(std::shared_ptr<screen_connector::EvasObject> surface, IAmbientViewer* listener);
virtual ~WatchSurface();
private:
std::string app_id_;
std::string inst_id_;
- std::shared_ptr<ISurface> surface_;
- AmbientViewer::IEvent* listener_;
+ IAmbientViewer* listener_;
};
} // namespace ambient_viewer
+
#endif // __AMBIENT_VIEWER_WATCH_SURFACE_H__
#################################################
# widget-viewer_unittests
#################################################
-%package -n widget-viewer_unittests
-Summary: GTest for widget-viewer
-Group: Development/Libraries
+# %package -n widget-viewer_unittests
+# Summary: GTest for widget-viewer
+# Group: Development/Libraries
-%description -n widget-viewer_unittests
-GTest for widget-viewer
+# %description -n widget-viewer_unittests
+# GTest for widget-viewer
-%files -n widget-viewer_unittests
-%{_bindir}/widget-viewer_unittests
+# %files -n widget-viewer_unittests
+# %{_bindir}/widget-viewer_unittests
#################################################
# widget-viewer-gcov
capi-appfw-application
cynara-client
screen_connector_watcher_evas
+ screen_connector_remote_surface_evas
appcore-efl
ecore
edje
SET(CMAKE_C_FLAGS_RELEASE "-O2")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../widget_viewer_evas/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../ambient-viewer/src)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../ambient-viewer/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../unittest/mock)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock UNIT_TEST_SOURCES)
AUX_SOURCE_DIRECTORY(src SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../widget_viewer_evas/src WIDGET_VIEWER_EVAS_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../ambient-viewer/src AMBIENT_VIEWER_SOURCES)
ADD_EXECUTABLE(${PROJECT_NAME}
${SOURCES}
${WIDGET_VIEWER_EVAS_SOURCES}
${UNIT_TEST_SOURCES}
+ ${AMBIENT_VIEWER_SOURCES}
)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${widget-viewer_unittests_LDFLAGS}
${pkgs_LIBRARIES}
gmock
widget_viewer_evas
+ ambient-viewer
)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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 <glib.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <ambient-viewer.h>
+
+using namespace std;
+using namespace ambient_viewer;
+using namespace screen_connector;
+
+
+class AmbientViewerTest : public ::testing::Test {
+ public:
+ AmbientViewer* stub;
+ virtual void SetUp() {
+ Evas_Object* win = elm_win_add(NULL, "Widget Viewer", ELM_WIN_BASIC);
+ stub = new AmbientViewer(shared_ptr<EvasObject>(new EvasObject(win, false)));
+ }
+ virtual void TearDown() {
+ delete stub;
+ }
+};
+
+TEST_F(AmbientViewerTest, create) {
+ EXPECT_NE(AmbientViewerTest::stub, nullptr);
+}
+
+TEST_F(AmbientViewerTest, Monitor) {
+ AmbientViewerTest::stub->Monitor();
+ AmbientViewerTest::stub->Unmonitor();
+
+ //EXPECT_EQ();
+}
+
+TEST_F(AmbientViewerTest, Get) {
+ AmbientViewerTest::stub->Monitor();
+
+ AmbientViewerTest::stub->GetTopAppSurface();
+
+ AmbientViewerTest::stub->Unmonitor();
+
+ //EXPECT_EQ();
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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 <glib.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <top-app-surface.h>
+
+class TopAppSurfaceTest : public ::testing::Test {
+ public:
+ TopAppSurface* surface;
+
+ virtual void SetUp() {
+ }
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(TopAppSurfaceTest, create) {
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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 <glib.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <watch-surface.h>
+
+
+class WatchSurfaceTest : public ::testing::Test {
+ public:
+ WatchSurface* surface;
+
+ virtual void SetUp() {
+ }
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(WatchSurfaceTest, create) {
+}
+