Fix Launcher Service 51/226551/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 3 Mar 2020 22:58:38 +0000 (07:58 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 3 Mar 2020 23:18:45 +0000 (08:18 +0900)
- Uses RawImage ptr instead of shared_ptr<RawImage> ptr
- Sets previous raw image handle after calling prepare_cb function

Change-Id: I9fe2338354cd258e6e54a56b1c1d857edd6dd509
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
screen_connector_launcher_service/stub.cc

index 437bf24..c95d496 100644 (file)
@@ -69,10 +69,11 @@ class LauncherServiceStub
 
   void OnPrepareEvent(std::shared_ptr<screen_connector::RawImage> image,
                       uint32_t serial) override {
-    raw_image_ = std::move(image);
     if (ops_.prepare) {
-      ops_.prepare(reinterpret_cast<void*>(&raw_image_), serial, user_data_);
+      ops_.prepare(reinterpret_cast<void*>(image.get()), serial,
+          user_data_);
     }
+    raw_image_ = std::move(image);
   }
 
   void OnStopEvent(uint32_t serial) override {
@@ -229,14 +230,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_direction(
     return -EINVAL;
   }
 
-  auto img_ptr =
-      reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *direction = __convert_direction(img->GetDirection());
 
   return 0;
@@ -250,14 +244,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_type(
     return -EINVAL;
   }
 
-  auto img_ptr =
-      reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *image_type = __convert_image_type(img->GetImageType());
 
   return 0;
@@ -271,14 +258,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_position_x(
     return -EINVAL;
   }
 
-  auto img_ptr =
-      reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *x = img->GetPositionX();
 
   return 0;
@@ -292,14 +272,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_position_y(
     return -EINVAL;
   }
 
-  auto img_ptr =
-    reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *y = img->GetPositionY();
 
   return 0;
@@ -314,14 +287,7 @@ screen_connector_launcher_service_image_get_shared_widget_info(
     return -EINVAL;
   }
 
-  auto img_ptr =
-    reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *shared_widget_info = strdup(img->GetSharedWidgetInfo().c_str());
   if (*shared_widget_info == nullptr) {
     _E("Out of memory");
@@ -340,14 +306,7 @@ screen_connector_launcher_service_image_get_tbm_surface(
     return -EINVAL;
   }
 
-  auto img_ptr =
-      reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *tbm_surface = img->GetWlBuffer()->GetTbmSurface();
 
   return 0;
@@ -362,14 +321,7 @@ screen_connector_launcher_service_image_get_tbm_surface_info(
     return -EINVAL;
   }
 
-  auto img_ptr =
-    reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *tbm_surface_info = img->GetWlBuffer()->GetTbmSurfaceInfo();
 
   return 0;
@@ -383,14 +335,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_image_file(
     return -EINVAL;
   }
 
-  auto img_ptr =
-    reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *fd = img->GetImageFile()->GetRaw();
   *size = img->GetImageFile()->GetSize();
 
@@ -405,14 +350,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_file_path(
     return -EINVAL;
   }
 
-  auto img_ptr =
-    reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *file_path = strdup(img->GetFilePath().c_str());
   if (*file_path == nullptr) {
     _E("Out of memory");
@@ -430,14 +368,7 @@ extern "C" EXPORT int screen_connector_launcher_service_image_get_file_group(
     return -EINVAL;
   }
 
-  auto img_ptr =
-    reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle);
-  auto img = img_ptr->get();
-  if (img == nullptr) {
-    _E("Invalid parameter");
-    return -EINVAL;
-  }
-
+  auto img = reinterpret_cast<screen_connector::RawImage*>(handle);
   *file_group = strdup(img->GetFileGroup().c_str());
   if (*file_group == nullptr) {
     _E("Out of memory");