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 | |
| 19 | #include "renderthread/RenderThread.h" |
John Reck | 9580146 | 2016-09-01 09:44:09 -0700 | [diff] [blame] | 20 | #include "Rect.h" |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 21 | |
| 22 | #include <SkBitmap.h> |
| 23 | #include <gui/Surface.h> |
| 24 | |
| 25 | namespace android { |
sergeyv | 59eecb52 | 2016-11-17 17:54:57 -0800 | [diff] [blame] | 26 | class GraphicBuffer; |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 27 | namespace uirenderer { |
| 28 | |
John Reck | e94cbc7 | 2016-04-25 13:03:44 -0700 | [diff] [blame] | 29 | // Keep in sync with PixelCopy.java codes |
| 30 | enum class CopyResult { |
| 31 | Success = 0, |
| 32 | UnknownError = 1, |
| 33 | Timeout = 2, |
| 34 | SourceEmpty = 3, |
| 35 | SourceInvalid = 4, |
| 36 | DestinationInvalid = 5, |
| 37 | }; |
| 38 | |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 39 | class Readback { |
| 40 | public: |
Chris Craik | 764045d | 2016-07-06 17:14:05 -0700 | [diff] [blame] | 41 | /** |
| 42 | * Copies the surface's most recently queued buffer into the provided bitmap. |
| 43 | */ |
Derek Sollenberger | c4fbada | 2016-11-07 16:05:41 -0500 | [diff] [blame] | 44 | virtual CopyResult copySurfaceInto(Surface& surface, const Rect& srcRect, |
| 45 | SkBitmap* bitmap) = 0; |
sergeyv | 59eecb52 | 2016-11-17 17:54:57 -0800 | [diff] [blame] | 46 | virtual CopyResult copyGraphicBufferInto(GraphicBuffer* graphicBuffer, SkBitmap* bitmap) = 0; |
Chris Craik | 764045d | 2016-07-06 17:14:05 -0700 | [diff] [blame] | 47 | |
Derek Sollenberger | c4fbada | 2016-11-07 16:05:41 -0500 | [diff] [blame] | 48 | protected: |
| 49 | explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {} |
| 50 | virtual ~Readback() {} |
| 51 | |
| 52 | renderthread::RenderThread& mRenderThread; |
John Reck | 10dd058 | 2016-03-31 16:36:16 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace uirenderer |
| 56 | } // namespace android |