Readback.h revision 9580146f5076aaa7c498f86bd3d724c00599f6f4
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" 20#include "Rect.h" 21 22#include <SkBitmap.h> 23#include <gui/Surface.h> 24 25namespace android { 26namespace uirenderer { 27 28class Layer; 29 30// Keep in sync with PixelCopy.java codes 31enum class CopyResult { 32 Success = 0, 33 UnknownError = 1, 34 Timeout = 2, 35 SourceEmpty = 3, 36 SourceInvalid = 4, 37 DestinationInvalid = 5, 38}; 39 40class Readback { 41public: 42 /** 43 * Copies the surface's most recently queued buffer into the provided bitmap. 44 */ 45 static CopyResult copySurfaceInto(renderthread::RenderThread& renderThread, 46 Surface& surface, const Rect& srcRect, SkBitmap* bitmap); 47 48 /** 49 * Copies the TextureLayer's texture content (thus, the currently rendering buffer) into the 50 * provided bitmap. 51 */ 52 static CopyResult copyTextureLayerInto(renderthread::RenderThread& renderThread, 53 Layer& layer, SkBitmap* bitmap); 54}; 55 56} // namespace uirenderer 57} // namespace android 58