Esempio n. 1
0
        public static unsafe void DirectBlit(BitmapSurface buffer, ref Texture2D texture2D)
        {
            //TODO : Test if d3dt can be cached
            var d3Dt = GetIUnknownObject <IDirect3DTexture9>(texture2D);
            //XE.Performance.Log("IDirect3DTexture9 Is "+(d3dt!=null ? d3dt.ToString():"null"));

            //D3DSURFACE_DESC desc=new D3DSURFACE_DESC();
            //Marshal.ThrowExceptionForHR(d3dt.GetLevelDesc(0, out desc));
            //XE.Performance.Log("LevelDesc Format "+desc.Format.ToString());
            //XE.Performance.Log("LevelDesc MultiSampleQuality "+desc.MultiSampleQuality.ToString());
            //XE.Performance.Log("LevelDesc MultiSampleType "+desc.MultiSampleType.ToString());
            //XE.Performance.Log("LevelDesc Pool "+desc.Pool.ToString());
            //XE.Performance.Log("LevelDesc Type "+desc.Type.ToString());
            //XE.Performance.Log("LevelDesc Usage "+desc.Usage.ToString());
            //XE.Performance.Log("LevelDesc Width "+desc.Width.ToString());
            //XE.Performance.Log("LevelDesc Height "+desc.Height.ToString());

            D3DlockedRect lockrect;
            var           rect = new Rect();

            Marshal.ThrowExceptionForHR(d3Dt.LockRect(0, out lockrect, rect, 0));
            //XE.Performance.Log("LockRect Pitch "+lockrect.Pitch.ToString());
            //XE.Performance.Log("LockRect pBits "+((uint)lockrect.pBits).ToString());

            //buffer.CopyTo(destBuffer, destRowSpan, destDepth, convertoRGBA, flipY);

            buffer.CopyTo((IntPtr)(uint)(lockrect.pBits), lockrect.Pitch, 4, false, false);
            d3Dt.UnlockRect(0);

            //Meve onto Dispose() if d3dt will be cached d3dt
            Marshal.ReleaseComObject(d3Dt);
        }
Esempio n. 2
0
        private int browserheight;       // Height of browser.

        /// <summary>
        /// Instantiates a new tab.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="URL"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public BrowserTab(int id, string URL, int w, int h, int x, int y)
        {
            ID  = id;
            url = URL;

            browserwidth  = w;
            browserheight = h;

            s        = new BitmapSurface(w, h);
            webBytes = new byte[w * h * 4];

            BrowserTex    = new Texture((uint)browserwidth, (uint)browserheight);
            View          = new Sprite(BrowserTex);
            View.Position = new Vector2f((uint)x, (uint)y);

            WebSession session = WebCore.CreateWebSession(new WebPreferences()
            {
                WebSecurity                = false,
                FileAccessFromFileURL      = true,
                UniversalAccessFromFileURL = true,
                LocalStorage               = true,
            });

            MyTab = WebCore.CreateWebView(browserwidth, browserheight, session, WebViewType.Offscreen);

            //MyTab.ShowJavascriptDialog += (sender, e) =>
            //{
            //    Console.WriteLine(e.Message);
            //    BrowserManager.DestroyTab(ID);
            //    BrowserManager.NewTab(ID, url, w, h, x, y);
            //};

            MyTab.Source = new Uri(URL);

            MyTab.Surface = s;

            s.Updated += (sender, e) =>
            {
                unsafe
                {
                    fixed(Byte *byteptr = webBytes)
                    {
                        s.CopyTo((IntPtr)byteptr, s.RowSpan, 4, true, false);
                        BrowserTex.Update(webBytes);
                    }
                }
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Updates texture.
        /// </summary>
        public void UpdateTexture()
        {
            BrowserManager.awesomiumContext.Send(state =>
            {
                int sRow           = s.RowSpan;
                BitmapSurface temp = s;

                unsafe
                {
                    fixed(Byte * byteptr = webBytes)
                    {
                        temp.CopyTo((IntPtr)byteptr, sRow, 4, true, false);
                        BrowserTex.Update(webBytes);
                    }
                }
            }, null);
        }
Esempio n. 4
0
 public void Update()
 {
     webView.Invoke(new Action(() =>
     {
         if (_surface == null || !_surface.IsDirty)
         {
             return;
         }
         unsafe
         {
             // This part saves us from double copying everything.
             fixed(Byte * imagePtr = _data)
             {
                 _surface.CopyTo((IntPtr)imagePtr, _surface.Width * 4, 4, false, false);
             }
         }
         IsDirty = true;
     }), null);
 }
Esempio n. 5
0
 public void Update()
 {
     _awesomiumContext.Post(state =>
     {
         if (_surface == null || !_surface.IsDirty)
         {
             return;
         }
         unsafe
         {
             // This part saves us from double copying everything.
             fixed(Byte * imagePtr = _data)
             {
                 _surface.CopyTo((IntPtr)imagePtr, _surface.Width * 4, 4, false, false);
             }
         }
         IsDirty = true;
     }, null);
 }
Esempio n. 6
0
        public void Draw()
        {
            if (!initialized)
            {
                return;
            }
#if DEBUG
            //bool wasDirty = surface.IsDirty;
#endif
            if (surface.IsDirty)
            {
                DataRectangle rect = mappableSurface.Map(SharpDX.DXGI.MapFlags.Write);
                surface.CopyTo(rect.DataPointer, rect.Pitch, 4, false, false);
                mappableSurface.Unmap();
                Display.context.CopyResource(mappableTexture, webTex.Tex);
            }
            QuadRenderer.Draw(webTex, position, new Color4(1, 1, 1, 1));
#if DEBUG
            //FontRenderer.Draw(FontManager.Get("default"), "Dirty:"+wasDirty, new Vector2(position.X, position.Y), Color.White);
#endif
        }