Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit d12963f

Browse files
committed
Implement windows surface
1 parent 497a54e commit d12963f

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/doc
22
/target
33
/Cargo.lock
4+
*~

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ pub mod platform {
6262
pub mod android {
6363
pub mod surface;
6464
}
65+
#[cfg(target_os="windows")]
66+
pub mod windows {
67+
pub mod surface;
68+
}
6569
pub mod surface;
6670
}
6771

src/platform/surface.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use texturegl::Texture;
1515
use euclid::size::Size2D;
1616
use skia::gl_rasterization_context::GLRasterizationContext;
1717
use skia::gl_context::GLContext;
18+
use skia::gl_context::PlatformDisplayData;
1819
use std::sync::Arc;
1920

2021
#[cfg(not(target_os="android"))]
@@ -34,6 +35,9 @@ use std::ptr;
3435
pub use platform::android::surface::{NativeDisplay,
3536
EGLImageNativeSurface};
3637

38+
#[cfg(target_os="windows")]
39+
pub use platform::windows::surface::NativeDisplay;
40+
3741
pub enum NativeSurface {
3842
MemoryBuffer(MemoryBufferNativeSurface),
3943
#[cfg(target_os="linux")]
@@ -72,6 +76,14 @@ impl NativeSurface {
7276
}
7377
}
7478

79+
#[cfg(target_os="windows")]
80+
impl NativeSurface {
81+
/// Creates a new native surface with uninitialized data.
82+
pub fn new(display: &NativeDisplay, size: Size2D<i32>) -> NativeSurface {
83+
NativeSurface::MemoryBuffer(MemoryBufferNativeSurface::new(display, size))
84+
}
85+
}
86+
7587
macro_rules! native_surface_method_with_mutability {
7688
($self_:ident, $function_name:ident, $surface:ident, $pattern:pat, $($argument:ident),*) => {
7789
match *$self_ {

src/platform/windows/surface.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use skia::gl_context::PlatformDisplayData;
2+
3+
#[derive(Copy, Clone)]
4+
pub struct NativeDisplay;
5+
6+
#[cfg(target_os="windows")]
7+
impl NativeDisplay {
8+
pub fn new() -> NativeDisplay {
9+
NativeDisplay
10+
}
11+
12+
pub fn platform_display_data(&self) -> PlatformDisplayData {
13+
PlatformDisplayData::new()
14+
}
15+
}
16+

src/texturegl.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ impl Texture {
160160
(Flip::NoFlip, TextureTarget::TextureTarget2D)
161161
}
162162

163+
#[cfg(target_os="windows")]
164+
pub fn texture_flip_and_target(_: bool) -> (Flip, TextureTarget) {
165+
(Flip::NoFlip, TextureTarget::TextureTarget2D)
166+
}
167+
163168
/// Returns the raw OpenGL texture underlying this texture.
164169
pub fn native_texture(&self) -> GLuint {
165170
self.id

0 commit comments

Comments
 (0)