OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 // Use anti-aliasing programs only when necessary. | 1163 // Use anti-aliasing programs only when necessary. |
1164 bool use_aa = | 1164 bool use_aa = |
1165 !clipped && (!device_quad.IsRectilinear() || | 1165 !clipped && (!device_quad.IsRectilinear() || |
1166 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(), | 1166 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(), |
1167 kAntiAliasingEpsilon)); | 1167 kAntiAliasingEpsilon)); |
1168 if (use_aa) { | 1168 if (use_aa) { |
1169 device_layer_bounds.InflateAntiAliasingDistance(); | 1169 device_layer_bounds.InflateAntiAliasingDistance(); |
1170 device_layer_edges.InflateAntiAliasingDistance(); | 1170 device_layer_edges.InflateAntiAliasingDistance(); |
1171 } | 1171 } |
1172 | 1172 |
1173 scoped_ptr<ResourceProvider::ScopedReadLockGL> mask_resource_lock; | 1173 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; |
1174 unsigned mask_texture_id = 0; | 1174 unsigned mask_texture_id = 0; |
1175 SamplerType mask_sampler = SamplerTypeNA; | |
1175 if (quad->mask_resource_id) { | 1176 if (quad->mask_resource_id) { |
1176 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( | 1177 mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL( |
1177 resource_provider_, quad->mask_resource_id)); | 1178 resource_provider_, quad->mask_resource_id, GL_TEXTURE1, GL_LINEAR)); |
1178 mask_texture_id = mask_resource_lock->texture_id(); | 1179 mask_texture_id = mask_resource_lock->texture_id(); |
1180 mask_sampler = SamplerTypeFromTextureTarget(mask_resource_lock->target()); | |
danakj
2014/10/15 15:33:35
this variable exists only for DCHECK? do the looku
enne (OOO)
2014/10/15 19:10:54
Sure, for now. In the next patch for adding suppo
| |
1179 } | 1181 } |
1180 | 1182 |
1181 // TODO(danakj): use the background_texture and blend the background in with | 1183 // TODO(danakj): use the background_texture and blend the background in with |
1182 // this draw instead of having a separate copy of the background texture. | 1184 // this draw instead of having a separate copy of the background texture. |
1183 | 1185 |
1184 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; | 1186 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; |
1185 if (filter_bitmap) { | 1187 if (filter_bitmap) { |
1186 GrTexture* texture = filter_bitmap->getTexture(); | 1188 GrTexture* texture = filter_bitmap->getTexture(); |
1187 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 1189 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
1188 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 1190 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1363 gl_->Uniform4f(shader_tex_transform_location, | 1365 gl_->Uniform4f(shader_tex_transform_location, |
1364 0.0f, | 1366 0.0f, |
1365 tex_scale_y, | 1367 tex_scale_y, |
1366 tex_scale_x, | 1368 tex_scale_x, |
1367 -tex_scale_y)); | 1369 -tex_scale_y)); |
1368 | 1370 |
1369 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; | 1371 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; |
1370 if (shader_mask_sampler_location != -1) { | 1372 if (shader_mask_sampler_location != -1) { |
1371 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); | 1373 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); |
1372 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); | 1374 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); |
1375 DCHECK_EQ(SamplerType2D, mask_sampler); | |
1373 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); | 1376 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); |
1374 | 1377 |
1375 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x; | 1378 gfx::RectF mask_uv_rect = quad->mask_uv_rect(); |
1376 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y; | |
1377 | 1379 |
1378 // Mask textures are oriented vertically flipped relative to the framebuffer | |
danakj
2014/10/15 15:33:35
what happened to this?
enne (OOO)
2014/10/15 19:10:54
OOPS
| |
1379 // and the RenderPass contents texture, so we flip the tex coords from the | 1380 // and the RenderPass contents texture, so we flip the tex coords from the |
1380 // RenderPass texture to find the mask texture coords. | 1381 // RenderPass texture to find the mask texture coords. |
1381 GLC(gl_, | 1382 GLC(gl_, |
1382 gl_->Uniform2f(shader_mask_tex_coord_offset_location, | 1383 gl_->Uniform2f(shader_mask_tex_coord_offset_location, |
1383 quad->mask_uv_rect.x(), | 1384 mask_uv_rect.x(), |
1384 quad->mask_uv_rect.y() + quad->mask_uv_rect.height())); | 1385 mask_uv_rect.bottom())); |
1385 GLC(gl_, | 1386 GLC(gl_, |
1386 gl_->Uniform2f(shader_mask_tex_coord_scale_location, | 1387 gl_->Uniform2f(shader_mask_tex_coord_scale_location, |
1387 mask_tex_scale_x, | 1388 mask_uv_rect.width() / tex_scale_x, |
1388 -mask_tex_scale_y)); | 1389 -mask_uv_rect.height() / tex_scale_y)); |
1389 shader_mask_sampler_lock = make_scoped_ptr( | |
1390 new ResourceProvider::ScopedSamplerGL(resource_provider_, | |
1391 quad->mask_resource_id, | |
1392 GL_TEXTURE1, | |
1393 GL_LINEAR)); | |
1394 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | |
1395 shader_mask_sampler_lock->target()); | |
1396 } | 1390 } |
1397 | 1391 |
1398 if (shader_edge_location != -1) { | 1392 if (shader_edge_location != -1) { |
1399 float edge[24]; | 1393 float edge[24]; |
1400 device_layer_edges.ToFloatArray(edge); | 1394 device_layer_edges.ToFloatArray(edge); |
1401 device_layer_bounds.ToFloatArray(&edge[12]); | 1395 device_layer_bounds.ToFloatArray(&edge[12]); |
1402 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge)); | 1396 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge)); |
1403 } | 1397 } |
1404 | 1398 |
1405 if (shader_viewport_location != -1) { | 1399 if (shader_viewport_location != -1) { |
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3283 context_support_->ScheduleOverlayPlane( | 3277 context_support_->ScheduleOverlayPlane( |
3284 overlay.plane_z_order, | 3278 overlay.plane_z_order, |
3285 overlay.transform, | 3279 overlay.transform, |
3286 pending_overlay_resources_.back()->texture_id(), | 3280 pending_overlay_resources_.back()->texture_id(), |
3287 overlay.display_rect, | 3281 overlay.display_rect, |
3288 overlay.uv_rect); | 3282 overlay.uv_rect); |
3289 } | 3283 } |
3290 } | 3284 } |
3291 | 3285 |
3292 } // namespace cc | 3286 } // namespace cc |
OLD | NEW |