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 <SkRefCnt.h> 20 21 #include "CopyRequest.h" 22 #include "Matrix.h" 23 #include "Rect.h" 24 #include "renderthread/RenderThread.h" 25 26 class SkBitmap; 27 class SkImage; 28 struct SkRect; 29 30 namespace android { 31 class Bitmap; 32 class GraphicBuffer; 33 class Surface; 34 namespace uirenderer { 35 36 class DeferredLayerUpdater; 37 class Layer; 38 39 class Readback { 40 public: Readback(renderthread::RenderThread & thread)41 explicit Readback(renderthread::RenderThread& thread) : mRenderThread(thread) {} 42 /** 43 * Copies the surface's most recently queued buffer into the provided bitmap. 44 */ 45 void copySurfaceInto(ANativeWindow* window, const std::shared_ptr<CopyRequest>& request); 46 47 CopyResult copyHWBitmapInto(Bitmap* hwBitmap, SkBitmap* bitmap); 48 CopyResult copyImageInto(const sk_sp<SkImage>& image, SkBitmap* bitmap); 49 50 CopyResult copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); 51 52 private: 53 CopyResult copyImageInto(const sk_sp<SkImage>& image, const Rect& srcRect, SkBitmap* bitmap); 54 55 bool copyLayerInto(Layer* layer, const SkRect* srcRect, const SkRect* dstRect, 56 SkBitmap* bitmap); 57 58 renderthread::RenderThread& mRenderThread; 59 }; 60 61 } // namespace uirenderer 62 } // namespace android 63