+++ /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.hh"
-
-#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__
-
-
-
#include <dlog.h>
#include "top-app-surface.hh"
-#include "internal.hh"
+#include "util.hh"
#ifdef LOG_TAG
#undef LOG_TAG
return 0;
}
- opr = ambient_viewer::internal::GetOpr(source_data, width, height);
+ opr = ambient_viewer::util::GetOpr(source_data, width, height);
tbm_surface_unmap(surface);
--- /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 "util.hh"
+
+#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
+
+namespace ambient_viewer::util {
+
+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::util
--- /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_UTIL_H__
+#define __AMBIENT_VIEWER_UTIL_H__
+
+namespace ambient_viewer::util {
+
+ float GetOpr(void* source_data, int width, int height);
+
+} // namespace ambient_viewer::util
+
+#endif // __AMBIENT_VIEWER_UTIL_H__
+
+
+
#include <dlog.h>
#include "watch-surface.hh"
-#include "internal.hh"
+#include "util.hh"
#ifdef LOG_TAG
#undef LOG_TAG
return 0;
}
- opr = ambient_viewer::internal::GetOpr(source_data, width, height);
+ opr = ambient_viewer::util::GetOpr(source_data, width, height);
tbm_surface_unmap(surface);
return opr;