Skip to content
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 4 commits into from Mar 30, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Use struct ExternalImageData to present the different external textur…

…e handle type.
  • Loading branch information
JerryShih committed Mar 30, 2017
commit 86b00a743f3295a9e69631c4c31579bf0a86939a
@@ -17,7 +17,7 @@ use tiling;
use renderer::BlendMode;
use webrender_traits::{Epoch, ColorF, PipelineId};
use webrender_traits::{ImageFormat, NativeFontHandle};
use webrender_traits::{ExternalImageId, ScrollLayerId};
use webrender_traits::{ExternalImageData, ExternalImageId, ScrollLayerId};
use webrender_traits::{ImageData};
use webrender_traits::{DeviceUintRect};

@@ -43,7 +43,7 @@ pub struct CacheTextureId(pub usize);
pub enum SourceTexture {
Invalid,
TextureCache(CacheTextureId),
External(ExternalImageId),
External(ExternalImageData),
#[cfg_attr(not(feature = "webgl"), allow(dead_code))]
/// This is actually a gl::GLuint, with the shared texture id between the
/// main context and the WebGL context.
@@ -868,8 +868,8 @@ impl PrimitiveStore {

// Check if an external image that needs to be resolved
// by the render thread.
match image_properties.external_id {
Some(external_id) => {
match image_properties.external_image {
Some(external_image) => {
// This is an external texture - we will add it to
// the deferred resolves list to be patched by
// the render thread...
@@ -878,7 +878,7 @@ impl PrimitiveStore {
resource_address: image_uv_address,
});

(SourceTexture::External(external_id), None)
(SourceTexture::External(external_image), None)
}
None => {
let cache_item = resource_cache.get_cached_image(image_key, image_rendering, tile_offset);
@@ -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;
@@ -1039,10 +1039,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 +1193,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.");
@@ -1665,16 +1672,16 @@ 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_id = match image.source {
ExternalImageSource::NativeTexture(texture_id) => TextureId::new(texture_id),
_ => 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);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.