blob: 7fbc4bf48c4e4061944057ce9eaa1c2aae1386c5 [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
19#include "renderthread/RenderThread.h"
John Reck95801462016-09-01 09:44:09 -070020#include "Rect.h"
John Reck10dd0582016-03-31 16:36:16 -070021
22#include <SkBitmap.h>
23#include <gui/Surface.h>
24
25namespace android {
26namespace uirenderer {
27
John Recke94cbc72016-04-25 13:03:44 -070028// Keep in sync with PixelCopy.java codes
29enum class CopyResult {
30 Success = 0,
31 UnknownError = 1,
32 Timeout = 2,
33 SourceEmpty = 3,
34 SourceInvalid = 4,
35 DestinationInvalid = 5,
36};
37
John Reck10dd0582016-03-31 16:36:16 -070038class Readback {
39public:
Chris Craik764045d2016-07-06 17:14:05 -070040 /**
41 * Copies the surface's most recently queued buffer into the provided bitmap.
42 */
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -050043 virtual CopyResult copySurfaceInto(Surface& surface, const Rect& srcRect,
44 SkBitmap* bitmap) = 0;
Chris Craik764045d2016-07-06 17:14:05 -070045
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -050046protected:
47 explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {}
48 virtual ~Readback() {}
49
50 renderthread::RenderThread& mRenderThread;
John Reck10dd0582016-03-31 16:36:16 -070051};
52
53} // namespace uirenderer
54} // namespace android