blob: ad3a8b690617f50b930f64b6250a954ea699be01 [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 Reck95801462016-09-01 09:44:09 -070019#include "Rect.h"
John Reck1bcacfd2017-11-03 10:12:19 -070020#include "renderthread/RenderThread.h"
John Reck10dd0582016-03-31 16:36:16 -070021
22#include <SkBitmap.h>
John Reck10dd0582016-03-31 16:36:16 -070023
24namespace android {
sergeyv59eecb522016-11-17 17:54:57 -080025class GraphicBuffer;
Mathias Agopian3d7d5f92017-05-01 15:13:20 -070026class Surface;
John Reck10dd0582016-03-31 16:36:16 -070027namespace uirenderer {
28
John Recke94cbc72016-04-25 13:03:44 -070029// Keep in sync with PixelCopy.java codes
30enum class CopyResult {
31 Success = 0,
32 UnknownError = 1,
33 Timeout = 2,
34 SourceEmpty = 3,
35 SourceInvalid = 4,
36 DestinationInvalid = 5,
37};
38
John Reck10dd0582016-03-31 16:36:16 -070039class Readback {
40public:
Chris Craik764045d2016-07-06 17:14:05 -070041 /**
42 * Copies the surface's most recently queued buffer into the provided bitmap.
43 */
John Reck1bcacfd2017-11-03 10:12:19 -070044 virtual CopyResult copySurfaceInto(Surface& surface, const Rect& srcRect, SkBitmap* bitmap) = 0;
sergeyv59eecb522016-11-17 17:54:57 -080045 virtual CopyResult copyGraphicBufferInto(GraphicBuffer* graphicBuffer, SkBitmap* bitmap) = 0;
Chris Craik764045d2016-07-06 17:14:05 -070046
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -050047protected:
48 explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {}
49 virtual ~Readback() {}
50
51 renderthread::RenderThread& mRenderThread;
John Reck10dd0582016-03-31 16:36:16 -070052};
53
John Reck1bcacfd2017-11-03 10:12:19 -070054} // namespace uirenderer
55} // namespace android