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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2939513002: color-profile-layer-filter.html issue (Closed)
Patch Set: Remove debugging info Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 // Whether a color matrix needs to be applied by the shaders when drawing 220 // Whether a color matrix needs to be applied by the shaders when drawing
221 // the RPDQ. 221 // the RPDQ.
222 bool use_color_matrix = false; 222 bool use_color_matrix = false;
223 223
224 gfx::QuadF surface_quad; 224 gfx::QuadF surface_quad;
225 225
226 gfx::Transform contents_device_transform; 226 gfx::Transform contents_device_transform;
227 227
228 gfx::RectF tex_coord_rect; 228 gfx::RectF tex_coord_rect;
229
230 // The color space of the texture bound for sampling (from filter_image or
231 // contents_resource_lock, depending on the path taken).
232 gfx::ColorSpace color_space;
229 }; 233 };
230 234
231 static GLint GetActiveTextureUnit(GLES2Interface* gl) { 235 static GLint GetActiveTextureUnit(GLES2Interface* gl) {
232 GLint active_unit = 0; 236 GLint active_unit = 0;
233 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 237 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
234 return active_unit; 238 return active_unit;
235 } 239 }
236 240
237 class GLRenderer::ScopedUseGrContext { 241 class GLRenderer::ScopedUseGrContext {
238 public: 242 public:
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 backend_texture_description.fTextureHandle = 647 backend_texture_description.fTextureHandle =
644 skia::GrGLTextureInfoToGrBackendObject(texture_info); 648 skia::GrGLTextureInfoToGrBackendObject(texture_info);
645 backend_texture_description.fOrigin = 649 backend_texture_description.fOrigin =
646 flip_texture ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; 650 flip_texture ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
647 651
648 return SkImage::MakeFromTexture(context, backend_texture_description); 652 return SkImage::MakeFromTexture(context, backend_texture_description);
649 } 653 }
650 654
651 static sk_sp<SkImage> ApplyImageFilter( 655 static sk_sp<SkImage> ApplyImageFilter(
652 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, 656 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
653 ResourceProvider* resource_provider,
654 const gfx::RectF& src_rect, 657 const gfx::RectF& src_rect,
655 const gfx::RectF& dst_rect, 658 const gfx::RectF& dst_rect,
656 const gfx::Vector2dF& scale, 659 const gfx::Vector2dF& scale,
657 sk_sp<SkImageFilter> filter, 660 sk_sp<SkImageFilter> filter,
658 const Resource* source_texture_resource, 661 const ResourceProvider::ScopedReadLockGL& source_texture_lock,
659 SkIPoint* offset, 662 SkIPoint* offset,
660 SkIRect* subset, 663 SkIRect* subset,
661 bool flip_texture, 664 bool flip_texture,
662 const gfx::PointF& origin) { 665 const gfx::PointF& origin) {
663 if (!filter || !use_gr_context) 666 if (!filter || !use_gr_context)
664 return nullptr; 667 return nullptr;
665 668
666 ResourceProvider::ScopedReadLockGL lock(resource_provider,
667 source_texture_resource->id());
668
669 sk_sp<SkImage> src_image = 669 sk_sp<SkImage> src_image =
670 WrapTexture(lock, use_gr_context->context(), flip_texture); 670 WrapTexture(source_texture_lock, use_gr_context->context(), flip_texture);
671 671
672 if (!src_image) { 672 if (!src_image) {
673 TRACE_EVENT_INSTANT0("cc", 673 TRACE_EVENT_INSTANT0("cc",
674 "ApplyImageFilter wrap background texture failed", 674 "ApplyImageFilter wrap background texture failed",
675 TRACE_EVENT_SCOPE_THREAD); 675 TRACE_EVENT_SCOPE_THREAD);
676 return nullptr; 676 return nullptr;
677 } 677 }
678 678
679 SkMatrix local_matrix; 679 SkMatrix local_matrix;
680 local_matrix.setTranslate(origin.x(), origin.y()); 680 local_matrix.setTranslate(origin.x(), origin.y());
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 const gfx::QuadF* clip_region) { 1037 const gfx::QuadF* clip_region) {
1038 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id); 1038 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id);
1039 DrawRenderPassDrawQuadParams params; 1039 DrawRenderPassDrawQuadParams params;
1040 params.quad = quad; 1040 params.quad = quad;
1041 params.clip_region = clip_region; 1041 params.clip_region = clip_region;
1042 params.window_matrix = current_frame()->window_matrix; 1042 params.window_matrix = current_frame()->window_matrix;
1043 params.projection_matrix = current_frame()->projection_matrix; 1043 params.projection_matrix = current_frame()->projection_matrix;
1044 params.tex_coord_rect = quad->tex_coord_rect; 1044 params.tex_coord_rect = quad->tex_coord_rect;
1045 if (bypass != render_pass_bypass_quads_.end()) { 1045 if (bypass != render_pass_bypass_quads_.end()) {
1046 TileDrawQuad* tile_quad = &bypass->second; 1046 TileDrawQuad* tile_quad = &bypass->second;
1047 // RGBA_8888 here is arbitrary and unused. 1047 // RGBA_8888 and the gfx::ColorSpace() here are arbitrary and unused.
1048 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size, 1048 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size,
1049 ResourceFormat::RGBA_8888, 1049 ResourceFormat::RGBA_8888, gfx::ColorSpace());
1050 current_frame()->current_render_pass->color_space);
1051 // The projection matrix used by GLRenderer has a flip. As tile texture 1050 // The projection matrix used by GLRenderer has a flip. As tile texture
1052 // inputs are oriented opposite to framebuffer outputs, don't flip via 1051 // inputs are oriented opposite to framebuffer outputs, don't flip via
1053 // texture coords and let the projection matrix naturallyd o it. 1052 // texture coords and let the projection matrix naturallyd o it.
1054 params.flip_texture = false; 1053 params.flip_texture = false;
1055 params.contents_texture = &tile_resource; 1054 params.contents_texture = &tile_resource;
1056 DrawRenderPassQuadInternal(&params); 1055 DrawRenderPassQuadInternal(&params);
1057 } else { 1056 } else {
1058 ScopedResource* contents_texture = 1057 ScopedResource* contents_texture =
1059 render_pass_textures_[quad->render_pass_id].get(); 1058 render_pass_textures_[quad->render_pass_id].get();
1060 DCHECK(contents_texture); 1059 DCHECK(contents_texture);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad); 1233 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad);
1235 params->dst_rect.Intersect(local_clip.BoundingBox()); 1234 params->dst_rect.Intersect(local_clip.BoundingBox());
1236 // If we've been fully clipped out (by crop rect or clipping), there's 1235 // If we've been fully clipped out (by crop rect or clipping), there's
1237 // nothing to draw. 1236 // nothing to draw.
1238 if (params->dst_rect.IsEmpty()) { 1237 if (params->dst_rect.IsEmpty()) {
1239 return false; 1238 return false;
1240 } 1239 }
1241 SkIPoint offset; 1240 SkIPoint offset;
1242 SkIRect subset; 1241 SkIRect subset;
1243 gfx::RectF src_rect(quad->rect); 1242 gfx::RectF src_rect(quad->rect);
1243
1244 ResourceProvider::ScopedReadLockGL prefilter_contents_texture_lock(
1245 resource_provider_, params->contents_texture->id());
1246 params->color_space = prefilter_contents_texture_lock.color_space();
1244 params->filter_image = ApplyImageFilter( 1247 params->filter_image = ApplyImageFilter(
1245 ScopedUseGrContext::Create(this), resource_provider_, src_rect, 1248 ScopedUseGrContext::Create(this), src_rect, params->dst_rect,
1246 params->dst_rect, quad->filters_scale, std::move(filter), 1249 quad->filters_scale, std::move(filter),
1247 params->contents_texture, &offset, &subset, params->flip_texture, 1250 prefilter_contents_texture_lock, &offset, &subset,
1248 quad->filters_origin); 1251 params->flip_texture, quad->filters_origin);
1249 if (!params->filter_image) 1252 if (!params->filter_image)
1250 return false; 1253 return false;
1251 params->dst_rect = 1254 params->dst_rect =
1252 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, 1255 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY,
1253 subset.width(), subset.height()); 1256 subset.width(), subset.height());
1254 params->src_offset.SetPoint(subset.x(), subset.y()); 1257 params->src_offset.SetPoint(subset.x(), subset.y());
1255 gfx::RectF tex_rect = gfx::RectF(gfx::PointF(params->src_offset), 1258 gfx::RectF tex_rect = gfx::RectF(gfx::PointF(params->src_offset),
1256 params->dst_rect.size()); 1259 params->dst_rect.size());
1257 params->tex_coord_rect = tex_rect; 1260 params->tex_coord_rect = tex_rect;
1258 } 1261 }
(...skipping 14 matching lines...) Expand all
1273 GrSurfaceOrigin origin; 1276 GrSurfaceOrigin origin;
1274 GLuint filter_image_id = 1277 GLuint filter_image_id =
1275 skia::GrBackendObjectToGrGLTextureInfo( 1278 skia::GrBackendObjectToGrGLTextureInfo(
1276 params->filter_image->getTextureHandle(true, &origin)) 1279 params->filter_image->getTextureHandle(true, &origin))
1277 ->fID; 1280 ->fID;
1278 DCHECK(filter_image_id); 1281 DCHECK(filter_image_id);
1279 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 1282 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
1280 gl_->BindTexture(GL_TEXTURE_2D, filter_image_id); 1283 gl_->BindTexture(GL_TEXTURE_2D, filter_image_id);
1281 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 1284 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1282 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 1285 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1283 1286 // |params->color_space| was populated when |prarams->filter_image| was
enne (OOO) 2017/06/12 22:18:00 typo This seems a little bit like making assumpti
ccameron 2017/06/12 23:24:27 Oop. Fixed. Yeah, I felt it was worth a comment f
1287 // populated.
1284 params->source_needs_flip = kBottomLeft_GrSurfaceOrigin == origin; 1288 params->source_needs_flip = kBottomLeft_GrSurfaceOrigin == origin;
1285 } else { 1289 } else {
1286 params->contents_resource_lock = 1290 params->contents_resource_lock =
1287 base::MakeUnique<ResourceProvider::ScopedSamplerGL>( 1291 base::MakeUnique<ResourceProvider::ScopedSamplerGL>(
1288 resource_provider_, params->contents_texture->id(), GL_LINEAR); 1292 resource_provider_, params->contents_texture->id(), GL_LINEAR);
1289 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1293 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1290 params->contents_resource_lock->target()); 1294 params->contents_resource_lock->target());
1295 params->color_space = params->contents_resource_lock->color_space();
1291 params->source_needs_flip = params->flip_texture; 1296 params->source_needs_flip = params->flip_texture;
1292 } 1297 }
1293 } 1298 }
1294 1299
1295 void GLRenderer::UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params) { 1300 void GLRenderer::UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params) {
1296 SkBlendMode blend_mode = params->quad->shared_quad_state->blend_mode; 1301 SkBlendMode blend_mode = params->quad->shared_quad_state->blend_mode;
1297 SetBlendEnabled(!params->use_shaders_for_blending && 1302 SetBlendEnabled(!params->use_shaders_for_blending &&
1298 (params->quad->ShouldDrawWithBlending() || 1303 (params->quad->ShouldDrawWithBlending() ||
1299 !IsDefaultBlendMode(blend_mode))); 1304 !IsDefaultBlendMode(blend_mode)));
1300 if (!params->use_shaders_for_blending) { 1305 if (!params->use_shaders_for_blending) {
(...skipping 15 matching lines...) Expand all
1316 : BLEND_MODE_NONE; 1321 : BLEND_MODE_NONE;
1317 1322
1318 SamplerType sampler_type = SAMPLER_TYPE_2D; 1323 SamplerType sampler_type = SAMPLER_TYPE_2D;
1319 MaskMode mask_mode = NO_MASK; 1324 MaskMode mask_mode = NO_MASK;
1320 bool mask_for_background = params->mask_for_background; 1325 bool mask_for_background = params->mask_for_background;
1321 if (params->mask_resource_lock) { 1326 if (params->mask_resource_lock) {
1322 mask_mode = HAS_MASK; 1327 mask_mode = HAS_MASK;
1323 sampler_type = 1328 sampler_type =
1324 SamplerTypeFromTextureTarget(params->mask_resource_lock->target()); 1329 SamplerTypeFromTextureTarget(params->mask_resource_lock->target());
1325 } 1330 }
1326
1327 SetUseProgram(ProgramKey::RenderPass( 1331 SetUseProgram(ProgramKey::RenderPass(
1328 tex_coord_precision, sampler_type, shader_blend_mode, 1332 tex_coord_precision, sampler_type, shader_blend_mode,
1329 params->use_aa ? USE_AA : NO_AA, mask_mode, 1333 params->use_aa ? USE_AA : NO_AA, mask_mode,
1330 mask_for_background, params->use_color_matrix), 1334 mask_for_background, params->use_color_matrix),
1331 params->contents_resource_lock 1335 params->color_space);
1332 ? params->contents_resource_lock->color_space()
1333 : gfx::ColorSpace());
1334 } 1336 }
1335 1337
1336 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { 1338 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
1337 gfx::RectF tex_rect = params->tex_coord_rect; 1339 gfx::RectF tex_rect = params->tex_coord_rect;
1338 1340
1339 gfx::Size texture_size; 1341 gfx::Size texture_size;
1340 if (params->filter_image) { 1342 if (params->filter_image) {
1341 texture_size.set_width(params->filter_image->width()); 1343 texture_size.set_width(params->filter_image->width());
1342 texture_size.set_height(params->filter_image->height()); 1344 texture_size.set_height(params->filter_image->height());
1343 } else { 1345 } else {
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 return; 3613 return;
3612 3614
3613 // Report GPU overdraw as a percentage of |max_result|. 3615 // Report GPU overdraw as a percentage of |max_result|.
3614 TRACE_COUNTER1( 3616 TRACE_COUNTER1(
3615 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3617 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3616 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3618 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3617 max_result); 3619 max_result);
3618 } 3620 }
3619 3621
3620 } // namespace cc 3622 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698