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

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

Issue 2203033005: Remove references to DrawingFrame from RenderPassDrawQuad drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp58_continue_rpdq_refactor
Patch Set: Rebase. Created 4 years, 4 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 | « cc/output/gl_renderer.h ('k') | no next file » | 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Block or crash if the number of pending sync queries reach this high as 149 // Block or crash if the number of pending sync queries reach this high as
150 // something is seriously wrong on the service side if this happens. 150 // something is seriously wrong on the service side if this happens.
151 const size_t kMaxPendingSyncQueries = 16; 151 const size_t kMaxPendingSyncQueries = 16;
152 } // anonymous namespace 152 } // anonymous namespace
153 153
154 // Parameters needed to draw a RenderPassDrawQuad. 154 // Parameters needed to draw a RenderPassDrawQuad.
155 struct DrawRenderPassDrawQuadParams { 155 struct DrawRenderPassDrawQuadParams {
156 DrawRenderPassDrawQuadParams() {} 156 DrawRenderPassDrawQuadParams() {}
157 ~DrawRenderPassDrawQuadParams() {} 157 ~DrawRenderPassDrawQuadParams() {}
158 158
159 // Inputs. 159 // Required Inputs.
160 const RenderPassDrawQuad* quad = nullptr; 160 const RenderPassDrawQuad* quad = nullptr;
161 const Resource* contents_texture = nullptr; 161 const Resource* contents_texture = nullptr;
162 DirectRenderer::DrawingFrame* frame = nullptr;
163 const gfx::QuadF* clip_region = nullptr; 162 const gfx::QuadF* clip_region = nullptr;
164 bool flip_texture = false; 163 bool flip_texture = false;
165 164
165 gfx::Transform window_matrix;
166 gfx::Transform projection_matrix;
167
168 // |frame| is needed for background effects.
169 DirectRenderer::DrawingFrame* frame = nullptr;
170
166 // Whether the texture to be sampled from needs to be flipped. 171 // Whether the texture to be sampled from needs to be flipped.
167 bool source_needs_flip = false; 172 bool source_needs_flip = false;
168 173
169 float edge[24]; 174 float edge[24];
170 SkScalar color_matrix[20]; 175 SkScalar color_matrix[20];
171 176
172 // Blending refers to modifications to the backdrop. 177 // Blending refers to modifications to the backdrop.
173 bool use_shaders_for_blending = false; 178 bool use_shaders_for_blending = false;
174 ShaderLocations locations; 179 ShaderLocations locations;
175 180
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 }; 220 };
216 221
217 static GLint GetActiveTextureUnit(GLES2Interface* gl) { 222 static GLint GetActiveTextureUnit(GLES2Interface* gl) {
218 GLint active_unit = 0; 223 GLint active_unit = 0;
219 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 224 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
220 return active_unit; 225 return active_unit;
221 } 226 }
222 227
223 class GLRenderer::ScopedUseGrContext { 228 class GLRenderer::ScopedUseGrContext {
224 public: 229 public:
225 static std::unique_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, 230 static std::unique_ptr<ScopedUseGrContext> Create(GLRenderer* renderer) {
226 DrawingFrame* frame) {
227 // GrContext for filters is created lazily, and may fail if the context 231 // GrContext for filters is created lazily, and may fail if the context
228 // is lost. 232 // is lost.
229 // TODO(vmiura,bsalomon): crbug.com/487850 Ensure that 233 // TODO(vmiura,bsalomon): crbug.com/487850 Ensure that
230 // ContextProvider::GrContext() does not return NULL. 234 // ContextProvider::GrContext() does not return NULL.
231 if (renderer->output_surface_->context_provider()->GrContext()) 235 if (renderer->output_surface_->context_provider()->GrContext())
232 return base::WrapUnique(new ScopedUseGrContext(renderer, frame)); 236 return base::WrapUnique(new ScopedUseGrContext(renderer));
233 return nullptr; 237 return nullptr;
234 } 238 }
235 239
236 ~ScopedUseGrContext() { 240 ~ScopedUseGrContext() {
237 // Pass context control back to GLrenderer. 241 // Pass context control back to GLrenderer.
238 scoped_gpu_raster_ = nullptr; 242 scoped_gpu_raster_ = nullptr;
239 renderer_->RestoreGLState(); 243 renderer_->RestoreGLState();
240 renderer_->RestoreFramebuffer(frame_);
241 } 244 }
242 245
243 GrContext* context() const { 246 GrContext* context() const {
244 return renderer_->output_surface_->context_provider()->GrContext(); 247 return renderer_->output_surface_->context_provider()->GrContext();
245 } 248 }
246 249
247 private: 250 private:
248 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame) 251 explicit ScopedUseGrContext(GLRenderer* renderer)
249 : scoped_gpu_raster_( 252 : scoped_gpu_raster_(
250 new ScopedGpuRaster(renderer->output_surface_->context_provider())), 253 new ScopedGpuRaster(renderer->output_surface_->context_provider())),
251 renderer_(renderer), 254 renderer_(renderer) {
252 frame_(frame) {
253 // scoped_gpu_raster_ passes context control to Skia. 255 // scoped_gpu_raster_ passes context control to Skia.
254 } 256 }
255 257
256 std::unique_ptr<ScopedGpuRaster> scoped_gpu_raster_; 258 std::unique_ptr<ScopedGpuRaster> scoped_gpu_raster_;
257 GLRenderer* renderer_; 259 GLRenderer* renderer_;
258 DrawingFrame* frame_;
259 260
260 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext); 261 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext);
261 }; 262 };
262 263
263 struct GLRenderer::PendingAsyncReadPixels { 264 struct GLRenderer::PendingAsyncReadPixels {
264 PendingAsyncReadPixels() : buffer(0) {} 265 PendingAsyncReadPixels() : buffer(0) {}
265 266
266 std::unique_ptr<CopyOutputRequest> copy_request; 267 std::unique_ptr<CopyOutputRequest> copy_request;
267 base::CancelableClosure finished_read_pixels_callback; 268 base::CancelableClosure finished_read_pixels_callback;
268 unsigned buffer; 269 unsigned buffer;
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 resource_provider_->best_texture_format()); 904 resource_provider_->best_texture_format());
904 { 905 {
905 ResourceProvider::ScopedWriteLockGL lock( 906 ResourceProvider::ScopedWriteLockGL lock(
906 resource_provider_, device_background_texture->id(), false); 907 resource_provider_, device_background_texture->id(), false);
907 GetFramebufferTexture(lock.texture_id(), bounding_rect); 908 GetFramebufferTexture(lock.texture_id(), bounding_rect);
908 } 909 }
909 return device_background_texture; 910 return device_background_texture;
910 } 911 }
911 912
912 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( 913 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters(
913 DrawingFrame* frame,
914 const RenderPassDrawQuad* quad, 914 const RenderPassDrawQuad* quad,
915 ScopedResource* background_texture, 915 ScopedResource* background_texture,
916 const gfx::RectF& rect) { 916 const gfx::RectF& rect) {
917 DCHECK(ShouldApplyBackgroundFilters(quad)); 917 DCHECK(ShouldApplyBackgroundFilters(quad));
918 auto use_gr_context = ScopedUseGrContext::Create(this, frame); 918 auto use_gr_context = ScopedUseGrContext::Create(this);
919 sk_sp<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 919 sk_sp<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
920 quad->background_filters, gfx::SizeF(background_texture->size())); 920 quad->background_filters, gfx::SizeF(background_texture->size()));
921 921
922 // TODO(senorblanco): background filters should be moved to the 922 // TODO(senorblanco): background filters should be moved to the
923 // makeWithFilter fast-path, and go back to calling ApplyImageFilter(). 923 // makeWithFilter fast-path, and go back to calling ApplyImageFilter().
924 // See http://crbug.com/613233. 924 // See http://crbug.com/613233.
925 if (!filter || !use_gr_context) 925 if (!filter || !use_gr_context)
926 return nullptr; 926 return nullptr;
927 927
928 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 928 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 } 1032 }
1033 1033
1034 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 1034 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
1035 const RenderPassDrawQuad* quad, 1035 const RenderPassDrawQuad* quad,
1036 const gfx::QuadF* clip_region) { 1036 const gfx::QuadF* clip_region) {
1037 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id); 1037 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id);
1038 DrawRenderPassDrawQuadParams params; 1038 DrawRenderPassDrawQuadParams params;
1039 params.quad = quad; 1039 params.quad = quad;
1040 params.frame = frame; 1040 params.frame = frame;
1041 params.clip_region = clip_region; 1041 params.clip_region = clip_region;
1042 params.window_matrix = frame->window_matrix;
1043 params.projection_matrix = frame->projection_matrix;
1042 if (bypass != render_pass_bypass_quads_.end()) { 1044 if (bypass != render_pass_bypass_quads_.end()) {
1043 TileDrawQuad* tile_quad = &bypass->second; 1045 TileDrawQuad* tile_quad = &bypass->second;
1044 // RGBA_8888 here is arbitrary and unused. 1046 // RGBA_8888 here is arbitrary and unused.
1045 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size, 1047 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size,
1046 ResourceFormat::RGBA_8888); 1048 ResourceFormat::RGBA_8888);
1047 // The projection matrix used by GLRenderer has a flip. As tile texture 1049 // The projection matrix used by GLRenderer has a flip. As tile texture
1048 // inputs are oriented opposite to framebuffer outputs, don't flip via 1050 // inputs are oriented opposite to framebuffer outputs, don't flip via
1049 // texture coords and let the projection matrix naturallyd o it. 1051 // texture coords and let the projection matrix naturallyd o it.
1050 params.flip_texture = false; 1052 params.flip_texture = false;
1051 params.contents_texture = &tile_resource; 1053 params.contents_texture = &tile_resource;
(...skipping 11 matching lines...) Expand all
1063 } 1065 }
1064 } 1066 }
1065 1067
1066 void GLRenderer::DrawRenderPassQuadInternal( 1068 void GLRenderer::DrawRenderPassQuadInternal(
1067 DrawRenderPassDrawQuadParams* params) { 1069 DrawRenderPassDrawQuadParams* params) {
1068 if (!InitializeRPDQParameters(params)) 1070 if (!InitializeRPDQParameters(params))
1069 return; 1071 return;
1070 UpdateRPDQShadersForBlending(params); 1072 UpdateRPDQShadersForBlending(params);
1071 if (!UpdateRPDQWithSkiaFilters(params)) 1073 if (!UpdateRPDQWithSkiaFilters(params))
1072 return; 1074 return;
1075 UseRenderPass(params->frame, params->frame->current_render_pass);
1076 SetViewport();
1073 UpdateRPDQTexturesForSampling(params); 1077 UpdateRPDQTexturesForSampling(params);
1074 UpdateRPDQBlendMode(params); 1078 UpdateRPDQBlendMode(params);
1075 ChooseRPDQProgram(params); 1079 ChooseRPDQProgram(params);
1076 UpdateRPDQUniforms(params); 1080 UpdateRPDQUniforms(params);
1077 DrawRPDQ(*params); 1081 DrawRPDQ(*params);
1078 } 1082 }
1079 1083
1080 bool GLRenderer::InitializeRPDQParameters( 1084 bool GLRenderer::InitializeRPDQParameters(
1081 DrawRenderPassDrawQuadParams* params) { 1085 DrawRenderPassDrawQuadParams* params) {
1082 const RenderPassDrawQuad* quad = params->quad; 1086 const RenderPassDrawQuad* quad = params->quad;
1083 SkMatrix scale_matrix; 1087 SkMatrix scale_matrix;
1084 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y()); 1088 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y());
1085 gfx::Rect dst_rect = quad->filters.MapRect(quad->rect, scale_matrix); 1089 gfx::Rect dst_rect = quad->filters.MapRect(quad->rect, scale_matrix);
1086 params->dst_rect.SetRect(static_cast<float>(dst_rect.x()), 1090 params->dst_rect.SetRect(static_cast<float>(dst_rect.x()),
1087 static_cast<float>(dst_rect.y()), 1091 static_cast<float>(dst_rect.y()),
1088 static_cast<float>(dst_rect.width()), 1092 static_cast<float>(dst_rect.width()),
1089 static_cast<float>(dst_rect.height())); 1093 static_cast<float>(dst_rect.height()));
1090 gfx::Transform quad_rect_matrix; 1094 gfx::Transform quad_rect_matrix;
1091 QuadRectTransform(&quad_rect_matrix, 1095 QuadRectTransform(&quad_rect_matrix,
1092 quad->shared_quad_state->quad_to_target_transform, 1096 quad->shared_quad_state->quad_to_target_transform,
1093 params->dst_rect); 1097 params->dst_rect);
1094 params->contents_device_transform = params->frame->window_matrix * 1098 params->contents_device_transform =
1095 params->frame->projection_matrix * 1099 params->window_matrix * params->projection_matrix * quad_rect_matrix;
1096 quad_rect_matrix;
1097 params->contents_device_transform.FlattenTo2d(); 1100 params->contents_device_transform.FlattenTo2d();
1098 1101
1099 // Can only draw surface if device matrix is invertible. 1102 // Can only draw surface if device matrix is invertible.
1100 if (!params->contents_device_transform.IsInvertible()) 1103 if (!params->contents_device_transform.IsInvertible())
1101 return false; 1104 return false;
1102 1105
1103 params->surface_quad = SharedGeometryQuad(); 1106 params->surface_quad = SharedGeometryQuad();
1104 1107
1105 gfx::QuadF device_layer_quad; 1108 gfx::QuadF device_layer_quad;
1106 if (settings_->allow_antialiasing) { 1109 if (settings_->allow_antialiasing) {
(...skipping 15 matching lines...) Expand all
1122 void GLRenderer::UpdateRPDQShadersForBlending( 1125 void GLRenderer::UpdateRPDQShadersForBlending(
1123 DrawRenderPassDrawQuadParams* params) { 1126 DrawRenderPassDrawQuadParams* params) {
1124 const RenderPassDrawQuad* quad = params->quad; 1127 const RenderPassDrawQuad* quad = params->quad;
1125 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; 1128 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
1126 params->use_shaders_for_blending = 1129 params->use_shaders_for_blending =
1127 !CanApplyBlendModeUsingBlendFunc(blend_mode) || 1130 !CanApplyBlendModeUsingBlendFunc(blend_mode) ||
1128 ShouldApplyBackgroundFilters(quad) || 1131 ShouldApplyBackgroundFilters(quad) ||
1129 settings_->force_blending_with_shaders; 1132 settings_->force_blending_with_shaders;
1130 1133
1131 if (params->use_shaders_for_blending) { 1134 if (params->use_shaders_for_blending) {
1135 DCHECK(params->frame);
1132 // Compute a bounding box around the pixels that will be visible through 1136 // Compute a bounding box around the pixels that will be visible through
1133 // the quad. 1137 // the quad.
1134 params->background_rect = GetBackdropBoundingBoxForRenderPassQuad( 1138 params->background_rect = GetBackdropBoundingBoxForRenderPassQuad(
1135 params->frame, quad, params->contents_device_transform, 1139 params->frame, quad, params->contents_device_transform,
1136 params->clip_region, params->use_aa); 1140 params->clip_region, params->use_aa);
1137 1141
1138 if (!params->background_rect.IsEmpty()) { 1142 if (!params->background_rect.IsEmpty()) {
1139 // The pixels from the filtered background should completely replace the 1143 // The pixels from the filtered background should completely replace the
1140 // current pixel values. 1144 // current pixel values.
1141 if (blend_enabled()) 1145 if (blend_enabled())
1142 SetBlendEnabled(false); 1146 SetBlendEnabled(false);
1143 1147
1144 // Read the pixels in the bounding box into a buffer R. 1148 // Read the pixels in the bounding box into a buffer R.
1145 // This function allocates a texture, which should contribute to the 1149 // This function allocates a texture, which should contribute to the
1146 // amount of memory used by render surfaces: 1150 // amount of memory used by render surfaces:
1147 // LayerTreeHost::CalculateMemoryForRenderSurfaces. 1151 // LayerTreeHost::CalculateMemoryForRenderSurfaces.
1148 params->background_texture = GetBackdropTexture(params->background_rect); 1152 params->background_texture = GetBackdropTexture(params->background_rect);
1149 1153
1150 if (ShouldApplyBackgroundFilters(quad) && params->background_texture) { 1154 if (ShouldApplyBackgroundFilters(quad) && params->background_texture) {
1151 // Apply the background filters to R, so that it is applied in the 1155 // Apply the background filters to R, so that it is applied in the
1152 // pixels' coordinate space. 1156 // pixels' coordinate space.
1153 params->background_image = ApplyBackgroundFilters( 1157 params->background_image =
1154 params->frame, quad, params->background_texture.get(), 1158 ApplyBackgroundFilters(quad, params->background_texture.get(),
1155 gfx::RectF(params->background_rect)); 1159 gfx::RectF(params->background_rect));
1156 if (params->background_image) { 1160 if (params->background_image) {
1157 params->background_image_id = 1161 params->background_image_id =
1158 skia::GrBackendObjectToGrGLTextureInfo( 1162 skia::GrBackendObjectToGrGLTextureInfo(
1159 params->background_image->getTextureHandle(true)) 1163 params->background_image->getTextureHandle(true))
1160 ->fID; 1164 ->fID;
1161 DCHECK(params->background_image_id); 1165 DCHECK(params->background_image_id);
1162 } 1166 }
1163 } 1167 }
1164 } 1168 }
1165 1169
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 params->dst_rect.Intersect(local_clip.BoundingBox()); 1223 params->dst_rect.Intersect(local_clip.BoundingBox());
1220 // If we've been fully clipped out (by crop rect or clipping), there's 1224 // If we've been fully clipped out (by crop rect or clipping), there's
1221 // nothing to draw. 1225 // nothing to draw.
1222 if (params->dst_rect.IsEmpty()) { 1226 if (params->dst_rect.IsEmpty()) {
1223 return false; 1227 return false;
1224 } 1228 }
1225 SkIPoint offset; 1229 SkIPoint offset;
1226 SkIRect subset; 1230 SkIRect subset;
1227 gfx::RectF src_rect(quad->rect); 1231 gfx::RectF src_rect(quad->rect);
1228 params->filter_image = ApplyImageFilter( 1232 params->filter_image = ApplyImageFilter(
1229 ScopedUseGrContext::Create(this, params->frame), resource_provider_, 1233 ScopedUseGrContext::Create(this), resource_provider_, src_rect,
1230 src_rect, params->dst_rect, quad->filters_scale, std::move(filter), 1234 params->dst_rect, quad->filters_scale, std::move(filter),
1231 params->contents_texture, &offset, &subset, params->flip_texture); 1235 params->contents_texture, &offset, &subset, params->flip_texture);
1232 if (!params->filter_image) 1236 if (!params->filter_image)
1233 return false; 1237 return false;
1234 params->dst_rect = 1238 params->dst_rect =
1235 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, 1239 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY,
1236 subset.width(), subset.height()); 1240 subset.width(), subset.height());
1237 params->src_offset.SetPoint(subset.x(), subset.y()); 1241 params->src_offset.SetPoint(subset.x(), subset.y());
1238 } 1242 }
1239 } 1243 }
1240 } 1244 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1491 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1488 params->shader_background_sampler_lock->target()); 1492 params->shader_background_sampler_lock->target());
1489 } 1493 }
1490 } 1494 }
1491 1495
1492 SetShaderOpacity(params->quad->shared_quad_state->opacity, locations.alpha); 1496 SetShaderOpacity(params->quad->shared_quad_state->opacity, locations.alpha);
1493 SetShaderQuadF(params->surface_quad, locations.quad); 1497 SetShaderQuadF(params->surface_quad, locations.quad);
1494 } 1498 }
1495 1499
1496 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) { 1500 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) {
1497 DrawQuadGeometry(params.frame, 1501 DrawQuadGeometry(params.projection_matrix,
1498 params.quad->shared_quad_state->quad_to_target_transform, 1502 params.quad->shared_quad_state->quad_to_target_transform,
1499 params.dst_rect, params.locations.matrix); 1503 params.dst_rect, params.locations.matrix);
1500 1504
1501 // Flush the compositor context before the filter bitmap goes out of 1505 // Flush the compositor context before the filter bitmap goes out of
1502 // scope, so the draw gets processed before the filter texture gets deleted. 1506 // scope, so the draw gets processed before the filter texture gets deleted.
1503 if (params.filter_image) 1507 if (params.filter_image)
1504 gl_->Flush(); 1508 gl_->Flush();
1505 1509
1506 if (!params.use_shaders_for_blending) 1510 if (!params.use_shaders_for_blending)
1507 RestoreBlendFuncToDefault(params.quad->shared_quad_state->blend_mode); 1511 RestoreBlendFuncToDefault(params.quad->shared_quad_state->blend_mode);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 SetShaderQuadF(local_quad, uniforms.quad_location); 1872 SetShaderQuadF(local_quad, uniforms.quad_location);
1869 1873
1870 // The transform and vertex data are used to figure out the extents that the 1874 // The transform and vertex data are used to figure out the extents that the
1871 // un-antialiased quad should have and which vertex this is and the float 1875 // un-antialiased quad should have and which vertex this is and the float
1872 // quad passed in via uniform is the actual geometry that gets used to draw 1876 // quad passed in via uniform is the actual geometry that gets used to draw
1873 // it. This is why this centered rect is used and not the original 1877 // it. This is why this centered rect is used and not the original
1874 // quad_rect. 1878 // quad_rect.
1875 gfx::RectF centered_rect( 1879 gfx::RectF centered_rect(
1876 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1880 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1877 gfx::SizeF(tile_rect.size())); 1881 gfx::SizeF(tile_rect.size()));
1878 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 1882 DrawQuadGeometry(frame->projection_matrix,
1883 quad->shared_quad_state->quad_to_target_transform,
1879 centered_rect, uniforms.matrix_location); 1884 centered_rect, uniforms.matrix_location);
1880 } else { 1885 } else {
1881 PrepareGeometry(SHARED_BINDING); 1886 PrepareGeometry(SHARED_BINDING);
1882 SetShaderQuadF(local_quad, uniforms.quad_location); 1887 SetShaderQuadF(local_quad, uniforms.quad_location);
1883 static float gl_matrix[16]; 1888 static float gl_matrix[16];
1884 ToGLMatrix(&gl_matrix[0], 1889 ToGLMatrix(&gl_matrix[0],
1885 frame->projection_matrix * 1890 frame->projection_matrix *
1886 quad->shared_quad_state->quad_to_target_transform); 1891 quad->shared_quad_state->quad_to_target_transform);
1887 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]); 1892 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]);
1888 1893
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location); 2072 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location);
2068 SetShaderQuadF(local_quad, uniforms.quad_location); 2073 SetShaderQuadF(local_quad, uniforms.quad_location);
2069 2074
2070 // The transform and vertex data are used to figure out the extents that the 2075 // The transform and vertex data are used to figure out the extents that the
2071 // un-antialiased quad should have and which vertex this is and the float 2076 // un-antialiased quad should have and which vertex this is and the float
2072 // quad passed in via uniform is the actual geometry that gets used to draw 2077 // quad passed in via uniform is the actual geometry that gets used to draw
2073 // it. This is why this centered rect is used and not the original quad_rect. 2078 // it. This is why this centered rect is used and not the original quad_rect.
2074 gfx::RectF centered_rect( 2079 gfx::RectF centered_rect(
2075 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 2080 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
2076 gfx::SizeF(tile_rect.size())); 2081 gfx::SizeF(tile_rect.size()));
2077 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2082 DrawQuadGeometry(frame->projection_matrix,
2083 quad->shared_quad_state->quad_to_target_transform,
2078 centered_rect, uniforms.matrix_location); 2084 centered_rect, uniforms.matrix_location);
2079 } 2085 }
2080 2086
2081 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, 2087 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame,
2082 const ContentDrawQuadBase* quad, 2088 const ContentDrawQuadBase* quad,
2083 ResourceId resource_id, 2089 ResourceId resource_id,
2084 const gfx::QuadF* clip_region) { 2090 const gfx::QuadF* clip_region) {
2085 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 2091 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
2086 quad->tex_coord_rect, gfx::RectF(quad->rect), 2092 quad->tex_coord_rect, gfx::RectF(quad->rect),
2087 gfx::RectF(quad->visible_rect)); 2093 gfx::RectF(quad->visible_rect));
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2385 // The transform and vertex data are used to figure out the extents that the 2391 // The transform and vertex data are used to figure out the extents that the
2386 // un-antialiased quad should have and which vertex this is and the float 2392 // un-antialiased quad should have and which vertex this is and the float
2387 // quad passed in via uniform is the actual geometry that gets used to draw 2393 // quad passed in via uniform is the actual geometry that gets used to draw
2388 // it. This is why this centered rect is used and not the original quad_rect. 2394 // it. This is why this centered rect is used and not the original quad_rect.
2389 auto tile_rect = gfx::RectF(quad->rect); 2395 auto tile_rect = gfx::RectF(quad->rect);
2390 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb_multiplied); 2396 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb_multiplied);
2391 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust_with_offset); 2397 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust_with_offset);
2392 2398
2393 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); 2399 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location);
2394 if (!clip_region) { 2400 if (!clip_region) {
2395 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2401 DrawQuadGeometry(frame->projection_matrix,
2402 quad->shared_quad_state->quad_to_target_transform,
2396 tile_rect, matrix_location); 2403 tile_rect, matrix_location);
2397 } else { 2404 } else {
2398 float uvs[8] = {0}; 2405 float uvs[8] = {0};
2399 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2406 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2400 gfx::QuadF region_quad = *clip_region; 2407 gfx::QuadF region_quad = *clip_region;
2401 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 2408 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
2402 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2409 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2403 DrawQuadGeometryClippedByQuadF( 2410 DrawQuadGeometryClippedByQuadF(
2404 frame, quad->shared_quad_state->quad_to_target_transform, tile_rect, 2411 frame, quad->shared_quad_state->quad_to_target_transform, tile_rect,
2405 region_quad, matrix_location, uvs); 2412 region_quad, matrix_location, uvs);
(...skipping 26 matching lines...) Expand all
2432 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); 2439 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id());
2433 2440
2434 gl_->UniformMatrix4fvStreamTextureMatrixCHROMIUM( 2441 gl_->UniformMatrix4fvStreamTextureMatrixCHROMIUM(
2435 program->vertex_shader().tex_matrix_location(), false, gl_matrix); 2442 program->vertex_shader().tex_matrix_location(), false, gl_matrix);
2436 2443
2437 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0); 2444 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0);
2438 2445
2439 SetShaderOpacity(quad->shared_quad_state->opacity, 2446 SetShaderOpacity(quad->shared_quad_state->opacity,
2440 program->fragment_shader().alpha_location()); 2447 program->fragment_shader().alpha_location());
2441 if (!clip_region) { 2448 if (!clip_region) {
2442 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2449 DrawQuadGeometry(frame->projection_matrix,
2450 quad->shared_quad_state->quad_to_target_transform,
2443 gfx::RectF(quad->rect), 2451 gfx::RectF(quad->rect),
2444 program->vertex_shader().matrix_location()); 2452 program->vertex_shader().matrix_location());
2445 } else { 2453 } else {
2446 gfx::QuadF region_quad(*clip_region); 2454 gfx::QuadF region_quad(*clip_region);
2447 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height()); 2455 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
2448 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2456 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2449 float uvs[8] = {0}; 2457 float uvs[8] = {0};
2450 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2458 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2451 DrawQuadGeometryClippedByQuadF( 2459 DrawQuadGeometryClippedByQuadF(
2452 frame, quad->shared_quad_state->quad_to_target_transform, 2460 frame, quad->shared_quad_state->quad_to_target_transform,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 gfx::Transform quad_rect_matrix; 2805 gfx::Transform quad_rect_matrix;
2798 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2806 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2799 static float gl_matrix[16]; 2807 static float gl_matrix[16];
2800 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2808 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2801 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); 2809 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]);
2802 2810
2803 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 2811 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
2804 reinterpret_cast<const void*>(0)); 2812 reinterpret_cast<const void*>(0));
2805 } 2813 }
2806 2814
2807 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame, 2815 void GLRenderer::DrawQuadGeometry(const gfx::Transform& projection_matrix,
2808 const gfx::Transform& draw_transform, 2816 const gfx::Transform& draw_transform,
2809 const gfx::RectF& quad_rect, 2817 const gfx::RectF& quad_rect,
2810 int matrix_location) { 2818 int matrix_location) {
2811 PrepareGeometry(SHARED_BINDING); 2819 PrepareGeometry(SHARED_BINDING);
2812 gfx::Transform quad_rect_matrix; 2820 gfx::Transform quad_rect_matrix;
2813 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2821 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2814 static float gl_matrix[16]; 2822 static float gl_matrix[16];
2815 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2823 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix);
2816 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); 2824 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]);
2817 2825
2818 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 2826 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
2819 } 2827 }
2820 2828
2821 void GLRenderer::Finish() { 2829 void GLRenderer::Finish() {
2822 TRACE_EVENT0("cc", "GLRenderer::Finish"); 2830 TRACE_EVENT0("cc", "GLRenderer::Finish");
2823 gl_->Finish(); 2831 gl_->Finish();
2824 } 2832 }
2825 2833
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3723 3731
3724 if (is_scissor_enabled_) { 3732 if (is_scissor_enabled_) {
3725 gl_->Enable(GL_SCISSOR_TEST); 3733 gl_->Enable(GL_SCISSOR_TEST);
3726 gl_->Scissor(scissor_rect_.x(), scissor_rect_.y(), scissor_rect_.width(), 3734 gl_->Scissor(scissor_rect_.x(), scissor_rect_.y(), scissor_rect_.width(),
3727 scissor_rect_.height()); 3735 scissor_rect_.height());
3728 } else { 3736 } else {
3729 gl_->Disable(GL_SCISSOR_TEST); 3737 gl_->Disable(GL_SCISSOR_TEST);
3730 } 3738 }
3731 } 3739 }
3732 3740
3733 void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) {
3734 UseRenderPass(frame, frame->current_render_pass);
3735
3736 // Call SetViewport directly, rather than through PrepareSurfaceForPass.
3737 // PrepareSurfaceForPass also clears the surface, which is not desired when
3738 // restoring.
3739 SetViewport();
3740 }
3741
3742 bool GLRenderer::IsContextLost() { 3741 bool GLRenderer::IsContextLost() {
3743 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; 3742 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
3744 } 3743 }
3745 3744
3746 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { 3745 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) {
3747 scoped_refptr<CALayerOverlaySharedState> shared_state; 3746 scoped_refptr<CALayerOverlaySharedState> shared_state;
3748 size_t copied_render_pass_count = 0; 3747 size_t copied_render_pass_count = 0;
3749 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { 3748 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) {
3750 if (!overlay_resource_pool_) { 3749 if (!overlay_resource_pool_) {
3751 overlay_resource_pool_ = ResourcePool::CreateForGpuMemoryBufferResources( 3750 overlay_resource_pool_ = ResourcePool::CreateForGpuMemoryBufferResources(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3881 resource_provider_, contents_texture->id())); 3880 resource_provider_, contents_texture->id()));
3882 source_texture = source->texture_id(); 3881 source_texture = source->texture_id();
3883 } 3882 }
3884 gl_->CopySubTextureCHROMIUM(source_texture, destination.texture_id(), 0, 0, 0, 3883 gl_->CopySubTextureCHROMIUM(source_texture, destination.texture_id(), 0, 0, 0,
3885 0, contents_texture->size().width(), 3884 0, contents_texture->size().width(),
3886 contents_texture->size().height(), GL_TRUE, 3885 contents_texture->size().height(), GL_TRUE,
3887 GL_FALSE, GL_FALSE); 3886 GL_FALSE, GL_FALSE);
3888 } 3887 }
3889 3888
3890 } // namespace cc 3889 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698