-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GL_TEXTURE_RECTANGLE texture target support #997
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
86b00a7
Use struct ExternalImageData to present the different external textur…
JerryShih 1305f38
Add new TextureTarget::Rect texture target type for external image Te…
JerryShih dec3102
Add a new TEXTURE_RECT_FEATURE feature in image shader for external i…
JerryShih bbfefcc
Update ImageData type in wrench.
JerryShih File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ use thread_profiler::{register_thread_with_profiler, write_profile}; | |
use util::TransformedRectKind; | ||
use webgl_types::GLContextHandleWrapper; | ||
use webrender_traits::{ColorF, Epoch, PipelineId, RenderNotifier, RenderDispatcher}; | ||
use webrender_traits::{ExternalImageId, ImageData, ImageFormat, RenderApiSender}; | ||
use webrender_traits::{ExternalImageId, ExternalImageType, ImageData, ImageFormat, RenderApiSender}; | ||
use webrender_traits::{DeviceIntRect, DevicePoint, DeviceIntPoint, DeviceIntSize, DeviceUintSize}; | ||
use webrender_traits::{ImageDescriptor, BlobImageRenderer}; | ||
use webrender_traits::channel; | ||
|
@@ -65,6 +65,7 @@ const GPU_TAG_INIT: GpuProfileTag = GpuProfileTag { label: "Init", color: debug_ | |
const GPU_TAG_SETUP_TARGET: GpuProfileTag = GpuProfileTag { label: "Target", color: debug_colors::SLATEGREY }; | ||
const GPU_TAG_PRIM_RECT: GpuProfileTag = GpuProfileTag { label: "Rect", color: debug_colors::RED }; | ||
const GPU_TAG_PRIM_IMAGE: GpuProfileTag = GpuProfileTag { label: "Image", color: debug_colors::GREEN }; | ||
const GPU_TAG_PRIM_IMAGE_RECT: GpuProfileTag = GpuProfileTag { label: "ImageRect", color: debug_colors::GREENYELLOW }; | ||
const GPU_TAG_PRIM_YUV_IMAGE: GpuProfileTag = GpuProfileTag { label: "YuvImage", color: debug_colors::DARKGREEN }; | ||
const GPU_TAG_PRIM_BLEND: GpuProfileTag = GpuProfileTag { label: "Blend", color: debug_colors::LIGHTBLUE }; | ||
const GPU_TAG_PRIM_HW_COMPOSITE: GpuProfileTag = GpuProfileTag { label: "HwComposite", color: debug_colors::DODGERBLUE }; | ||
|
@@ -223,6 +224,7 @@ pub type GradientDataStore = GpuStore<GradientData, GradientDataTextureLayout>; | |
const TRANSFORM_FEATURE: &'static str = "TRANSFORM"; | ||
const SUBPIXEL_AA_FEATURE: &'static str = "SUBPIXEL_AA"; | ||
const CLIP_FEATURE: &'static str = "CLIP"; | ||
const TEXTURE_RECT_FEATURE: &'static str = "TEXTURE_RECT"; | ||
|
||
enum ShaderKind { | ||
Primitive, | ||
|
@@ -465,6 +467,7 @@ pub struct Renderer { | |
ps_text_run: PrimitiveShader, | ||
ps_text_run_subpixel: PrimitiveShader, | ||
ps_image: PrimitiveShader, | ||
ps_image_rect: PrimitiveShader, | ||
ps_yuv_image: PrimitiveShader, | ||
ps_border: PrimitiveShader, | ||
ps_gradient: PrimitiveShader, | ||
|
@@ -670,6 +673,13 @@ impl Renderer { | |
options.precache_shaders) | ||
}; | ||
|
||
let ps_image_rect = try!{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I add a new shader for textureRect. We could also merge this back to the original image shader. I don't like too much "#ifdef" in the code. |
||
PrimitiveShader::new("ps_image", | ||
&mut device, | ||
&[ TEXTURE_RECT_FEATURE ], | ||
options.precache_shaders) | ||
}; | ||
|
||
let ps_yuv_image = try!{ | ||
PrimitiveShader::new("ps_yuv_image", | ||
&mut device, | ||
|
@@ -912,6 +922,7 @@ impl Renderer { | |
ps_text_run: ps_text_run, | ||
ps_text_run_subpixel: ps_text_run_subpixel, | ||
ps_image: ps_image, | ||
ps_image_rect: ps_image_rect, | ||
ps_yuv_image: ps_yuv_image, | ||
ps_border: ps_border, | ||
ps_box_shadow: ps_box_shadow, | ||
|
@@ -1039,10 +1050,10 @@ impl Renderer { | |
fn resolve_source_texture(&mut self, texture_id: &SourceTexture) -> TextureId { | ||
match *texture_id { | ||
SourceTexture::Invalid => TextureId::invalid(), | ||
SourceTexture::WebGL(id) => TextureId::new(id), | ||
SourceTexture::External(ref key) => { | ||
SourceTexture::WebGL(id) => TextureId::new(id, TextureTarget::Default), | ||
SourceTexture::External(external_image) => { | ||
*self.external_images | ||
.get(key) | ||
.get(&external_image.id) | ||
.expect("BUG: External image should be resolved by now!") | ||
} | ||
SourceTexture::TextureCache(index) => { | ||
|
@@ -1193,24 +1204,31 @@ impl Renderer { | |
mode, | ||
Some(raw.as_slice())); | ||
} | ||
ImageData::ExternalBuffer(id) => { | ||
let handler = self.external_image_handler | ||
.as_mut() | ||
.expect("Found external image, but no handler set!"); | ||
|
||
match handler.lock(id).source { | ||
ExternalImageSource::RawData(raw) => { | ||
self.device.init_texture(texture_id, | ||
width, | ||
height, | ||
format, | ||
filter, | ||
mode, | ||
Some(raw)); | ||
ImageData::External(ext_image) => { | ||
match ext_image.image_type { | ||
ExternalImageType::ExternalBuffer => { | ||
let handler = self.external_image_handler | ||
.as_mut() | ||
.expect("Found external image, but no handler set!"); | ||
|
||
match handler.lock(ext_image.id).source { | ||
ExternalImageSource::RawData(raw) => { | ||
self.device.init_texture(texture_id, | ||
width, | ||
height, | ||
format, | ||
filter, | ||
mode, | ||
Some(raw)); | ||
} | ||
_ => panic!("No external buffer found"), | ||
}; | ||
handler.unlock(ext_image.id); | ||
} | ||
_ => panic!("No external buffer found"), | ||
}; | ||
handler.unlock(id); | ||
_ => { | ||
panic!("External texture handle should not use TextureUpdateOp::Create."); | ||
} | ||
} | ||
} | ||
_ => { | ||
panic!("No suitable image buffer for TextureUpdateOp::Create."); | ||
|
@@ -1339,6 +1357,10 @@ impl Renderer { | |
let shader = self.ps_image.get(&mut self.device, transform_kind); | ||
(GPU_TAG_PRIM_IMAGE, shader) | ||
} | ||
AlphaBatchKind::ImageRect => { | ||
let shader = self.ps_image_rect.get(&mut self.device, transform_kind); | ||
(GPU_TAG_PRIM_IMAGE_RECT, shader) | ||
} | ||
AlphaBatchKind::YuvImage => { | ||
let shader = self.ps_yuv_image.get(&mut self.device, transform_kind); | ||
(GPU_TAG_PRIM_YUV_IMAGE, shader) | ||
|
@@ -1665,16 +1687,24 @@ impl Renderer { | |
for deferred_resolve in &frame.deferred_resolves { | ||
GpuMarker::fire(self.device.gl(), "deferred resolve"); | ||
let props = &deferred_resolve.image_properties; | ||
let external_id = props.external_id | ||
.expect("BUG: Deferred resolves must be external images!"); | ||
let image = handler.lock(external_id); | ||
let ext_image = props.external_image | ||
.expect("BUG: Deferred resolves must be external images!"); | ||
let image = handler.lock(ext_image.id); | ||
let texture_target = match ext_image.image_type { | ||
ExternalImageType::Texture2DHandle => TextureTarget::Default, | ||
ExternalImageType::TextureRectHandle => TextureTarget::Rect, | ||
_ => { | ||
panic!("{:?} is not a suitable image type in update_deferred_resolves().", | ||
ext_image.image_type); | ||
} | ||
}; | ||
|
||
let texture_id = match image.source { | ||
ExternalImageSource::NativeTexture(texture_id) => TextureId::new(texture_id), | ||
ExternalImageSource::NativeTexture(texture_id) => TextureId::new(texture_id, texture_target), | ||
_ => panic!("No native texture found."), | ||
}; | ||
|
||
self.external_images.insert(external_id, texture_id); | ||
self.external_images.insert(ext_image.id, texture_id); | ||
let resource_rect_index = deferred_resolve.resource_address.0 as usize; | ||
let resource_rect = &mut frame.gpu_resource_rects[resource_rect_index]; | ||
resource_rect.uv0 = DevicePoint::new(image.u0, image.v0); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macIOSurface should use sampler2DRect