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

Side by Side Diff: content/browser/renderer_host/compositing_iosurface_mac.mm

Issue 10533098: mac: Improve framerate on accelerated pages in HiDPI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/compositing_iosurface_mac.h" 5 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
6 6
7 #include <OpenGL/OpenGL.h> 7 #include <OpenGL/OpenGL.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", 213 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface",
214 "has_io_surface", has_io_surface); 214 "has_io_surface", has_io_surface);
215 215
216 [glContext_ setView:view]; 216 [glContext_ setView:view];
217 gfx::Size window_size(NSSizeToCGSize([view frame].size)); 217 gfx::Size window_size(NSSizeToCGSize([view frame].size));
218 gfx::Size pixel_window_size = window_size.Scale(scale_factor); 218 gfx::Size pixel_window_size = window_size.Scale(scale_factor);
219 glViewport(0, 0, pixel_window_size.width(), pixel_window_size.height()); 219 glViewport(0, 0, pixel_window_size.width(), pixel_window_size.height());
220 220
221 // TODO: After a resolution change, the DPI-ness of the view and the 221 // TODO: After a resolution change, the DPI-ness of the view and the
222 // IOSurface might not be in sync. 222 // IOSurface might not be in sync.
223 gfx::Size io_surface_size = pixel_io_surface_size_; 223 io_surface_size_ = pixel_io_surface_size_.Scale(1.0 / scale_factor);
224 io_surface_size = pixel_io_surface_size_.Scale(1.0 / scale_factor); 224 quad_.set_size(io_surface_size_, pixel_io_surface_size_);
225 quad_.set_size(io_surface_size, pixel_io_surface_size_);
226 225
227 glMatrixMode(GL_PROJECTION); 226 glMatrixMode(GL_PROJECTION);
228 glLoadIdentity(); 227 glLoadIdentity();
229 228
230 // Note that the projection keeps things in view units, so the use of 229 // Note that the projection keeps things in view units, so the use of
231 // window_size / io_surface_size (as opposed to the pixel_ variants) below is 230 // window_size / io_surface_size_ (as opposed to the pixel_ variants) below is
232 // correct. 231 // correct.
233 glOrtho(0, window_size.width(), window_size.height(), 0, -1, 1); 232 glOrtho(0, window_size.width(), window_size.height(), 0, -1, 1);
234 glMatrixMode(GL_MODELVIEW); 233 glMatrixMode(GL_MODELVIEW);
235 glLoadIdentity(); 234 glLoadIdentity();
236 235
237 glDisable(GL_DEPTH_TEST); 236 glDisable(GL_DEPTH_TEST);
238 glDisable(GL_BLEND); 237 glDisable(GL_BLEND);
239 238
240 if (has_io_surface) { 239 if (has_io_surface) {
241 glUseProgram(shader_program_blit_rgb_); 240 glUseProgram(shader_program_blit_rgb_);
242 241
243 int texture_unit = 0; 242 int texture_unit = 0;
244 glUniform1i(blit_rgb_sampler_location_, texture_unit); 243 glUniform1i(blit_rgb_sampler_location_, texture_unit);
245 glActiveTexture(GL_TEXTURE0 + texture_unit); 244 glActiveTexture(GL_TEXTURE0 + texture_unit);
246 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_); 245 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_);
247 246
248 DrawQuad(quad_); 247 DrawQuad(quad_);
249 248
250 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); CHECK_GL_ERROR(); 249 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); CHECK_GL_ERROR();
251 250
252 // Fill the resize gutters with white. 251 // Fill the resize gutters with white.
253 if (window_size.width() > io_surface_size.width() || 252 if (window_size.width() > io_surface_size_.width() ||
254 window_size.height() > io_surface_size.height()) { 253 window_size.height() > io_surface_size_.height()) {
255 glUseProgram(shader_program_white_); 254 glUseProgram(shader_program_white_);
256 SurfaceQuad filler_quad; 255 SurfaceQuad filler_quad;
257 if (window_size.width() > io_surface_size.width()) { 256 if (window_size.width() > io_surface_size_.width()) {
258 // Draw right-side gutter down to the bottom of the window. 257 // Draw right-side gutter down to the bottom of the window.
259 filler_quad.set_rect(io_surface_size.width(), 0.0f, 258 filler_quad.set_rect(io_surface_size_.width(), 0.0f,
260 window_size.width(), window_size.height()); 259 window_size.width(), window_size.height());
261 DrawQuad(filler_quad); 260 DrawQuad(filler_quad);
262 } 261 }
263 if (window_size.height() > io_surface_size.height()) { 262 if (window_size.height() > io_surface_size_.height()) {
264 // Draw bottom gutter to the width of the IOSurface. 263 // Draw bottom gutter to the width of the IOSurface.
265 filler_quad.set_rect(0.0f, io_surface_size.height(), 264 filler_quad.set_rect(0.0f, io_surface_size_.height(),
266 io_surface_size.width(), window_size.height()); 265 io_surface_size_.width(), window_size.height());
267 DrawQuad(filler_quad); 266 DrawQuad(filler_quad);
268 } 267 }
269 } 268 }
270 269
271 glUseProgram(0); CHECK_GL_ERROR(); 270 glUseProgram(0); CHECK_GL_ERROR();
272 } else { 271 } else {
273 // Should match the clear color of RenderWidgetHostViewMac. 272 // Should match the clear color of RenderWidgetHostViewMac.
274 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 273 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
275 glClear(GL_COLOR_BUFFER_BIT); 274 glClear(GL_COLOR_BUFFER_BIT);
276 } 275 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (!io_surface_.get()) { 387 if (!io_surface_.get()) {
389 io_surface_handle_ = 0; 388 io_surface_handle_ = 0;
390 return false; 389 return false;
391 } 390 }
392 391
393 io_surface_handle_ = io_surface_handle; 392 io_surface_handle_ = io_surface_handle;
394 pixel_io_surface_size_.SetSize( 393 pixel_io_surface_size_.SetSize(
395 io_surface_support_->IOSurfaceGetWidth(io_surface_), 394 io_surface_support_->IOSurfaceGetWidth(io_surface_),
396 io_surface_support_->IOSurfaceGetHeight(io_surface_)); 395 io_surface_support_->IOSurfaceGetHeight(io_surface_));
397 396
397 // TODO(thakis): Keep track of the view size over IPC. At the moment,
398 // the correct view units are computed on first paint.
399 io_surface_size_ = pixel_io_surface_size_;
400
398 quad_.set_size(pixel_io_surface_size_, pixel_io_surface_size_); 401 quad_.set_size(pixel_io_surface_size_, pixel_io_surface_size_);
399 402
400 GLenum target = GL_TEXTURE_RECTANGLE_ARB; 403 GLenum target = GL_TEXTURE_RECTANGLE_ARB;
401 glGenTextures(1, &texture_); 404 glGenTextures(1, &texture_);
402 glBindTexture(target, texture_); 405 glBindTexture(target, texture_);
403 glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 406 glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
404 glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL_ERROR(); 407 glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL_ERROR();
405 GLuint plane = 0; 408 GLuint plane = 0;
406 CGLError cglerror = io_surface_support_->CGLTexImageIOSurface2D( 409 CGLError cglerror = io_surface_support_->CGLTexImageIOSurface2D(
407 cglContext_, 410 cglContext_,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 458 }
456 459
457 void CompositingIOSurfaceMac::GlobalFrameDidChange() { 460 void CompositingIOSurfaceMac::GlobalFrameDidChange() {
458 [glContext_ update]; 461 [glContext_ update];
459 } 462 }
460 463
461 void CompositingIOSurfaceMac::ClearDrawable() { 464 void CompositingIOSurfaceMac::ClearDrawable() {
462 [glContext_ clearDrawable]; 465 [glContext_ clearDrawable];
463 UnrefIOSurface(); 466 UnrefIOSurface();
464 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698