1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_DRAW_CMD_H 17 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_DRAW_CMD_H 18 19 #if (defined(ROSEN_OHOS) && defined(RS_ENABLE_GL)) 20 #include <GLES/gl.h> 21 #include "EGL/egl.h" 22 #include "EGL/eglext.h" 23 #include "GLES2/gl2.h" 24 #include "GLES2/gl2ext.h" 25 #endif 26 27 #include "common/rs_common_def.h" 28 29 #include "recording/draw_cmd.h" 30 #include "recording/recording_canvas.h" 31 #include "render/rs_image.h" 32 33 #if defined(ROSEN_OHOS) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) 34 #include "surface_buffer.h" 35 #include "surface_type.h" 36 #include "sync_fence.h" 37 #include "external_window.h" 38 #endif 39 40 namespace OHOS { 41 namespace Rosen { 42 #ifdef ROSEN_OHOS 43 #ifdef RS_ENABLE_VK 44 namespace NativeBufferUtils { 45 class VulkanCleanupHelper; 46 } 47 #endif 48 struct DrawingSurfaceBufferInfo { 49 DrawingSurfaceBufferInfo() = default; 50 DrawingSurfaceBufferInfo(const sptr<SurfaceBuffer>& surfaceBuffer, int offSetX, int offSetY, int width, int height, 51 pid_t pid = {}, uint64_t uid = {}, sptr<SyncFence> acquireFence = nullptr, 52 GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_NONE, 53 Drawing::Rect srcRect = {}) surfaceBuffer_DrawingSurfaceBufferInfo54 : surfaceBuffer_(surfaceBuffer), srcRect_(srcRect), 55 dstRect_(Drawing::Rect { offSetX, offSetY, offSetX + width, offSetY + height }), pid_(pid), uid_(uid), 56 acquireFence_(acquireFence), transform_(transform) 57 {} 58 sptr<SurfaceBuffer> surfaceBuffer_ = nullptr; 59 Drawing::Rect srcRect_; 60 Drawing::Rect dstRect_; 61 pid_t pid_ = {}; 62 uint64_t uid_ = {}; 63 sptr<SyncFence> acquireFence_ = nullptr; 64 GraphicTransformType transform_ = GraphicTransformType::GRAPHIC_ROTATE_NONE; 65 }; 66 #endif 67 68 class RSB_EXPORT RSExtendImageObject : public Drawing::ExtendImageObject { 69 public: 70 RSExtendImageObject() = default; 71 RSExtendImageObject(const std::shared_ptr<Drawing::Image>& image, const std::shared_ptr<Drawing::Data>& data, 72 const Drawing::AdaptiveImageInfo& imageInfo); 73 RSExtendImageObject(const std::shared_ptr<Media::PixelMap>& pixelMap, const Drawing::AdaptiveImageInfo& imageInfo); 74 ~RSExtendImageObject() override; 75 void Playback(Drawing::Canvas& canvas, const Drawing::Rect& rect, 76 const Drawing::SamplingOptions& sampling, bool isBackground = false) override; 77 bool Marshalling(Parcel &parcel) const; 78 static RSExtendImageObject *Unmarshalling(Parcel &parcel); 79 #if defined(ROSEN_OHOS) && defined(RS_ENABLE_GL) 80 bool GetDrawingImageFromSurfaceBuffer(Drawing::Canvas& canvas, SurfaceBuffer* surfaceBuffer); 81 #endif 82 #if defined(ROSEN_OHOS) && defined(RS_ENABLE_VK) 83 bool MakeFromTextureForVK(Drawing::Canvas& canvas, SurfaceBuffer *surfaceBuffer, 84 const std::shared_ptr<Drawing::ColorSpace>& colorSpace = nullptr); 85 bool GetRsImageCache(Drawing::Canvas& canvas, const std::shared_ptr<Media::PixelMap>& pixelMap, 86 SurfaceBuffer *surfaceBuffer, const std::shared_ptr<Drawing::ColorSpace>& colorSpace = nullptr); 87 #endif 88 void SetNodeId(NodeId id) override; 89 NodeId GetNodeId() const override; 90 void SetPaint(Drawing::Paint paint) override; 91 void Purge() override; 92 bool IsValid() override; 93 void Dump(std::string& dump) override; 94 protected: 95 std::shared_ptr<RSImage> rsImage_ = nullptr; 96 private: 97 #if defined(ROSEN_OHOS) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) 98 void PreProcessPixelMap(Drawing::Canvas& canvas, const std::shared_ptr<Media::PixelMap>& pixelMap, 99 const Drawing::SamplingOptions& sampling); 100 #ifdef RS_ENABLE_GL 101 mutable EGLImageKHR eglImage_ = EGL_NO_IMAGE_KHR; 102 mutable GLuint texId_ = 0; 103 #endif 104 mutable OHNativeWindowBuffer* nativeWindowBuffer_ = nullptr; 105 mutable pid_t tid_ = 0; 106 #ifdef RS_ENABLE_VK 107 mutable Drawing::BackendTexture backendTexture_ = {}; 108 mutable NativeBufferUtils::VulkanCleanupHelper* cleanUpHelper_ = nullptr; 109 #endif 110 #endif 111 std::shared_ptr<Drawing::Image> image_; 112 Drawing::AdaptiveImageInfo imageInfo_; 113 NodeId nodeId_ = INVALID_NODEID; 114 }; 115 116 class RSB_EXPORT RSExtendImageBaseObj : public Drawing::ExtendImageBaseObj { 117 public: 118 RSExtendImageBaseObj() = default; 119 RSExtendImageBaseObj(const std::shared_ptr<Media::PixelMap>& pixelMap, const Drawing::Rect& src, 120 const Drawing::Rect& dst); 121 ~RSExtendImageBaseObj() override = default; 122 void Playback(Drawing::Canvas& canvas, const Drawing::Rect& rect, const Drawing::SamplingOptions& sampling, 123 Drawing::SrcRectConstraint constraint = Drawing::SrcRectConstraint::STRICT_SRC_RECT_CONSTRAINT) override; 124 bool Marshalling(Parcel &parcel) const; 125 static RSExtendImageBaseObj *Unmarshalling(Parcel &parcel); 126 void SetNodeId(NodeId id) override; 127 void Purge() override; 128 protected: 129 std::shared_ptr<RSImageBase> rsImage_ = nullptr; 130 }; 131 132 class RSB_EXPORT RSExtendImageNineObject : public Drawing::ExtendImageNineObject { 133 public: 134 RSExtendImageNineObject() = default; 135 RSExtendImageNineObject(const std::shared_ptr<Media::PixelMap>& pixelMap); 136 ~RSExtendImageNineObject() override = default; 137 void Playback(Drawing::Canvas& canvas, const Drawing::RectI& center, const Drawing::Rect& dst, 138 Drawing::FilterMode filterMode) override; 139 bool Marshalling(Parcel &parcel) const; 140 static RSExtendImageNineObject *Unmarshalling(Parcel &parcel); 141 void SetNodeId(NodeId id) override; 142 void Purge() override; 143 protected: 144 std::shared_ptr<RSImageBase> rsImage_ = nullptr; 145 }; 146 147 class RSB_EXPORT RSExtendImageLatticeObject : public Drawing::ExtendImageLatticeObject { 148 public: 149 RSExtendImageLatticeObject() = default; 150 RSExtendImageLatticeObject(const std::shared_ptr<Media::PixelMap>& pixelMap); 151 ~RSExtendImageLatticeObject() override = default; 152 void Playback(Drawing::Canvas& canvas, const Drawing::Lattice& lattice, const Drawing::Rect& dst, 153 Drawing::FilterMode filterMode) override; 154 bool Marshalling(Parcel &parcel) const; 155 static RSExtendImageLatticeObject *Unmarshalling(Parcel &parcel); 156 void SetNodeId(NodeId id) override; 157 void Purge() override; 158 protected: 159 std::shared_ptr<RSImageBase> rsImage_ = nullptr; 160 }; 161 162 class RSB_EXPORT RSExtendDrawFuncObj : public Drawing::ExtendDrawFuncObj { 163 public: RSExtendDrawFuncObj(Drawing::RecordingCanvas::DrawFunc && drawFunc)164 explicit RSExtendDrawFuncObj(Drawing::RecordingCanvas::DrawFunc&& drawFunc) : drawFunc_(std::move(drawFunc)) {} 165 ~RSExtendDrawFuncObj() override = default; 166 void Playback(Drawing::Canvas* canvas, const Drawing::Rect* rect) override; 167 bool Marshalling(Parcel& parcel) const; 168 static RSExtendDrawFuncObj* Unmarshalling(Parcel& parcel); 169 170 private: 171 Drawing::RecordingCanvas::DrawFunc drawFunc_; 172 }; 173 174 namespace Drawing { 175 class RSB_EXPORT DrawImageWithParmOpItem : public DrawWithPaintOpItem { 176 public: 177 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle178 ConstructorHandle(const OpDataHandle& objectHandle, const SamplingOptions& sampling, 179 const PaintHandle& paintHandle) 180 : OpItem(DrawOpItem::IMAGE_WITH_PARM_OPITEM), objectHandle(objectHandle), sampling(sampling), 181 paintHandle(paintHandle) {} 182 ~ConstructorHandle() override = default; 183 OpDataHandle objectHandle; 184 SamplingOptions sampling; 185 PaintHandle paintHandle; 186 }; 187 DrawImageWithParmOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 188 DrawImageWithParmOpItem(const std::shared_ptr<Image>& image, const std::shared_ptr<Data>& data, 189 const AdaptiveImageInfo& rsImageInfo, const SamplingOptions& sampling, const Paint& paint); 190 ~DrawImageWithParmOpItem() override = default; 191 192 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 193 void Marshalling(DrawCmdList& cmdList) override; 194 void Playback(Canvas* canvas, const Rect* rect) override; 195 void SetNodeId(NodeId id) override; 196 void Dump(std::string& out) const override; 197 private: 198 SamplingOptions sampling_; 199 std::shared_ptr<ExtendImageObject> objectHandle_; 200 }; 201 202 class RSB_EXPORT DrawPixelMapWithParmOpItem : public DrawWithPaintOpItem { 203 public: 204 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle205 ConstructorHandle(const OpDataHandle& objectHandle, const SamplingOptions& sampling, 206 const PaintHandle& paintHandle) 207 : OpItem(DrawOpItem::PIXELMAP_WITH_PARM_OPITEM), objectHandle(objectHandle), sampling(sampling), 208 paintHandle(paintHandle) {} 209 ~ConstructorHandle() override = default; 210 OpDataHandle objectHandle; 211 SamplingOptions sampling; 212 PaintHandle paintHandle; 213 }; 214 DrawPixelMapWithParmOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 215 DrawPixelMapWithParmOpItem(const std::shared_ptr<Media::PixelMap>& pixelMap, 216 const AdaptiveImageInfo& rsImageInfo, const SamplingOptions& sampling, const Paint& paint); 217 ~DrawPixelMapWithParmOpItem() override = default; 218 219 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 220 void Marshalling(DrawCmdList& cmdList) override; 221 void Playback(Canvas* canvas, const Rect* rect) override; 222 void SetNodeId(NodeId id) override; 223 virtual void DumpItems(std::string& out) const override; Purge()224 void Purge() override 225 { 226 if (objectHandle_) { 227 objectHandle_->Purge(); 228 } 229 } 230 private: 231 SamplingOptions sampling_; 232 std::shared_ptr<ExtendImageObject> objectHandle_; 233 }; 234 235 #ifdef RS_ENABLE_VK 236 class RSB_EXPORT DrawHybridPixelMapOpItem : public DrawWithPaintOpItem { 237 public: 238 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle239 ConstructorHandle(const OpDataHandle& objectHandle, const SamplingOptions& sampling, 240 const PaintHandle& paintHandle, uint32_t entryId, bool isRenderForeground) 241 : OpItem(DrawOpItem::HYBRID_RENDER_PIXELMAP_OPITEM), objectHandle(objectHandle), sampling(sampling), 242 paintHandle(paintHandle), entryId(entryId), isRenderForeground(isRenderForeground) {} 243 ~ConstructorHandle() override = default; 244 OpDataHandle objectHandle; 245 SamplingOptions sampling; 246 PaintHandle paintHandle; 247 uint32_t entryId; 248 bool isRenderForeground; 249 }; 250 DrawHybridPixelMapOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 251 DrawHybridPixelMapOpItem(const std::shared_ptr<Media::PixelMap>& pixelMap, 252 const AdaptiveImageInfo& rsImageInfo, const SamplingOptions& sampling, const Paint& paint); 253 ~DrawHybridPixelMapOpItem() override = default; 254 255 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 256 void Marshalling(DrawCmdList& cmdList) override; 257 void Playback(Canvas* canvas, const Rect* rect) override; 258 void SetNodeId(NodeId id) override; 259 virtual void DumpItems(std::string& out) const override; Purge()260 void Purge() override 261 { 262 if (objectHandle_) { 263 objectHandle_->Purge(); 264 } 265 } 266 private: 267 SamplingOptions sampling_; 268 std::shared_ptr<ExtendImageObject> objectHandle_; 269 bool isRenderForeground_ = false; 270 sptr<SyncFence> fence_ = nullptr; 271 }; 272 #endif 273 274 class RSB_EXPORT DrawPixelMapRectOpItem : public DrawWithPaintOpItem { 275 public: 276 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle277 ConstructorHandle(const OpDataHandle& objectHandle, const SamplingOptions& sampling, 278 SrcRectConstraint constraint, const PaintHandle& paintHandle) 279 : OpItem(DrawOpItem::PIXELMAP_RECT_OPITEM), objectHandle(objectHandle), sampling(sampling), 280 constraint(constraint), paintHandle(paintHandle) {} 281 ~ConstructorHandle() override = default; 282 OpDataHandle objectHandle; 283 SamplingOptions sampling; 284 SrcRectConstraint constraint; 285 PaintHandle paintHandle; 286 }; 287 DrawPixelMapRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 288 DrawPixelMapRectOpItem(const std::shared_ptr<Media::PixelMap>& pixelMap, const Rect& src, const Rect& dst, 289 const SamplingOptions& sampling, SrcRectConstraint constraint, const Paint& paint); 290 ~DrawPixelMapRectOpItem() override = default; 291 292 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 293 void Marshalling(DrawCmdList& cmdList) override; 294 void Playback(Canvas* canvas, const Rect* rect) override; 295 void SetNodeId(NodeId id) override; 296 virtual void DumpItems(std::string& out) const override; Purge()297 void Purge() override 298 { 299 if (objectHandle_) { 300 objectHandle_->Purge(); 301 } 302 } 303 private: 304 SamplingOptions sampling_; 305 SrcRectConstraint constraint_; 306 std::shared_ptr<ExtendImageBaseObj> objectHandle_; 307 }; 308 309 class RSB_EXPORT DrawFuncOpItem : public DrawOpItem { 310 public: 311 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle312 ConstructorHandle(uint32_t funcObjectId) 313 : OpItem(DrawOpItem::DRAW_FUNC_OPITEM), funcObjectId(funcObjectId) {} 314 ~ConstructorHandle() override = default; 315 uint32_t funcObjectId; 316 }; 317 DrawFuncOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 318 explicit DrawFuncOpItem(RecordingCanvas::DrawFunc&& drawFunc); 319 ~DrawFuncOpItem() override = default; 320 321 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 322 void Marshalling(DrawCmdList& cmdList) override; 323 void Playback(Canvas* canvas, const Rect* rect) override; 324 private: 325 std::shared_ptr<ExtendDrawFuncObj> objectHandle_; 326 }; 327 328 class DrawPixelMapNineOpItem : public DrawWithPaintOpItem { 329 public: 330 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle331 ConstructorHandle(const OpDataHandle& objectHandle, const Drawing::RectI& center, 332 const Drawing::Rect& dst, Drawing::FilterMode filterMode, const PaintHandle& paintHandle) 333 : OpItem(DrawOpItem::PIXELMAP_NINE_OPITEM), objectHandle(objectHandle), center(center), 334 dst(dst), filterMode(filterMode), paintHandle(paintHandle) {} 335 ~ConstructorHandle() override = default; 336 OpDataHandle objectHandle; 337 Drawing::RectI center; 338 Drawing::Rect dst; 339 FilterMode filterMode; 340 PaintHandle paintHandle; 341 }; 342 DrawPixelMapNineOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 343 DrawPixelMapNineOpItem(const std::shared_ptr<Media::PixelMap>& pixelMap, const Drawing::RectI& center, 344 const Drawing::Rect& dst, Drawing::FilterMode filterMode, const Paint& paint); 345 ~DrawPixelMapNineOpItem() override = default; 346 347 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 348 void Marshalling(DrawCmdList& cmdList) override; 349 void Playback(Canvas* canvas, const Rect* rect) override; 350 void SetNodeId(NodeId id) override; 351 virtual void DumpItems(std::string& out) const override; Purge()352 void Purge() override 353 { 354 if (objectHandle_) { 355 objectHandle_->Purge(); 356 } 357 } 358 private: 359 Drawing::RectI center_; 360 Drawing::Rect dst_; 361 FilterMode filterMode_; 362 std::shared_ptr<ExtendImageNineObject> objectHandle_; 363 }; 364 365 class DrawPixelMapLatticeOpItem : public DrawWithPaintOpItem { 366 public: 367 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle368 ConstructorHandle(const OpDataHandle& objectHandle, const LatticeHandle& latticeHandle, 369 const Drawing::Rect& dst, Drawing::FilterMode filterMode, const PaintHandle& paintHandle) 370 : OpItem(DrawOpItem::PIXELMAP_LATTICE_OPITEM), objectHandle(objectHandle), latticeHandle(latticeHandle), 371 dst(dst), filterMode(filterMode), paintHandle(paintHandle) {} 372 ~ConstructorHandle() override = default; 373 OpDataHandle objectHandle; 374 LatticeHandle latticeHandle; 375 Drawing::Rect dst; 376 FilterMode filterMode; 377 PaintHandle paintHandle; 378 }; 379 DrawPixelMapLatticeOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); 380 DrawPixelMapLatticeOpItem(const std::shared_ptr<Media::PixelMap>& pixelMap, const Drawing::Lattice& lattice, 381 const Drawing::Rect& dst, Drawing::FilterMode filterMode, const Paint& paint); 382 ~DrawPixelMapLatticeOpItem() override = default; 383 384 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 385 void Marshalling(DrawCmdList& cmdList) override; 386 void Playback(Canvas* canvas, const Rect* rect) override; 387 void SetNodeId(NodeId id) override; 388 virtual void DumpItems(std::string& out) const override; Purge()389 void Purge() override 390 { 391 if (objectHandle_) { 392 objectHandle_->Purge(); 393 } 394 } 395 private: 396 Drawing::Lattice lattice_; 397 Drawing::Rect dst_; 398 FilterMode filterMode_; 399 std::shared_ptr<ExtendImageLatticeObject> objectHandle_; 400 }; 401 402 #ifdef ROSEN_OHOS 403 struct RSB_EXPORT DrawSurfaceBufferFinishCbData { 404 uint64_t uid; 405 pid_t pid; 406 uint32_t surfaceBufferId; 407 NodeId rootNodeId = INVALID_NODEID; 408 sptr<SyncFence> releaseFence = SyncFence::INVALID_FENCE; 409 bool isRendered = false; 410 bool isNeedTriggerCbDirectly = false; 411 }; 412 413 struct RSB_EXPORT DrawSurfaceBufferAfterAcquireCbData { 414 uint64_t uid; 415 pid_t pid; 416 }; 417 418 struct RSB_EXPORT DrawSurfaceBufferOpItemCb { 419 std::function<void(const DrawSurfaceBufferFinishCbData&)> OnFinish; 420 std::function<void(const DrawSurfaceBufferAfterAcquireCbData&)> OnAfterAcquireBuffer; 421 }; 422 423 class RSB_EXPORT DrawSurfaceBufferOpItem : public DrawWithPaintOpItem { 424 public: 425 struct ConstructorHandle : public OpItem { ConstructorHandleConstructorHandle426 ConstructorHandle(uint32_t surfaceBufferId, int offSetX, int offSetY, int width, int height, pid_t pid, 427 uint64_t uid, GraphicTransformType transform, Drawing::Rect srcRect, const PaintHandle& paintHandle) 428 : OpItem(DrawOpItem::SURFACEBUFFER_OPITEM), surfaceBufferId(surfaceBufferId), 429 surfaceBufferInfo(nullptr, offSetX, offSetY, width, height, pid, uid, nullptr, transform, srcRect), 430 paintHandle(paintHandle) 431 {} 432 ~ConstructorHandle() override = default; 433 uint32_t surfaceBufferId; 434 DrawingSurfaceBufferInfo surfaceBufferInfo; 435 PaintHandle paintHandle; 436 }; 437 438 DrawSurfaceBufferOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle); DrawSurfaceBufferOpItem(const DrawingSurfaceBufferInfo & surfaceBufferInfo,const Paint & paint)439 DrawSurfaceBufferOpItem(const DrawingSurfaceBufferInfo& surfaceBufferInfo, const Paint& paint) 440 : DrawWithPaintOpItem(paint, SURFACEBUFFER_OPITEM), surfaceBufferInfo_(surfaceBufferInfo) {} 441 ~DrawSurfaceBufferOpItem(); 442 443 static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle); 444 void Marshalling(DrawCmdList& cmdList) override; 445 void Playback(Canvas* canvas, const Rect* rect) override; 446 virtual void DumpItems(std::string& out) const override; 447 RSB_EXPORT static void RegisterSurfaceBufferCallback(DrawSurfaceBufferOpItemCb callbacks); 448 RSB_EXPORT static void RegisterGetRootNodeIdFuncForRT(std::function<NodeId()> func); 449 RSB_EXPORT static void SetIsUniRender(bool isUniRender); 450 private: 451 void OnAfterAcquireBuffer(); 452 void OnBeforeDraw(); 453 void OnAfterDraw(); 454 void OnDestruct(); 455 void ReleaseBuffer(); 456 void Clear(); 457 void DealWithRotate(Canvas* canvas); 458 void Draw(Canvas* canvas); 459 void DrawWithVulkan(Canvas* canvas); 460 void DrawWithGles(Canvas* canvas); 461 bool CreateEglTextureId(); 462 bool IsNeedDrawDirectly() const; 463 static Drawing::SamplingOptions CreateSamplingOptions(const Drawing::Matrix& matrix); 464 static Drawing::BitmapFormat CreateBitmapFormat(int32_t bufferFormat); 465 #ifdef RS_ENABLE_GL 466 static GLenum GetGLTextureFormatByBitmapFormat(Drawing::ColorType colorType); 467 #endif 468 static GraphicTransformType MapGraphicTransformType(GraphicTransformType origin); 469 static bool IsValidRemoteAddress(pid_t pid, uint64_t uid); 470 mutable DrawingSurfaceBufferInfo surfaceBufferInfo_; 471 NodeId rootNodeId_ = INVALID_NODEID; 472 sptr<SyncFence> releaseFence_ = SyncFence::INVALID_FENCE; 473 bool isRendered_ = false; 474 bool isNeedRotateDstRect_ = false; 475 bool isNeedDrawDirectly_ = false; 476 477 #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) 478 OHNativeWindowBuffer* nativeWindowBuffer_ = nullptr; 479 #endif 480 #ifdef RS_ENABLE_GL 481 mutable EGLImageKHR eglImage_ = EGL_NO_IMAGE_KHR; 482 mutable GLuint texId_ = 0; 483 #endif 484 }; 485 #endif 486 } 487 } // namespace Rosen 488 } // namespace OHOS 489 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_DRAW_CMD_H 490