blob: e86a8136cfa38e01b1aaf0725931ba42af2ebf15 [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
Stan Iliev1a025a72018-09-05 16:35:11 -040019#include "Matrix.h"
John Reck95801462016-09-01 09:44:09 -070020#include "Rect.h"
John Reck1bcacfd2017-11-03 10:12:19 -070021#include "renderthread/RenderThread.h"
John Reck10dd0582016-03-31 16:36:16 -070022
23#include <SkBitmap.h>
John Reck10dd0582016-03-31 16:36:16 -070024
25namespace android {
Stan Iliev1a025a72018-09-05 16:35:11 -040026class Bitmap;
sergeyv59eecb522016-11-17 17:54:57 -080027class GraphicBuffer;
Mathias Agopian3d7d5f92017-05-01 15:13:20 -070028class Surface;
John Reck10dd0582016-03-31 16:36:16 -070029namespace uirenderer {
30
Stan Iliev1a025a72018-09-05 16:35:11 -040031class DeferredLayerUpdater;
32class Layer;
33
John Recke94cbc72016-04-25 13:03:44 -070034// Keep in sync with PixelCopy.java codes
35enum class CopyResult {
36 Success = 0,
37 UnknownError = 1,
38 Timeout = 2,
39 SourceEmpty = 3,
40 SourceInvalid = 4,
41 DestinationInvalid = 5,
42};
43
John Reck10dd0582016-03-31 16:36:16 -070044class Readback {
45public:
Stan Iliev1a025a72018-09-05 16:35:11 -040046 explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {}
Chris Craik764045d2016-07-06 17:14:05 -070047 /**
48 * Copies the surface's most recently queued buffer into the provided bitmap.
49 */
Stan Iliev1a025a72018-09-05 16:35:11 -040050 CopyResult copySurfaceInto(Surface& surface, const Rect& srcRect, SkBitmap* bitmap);
Chris Craik764045d2016-07-06 17:14:05 -070051
Stan Iliev1a025a72018-09-05 16:35:11 -040052 CopyResult copyHWBitmapInto(Bitmap* hwBitmap, SkBitmap* bitmap);
53
54 CopyResult copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap);
55
56private:
Derek Sollenbergerd01b5912018-10-19 15:55:33 -040057 CopyResult copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTransform,
58 const Rect& srcRect, SkBitmap* bitmap);
Stan Iliev1a025a72018-09-05 16:35:11 -040059
60 bool copyLayerInto(Layer* layer, const SkRect* srcRect, const SkRect* dstRect,
61 SkBitmap* bitmap);
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -050062
63 renderthread::RenderThread& mRenderThread;
John Reck10dd0582016-03-31 16:36:16 -070064};
65
John Reck1bcacfd2017-11-03 10:12:19 -070066} // namespace uirenderer
67} // namespace android