Home | History | Annotate | Download | only in utils
      1 /*
      2  * Copyright (C) 2015 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 #ifndef TESTWINDOWCONTEXT_H_
     17 #define TESTWINDOWCONTEXT_H_
     18 
     19 #include <cutils/compiler.h>
     20 
     21 class SkBitmap;
     22 class SkCanvas;
     23 
     24 namespace android {
     25 
     26 namespace uirenderer {
     27 
     28 /**
     29   Wraps all libui/libgui classes and types that external tests depend on,
     30   exposing only primitive Skia types.
     31 */
     32 
     33 class ANDROID_API TestWindowContext {
     34 public:
     35     TestWindowContext();
     36     ~TestWindowContext();
     37 
     38     /// We need to know the size of the window.
     39     void initialize(int width, int height);
     40 
     41     /// Returns a canvas to draw into; NULL if not yet initialize()d.
     42     SkCanvas* prepareToDraw();
     43 
     44     /// Flushes all drawing commands to HWUI; no-op if not yet initialize()d.
     45     void finishDrawing();
     46 
     47     /// Blocks until HWUI has processed all pending drawing commands;
     48     /// no-op if not yet initialize()d.
     49     void fence();
     50 
     51     /// Returns false if not yet initialize()d.
     52     bool capturePixels(SkBitmap* bmp);
     53 
     54 private:
     55     /// Hidden implementation.
     56     class TestWindowData;
     57 
     58     TestWindowData* mData;
     59 };
     60 
     61 }  // namespace uirenderer
     62 }  // namespace android
     63 
     64 #endif  // TESTWINDOWCONTEXT_H_
     65