Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2010 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 #ifndef MediaLayer_h
     18 #define MediaLayer_h
     19 
     20 #if USE(ACCELERATED_COMPOSITING)
     21 
     22 #include "MediaTexture.h"
     23 #include "LayerAndroid.h"
     24 #include <jni.h>
     25 
     26 namespace android {
     27     class SurfaceTexture;
     28 }
     29 
     30 namespace WebCore {
     31 
     32 class MediaLayer : public LayerAndroid {
     33 
     34 public:
     35     MediaLayer(jobject webViewRef);
     36     MediaLayer(const MediaLayer& layer);
     37     virtual ~MediaLayer();
     38 
     39     virtual bool drawGL();
     40     virtual void paintBitmapGL() const { };
     41     virtual bool needsTexture() { return false; }
     42 
     43     virtual bool isMedia() const { return true; }
     44     virtual LayerAndroid* copy() const { return new MediaLayer(*this); }
     45 
     46     void invertContents(bool invert) { m_mediaTexture->invertContents(invert); }
     47     void setOutlineSize(int size) { m_outlineSize = size; }
     48 
     49     // function to setup the primary SurfaceTexture in the renderer's context
     50     ANativeWindow* acquireNativeWindowForContent();
     51 
     52     // functions to manipulate secondary layers for video playback
     53     ANativeWindow* acquireNativeWindowForVideo();
     54     void setWindowDimensionsForVideo(const ANativeWindow* window, const SkRect& dimensions);
     55     void releaseNativeWindowForVideo(ANativeWindow* window);
     56     void setFramerateCallback(const ANativeWindow* window, FramerateCallbackProc callback);
     57 
     58 private:
     59     bool m_isCopy;
     60     int m_outlineSize;
     61 
     62     // SurfaceTexture member variables
     63     MediaTexture* m_mediaTexture;
     64 };
     65 
     66 } // namespace WebCore
     67 
     68 #endif // USE(ACCELERATED_COMPOSITING)
     69 
     70 #endif  // MediaLayer_h
     71