Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 1 | // Copyright 2024 The Chromium Authors |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_SERVICES_SCREEN_AI_SCREEN_AI_LIBRARY_WRAPPER_H_ |
| 6 | #define COMPONENTS_SERVICES_SCREEN_AI_SCREEN_AI_LIBRARY_WRAPPER_H_ |
| 7 | |
| 8 | #include <stdint.h> |
Arthur Sonzogni | c571efb | 2024-01-26 20:26:18 | [diff] [blame] | 9 | |
Ramin Halavati | daff1ae | 2023-03-30 04:55:26 | [diff] [blame] | 10 | #include <cstdint> |
Arthur Sonzogni | c571efb | 2024-01-26 20:26:18 | [diff] [blame] | 11 | #include <optional> |
Ramin Halavati | c1e4fa9 | 2023-05-17 17:22:06 | [diff] [blame] | 12 | #include <vector> |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 13 | |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 14 | #include "base/files/file_path.h" |
| 15 | #include "base/scoped_native_library.h" |
| 16 | #include "build/build_config.h" |
| 17 | #include "build/chromeos_buildflags.h" |
Ramin Halavati | daff1ae | 2023-03-30 04:55:26 | [diff] [blame] | 18 | #include "components/services/screen_ai/proto/chrome_screen_ai.pb.h" |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 19 | #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | |
| 21 | namespace screen_ai { |
| 22 | |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 23 | // Base wrapper class for Chrome Screen AI library. |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 24 | class ScreenAILibraryWrapper { |
| 25 | public: |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 26 | ScreenAILibraryWrapper() = default; |
| 27 | virtual ~ScreenAILibraryWrapper() = default; |
Ramin Halavati | c1e4fa9 | 2023-05-17 17:22:06 | [diff] [blame] | 28 | |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 29 | // Loads the library from disk. |
| 30 | virtual bool Load(const base::FilePath& library_path) = 0; |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 31 | |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 32 | virtual void EnableDebugMode() = 0; |
| 33 | virtual void GetLibraryVersion(uint32_t& major, uint32_t& minor) = 0; |
| 34 | virtual void SetFileContentFunctions( |
Ramin Halavati | 8ced639 | 2023-09-25 07:27:50 | [diff] [blame] | 35 | uint32_t (*get_file_content_size)(const char* relative_file_path), |
| 36 | void (*get_file_content)(const char* relative_file_path, |
| 37 | uint32_t buffer_size, |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 38 | char* buffer)) = 0; |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 39 | #if BUILDFLAG(IS_CHROMEOS_ASH) |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 40 | virtual void SetLogger() = 0; |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 41 | #endif |
| 42 | |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 43 | virtual bool InitLayoutExtraction() = 0; |
| 44 | virtual std::optional<chrome_screen_ai::VisualAnnotation> ExtractLayout( |
| 45 | const SkBitmap& image) = 0; |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 46 | |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 47 | virtual bool InitMainContentExtraction() = 0; |
| 48 | virtual std::optional<std::vector<int32_t>> ExtractMainContent( |
| 49 | const std::string& serialized_view_hierarchy) = 0; |
Ramin Halavati | 8ced639 | 2023-09-25 07:27:50 | [diff] [blame] | 50 | |
Ramin Halavati | 767b8fc | 2024-02-02 06:23:08 | [diff] [blame] | 51 | virtual bool InitOCR() = 0; |
| 52 | virtual std::optional<chrome_screen_ai::VisualAnnotation> PerformOcr( |
| 53 | const SkBitmap& image) = 0; |
Ramin Halavati | 9442fc7 | 2023-02-19 07:38:12 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | } // namespace screen_ai |
| 57 | |
| 58 | #endif // COMPONENTS_SERVICES_SCREEN_AI_SCREEN_AI_LIBRARY_WRAPPER_H_ |