John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
John Reck | 4d73cb1 | 2022-07-27 10:32:52 -0400 | [diff] [blame] | 19 | #include <SkRefCnt.h> |
| 20 | |
| 21 | #include "CopyRequest.h" |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 22 | #include "Matrix.h" |
John Reck | 9580146 | 2016-09-01 09:44:09 -0700 | [diff] [blame] | 23 | #include "Rect.h" |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 24 | #include "renderthread/RenderThread.h" |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 25 | |
Kevin Lubick | 1175dc0 | 2022-02-28 12:41:27 -0500 | [diff] [blame] | 26 | class SkBitmap; |
| 27 | class SkImage; |
| 28 | struct SkRect; |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 29 | |
| 30 | namespace android { |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 31 | class Bitmap; |
sergeyv | 59eecb52 | 2016-11-17 17:54:57 -0800 | [diff] [blame] | 32 | class GraphicBuffer; |
Mathias Agopian | 3d7d5f9 | 2017-05-01 15:13:20 -0700 | [diff] [blame] | 33 | class Surface; |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 34 | namespace uirenderer { |
| 35 | |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 36 | class DeferredLayerUpdater; |
| 37 | class Layer; |
| 38 | |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 39 | class Readback { |
| 40 | public: |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 41 | explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {} |
Chris Craik | 764045d | 2016-07-06 17:14:05 -0700 | [diff] [blame] | 42 | /** |
| 43 | * Copies the surface's most recently queued buffer into the provided bitmap. |
| 44 | */ |
John Reck | 4d73cb1 | 2022-07-27 10:32:52 -0400 | [diff] [blame] | 45 | void copySurfaceInto(ANativeWindow* window, const std::shared_ptr<CopyRequest>& request); |
Chris Craik | 764045d | 2016-07-06 17:14:05 -0700 | [diff] [blame] | 46 | |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 47 | CopyResult copyHWBitmapInto(Bitmap* hwBitmap, SkBitmap* bitmap); |
John Reck | 7600518 | 2021-06-09 22:43:05 -0400 | [diff] [blame] | 48 | CopyResult copyImageInto(const sk_sp<SkImage>& image, SkBitmap* bitmap); |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 49 | |
| 50 | CopyResult copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); |
| 51 | |
| 52 | private: |
ramindani | 3952ed6 | 2021-08-12 15:55:12 +0000 | [diff] [blame] | 53 | CopyResult copyImageInto(const sk_sp<SkImage>& image, const Rect& srcRect, SkBitmap* bitmap); |
Stan Iliev | 1a025a7 | 2018-09-05 16:35:11 -0400 | [diff] [blame] | 54 | |
| 55 | bool copyLayerInto(Layer* layer, const SkRect* srcRect, const SkRect* dstRect, |
| 56 | SkBitmap* bitmap); |
Derek Sollenberger | c4fbada | 2016-11-07 16:05:41 -0500 | [diff] [blame] | 57 | |
| 58 | renderthread::RenderThread& mRenderThread; |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 61 | } // namespace uirenderer |
| 62 | } // namespace android |