blob: a092d472abf0f9f5665c8bb7bb100531db8f95b5 [file] [log] [blame]
John Reck10dd0582016-03-31 16:36:16 -07001/*
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 Reck4d73cb12022-07-27 10:32:52 -040019#include <SkRefCnt.h>
20
21#include "CopyRequest.h"
Stan Iliev1a025a72018-09-05 16:35:11 -040022#include "Matrix.h"
John Reck95801462016-09-01 09:44:09 -070023#include "Rect.h"
John Reck1bcacfd2017-11-03 10:12:19 -070024#include "renderthread/RenderThread.h"
John Reck10dd0582016-03-31 16:36:16 -070025
Kevin Lubick1175dc02022-02-28 12:41:27 -050026class SkBitmap;
27class SkImage;
28struct SkRect;
John Reck10dd0582016-03-31 16:36:16 -070029
30namespace android {
Stan Iliev1a025a72018-09-05 16:35:11 -040031class Bitmap;
sergeyv59eecb522016-11-17 17:54:57 -080032class GraphicBuffer;
Mathias Agopian3d7d5f92017-05-01 15:13:20 -070033class Surface;
John Reck10dd0582016-03-31 16:36:16 -070034namespace uirenderer {
35
Stan Iliev1a025a72018-09-05 16:35:11 -040036class DeferredLayerUpdater;
37class Layer;
38
John Reck10dd0582016-03-31 16:36:16 -070039class Readback {
40public:
Stan Iliev1a025a72018-09-05 16:35:11 -040041 explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {}
Chris Craik764045d2016-07-06 17:14:05 -070042 /**
43 * Copies the surface's most recently queued buffer into the provided bitmap.
44 */
John Reck4d73cb12022-07-27 10:32:52 -040045 void copySurfaceInto(ANativeWindow* window, const std::shared_ptr<CopyRequest>& request);
Chris Craik764045d2016-07-06 17:14:05 -070046
Stan Iliev1a025a72018-09-05 16:35:11 -040047 CopyResult copyHWBitmapInto(Bitmap* hwBitmap, SkBitmap* bitmap);
John Reck76005182021-06-09 22:43:05 -040048 CopyResult copyImageInto(const sk_sp<SkImage>& image, SkBitmap* bitmap);
Stan Iliev1a025a72018-09-05 16:35:11 -040049
50 CopyResult copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap);
51
52private:
ramindani3952ed62021-08-12 15:55:12 +000053 CopyResult copyImageInto(const sk_sp<SkImage>& image, const Rect& srcRect, SkBitmap* bitmap);
Stan Iliev1a025a72018-09-05 16:35:11 -040054
55 bool copyLayerInto(Layer* layer, const SkRect* srcRect, const SkRect* dstRect,
56 SkBitmap* bitmap);
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -050057
58 renderthread::RenderThread& mRenderThread;
John Reck10dd0582016-03-31 16:36:16 -070059};
60
John Reck1bcacfd2017-11-03 10:12:19 -070061} // namespace uirenderer
62} // namespace android