Home | History | Annotate | Download | only in layers
      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, jobject webViewCoreRef);
     36     MediaLayer(const MediaLayer& layer);
     37     virtual ~MediaLayer();
     38 
     39     virtual bool drawGL(bool layerTilesDisabled);
     40     virtual void paintBitmapGL() const { };
     41     virtual bool needsTexture() { return false; }
     42     virtual bool needsIsolatedSurface() { return true; }
     43 
     44     virtual bool isMedia() const { return true; }
     45     virtual LayerAndroid* copy() const { return new MediaLayer(*this); }
     46 
     47     void invertContents(bool invert) { m_mediaTexture->invertContents(invert); }
     48     void setOutlineSize(int size) { m_outlineSize = size; }
     49 
     50     // function to setup the primary SurfaceTexture in the renderer's context
     51     ANativeWindow* acquireNativeWindowForContent();
     52 
     53     // functions to manipulate secondary layers for video playback
     54     ANativeWindow* acquireNativeWindowForVideo();
     55     void setWindowDimensionsForVideo(const ANativeWindow* window, const SkRect& dimensions);
     56     void releaseNativeWindowForVideo(ANativeWindow* window);
     57     void setFramerateCallback(const ANativeWindow* window, FramerateCallbackProc callback);
     58 
     59 private:
     60     bool m_isCopy;
     61     int m_outlineSize;
     62 
     63     // SurfaceTexture member variables
     64     MediaTexture* m_mediaTexture;
     65 };
     66 
     67 } // namespace WebCore
     68 
     69 #endif // USE(ACCELERATED_COMPOSITING)
     70 
     71 #endif  // MediaLayer_h
     72