Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3348)

Unified Diff: cc/layers/texture_layer_impl.cc

Issue 558083002: [cc] Add nearest neighbor filtering for TextureLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add nearest_neighbor field to TextureMailbox. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layers/texture_layer_impl.cc
diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc
index bcde7cd49ecbac99591a787453cad6ea9a739cd2..cf47066993e7946d37b0dc49c6fdefb2c02f26a0 100644
--- a/cc/layers/texture_layer_impl.cc
+++ b/cc/layers/texture_layer_impl.cc
@@ -23,6 +23,7 @@ TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl, int id)
premultiplied_alpha_(true),
blend_background_color_(false),
flipped_(true),
+ nearest_neighbor_(false),
uv_top_left_(0.f, 0.f),
uv_bottom_right_(1.f, 1.f),
own_mailbox_(false),
@@ -62,6 +63,7 @@ void TextureLayerImpl::PushPropertiesTo(LayerImpl* layer) {
texture_layer->SetVertexOpacity(vertex_opacity_);
texture_layer->SetPremultipliedAlpha(premultiplied_alpha_);
texture_layer->SetBlendBackgroundColor(blend_background_color_);
+ texture_layer->SetNearestNeighbor(nearest_neighbor_);
if (own_mailbox_) {
texture_layer->SetTextureMailbox(texture_mailbox_,
release_callback_.Pass());
@@ -101,9 +103,12 @@ bool TextureLayerImpl::WillDraw(DrawMode draw_mode,
resource_provider->InUseByConsumer(texture_copy_->id()))
texture_copy_->Free();
+ //if (nearest_neighbor_)
+ //texture_copy_->filter = GL_NEAREST;
+
if (!texture_copy_->id()) {
texture_copy_->Allocate(texture_mailbox_.shared_memory_size(),
- ResourceProvider::TextureHintImmutable,
+ ResourceProvider::TextureHintDefault,
piman 2014/10/28 05:09:50 Why changing this? (and other places) Immutability
jackhou1 2014/10/29 00:12:25 Oops, I wasn't sure if this mattered. Removed.
resource_provider->best_texture_format());
}
@@ -135,8 +140,10 @@ bool TextureLayerImpl::WillDraw(DrawMode draw_mode,
valid_texture_copy_ = true;
}
}
- return (external_texture_resource_ || valid_texture_copy_) &&
+ bool result = (external_texture_resource_ || valid_texture_copy_) &&
LayerImpl::WillDraw(draw_mode, resource_provider);
+ //printf("TextureLayerImpl::WillDraw %d %p\n", result, this);
+ return result;
}
void TextureLayerImpl::AppendQuads(RenderPass* render_pass,
@@ -166,6 +173,8 @@ void TextureLayerImpl::AppendQuads(RenderPass* render_pass,
render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
ResourceProvider::ResourceId id =
valid_texture_copy_ ? texture_copy_->id() : external_texture_resource_;
+
+ //printf("TextureLayerImpl::AppendQuads %d %d %p\n", nearest_neighbor_, id, this);
quad->SetNew(shared_quad_state,
quad_rect,
opaque_rect,
@@ -176,7 +185,8 @@ void TextureLayerImpl::AppendQuads(RenderPass* render_pass,
uv_bottom_right_,
bg_color,
vertex_opacity_,
- flipped_);
+ flipped_,
+ nearest_neighbor_);
}
SimpleEnclosedRegion TextureLayerImpl::VisibleContentOpaqueRegion() const {
@@ -211,6 +221,12 @@ void TextureLayerImpl::SetFlipped(bool flipped) {
SetNeedsPushProperties();
}
+void TextureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) {
+ //printf("TextureLayerImpl::SetNearestNeighbor %d %p\n", nearest_neighbor, this);
+ nearest_neighbor_ = nearest_neighbor;
+ SetNeedsPushProperties();
+}
+
void TextureLayerImpl::SetUVTopLeft(const gfx::PointF top_left) {
uv_top_left_ = top_left;
SetNeedsPushProperties();

Powered by Google App Engine
This is Rietveld 408576698