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

Side by Side Diff: webkit/tools/test_shell/webwidget_host_gtk.cc

Issue 43058: Reverting 11396. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « webkit/tools/test_shell/webwidget_host.h ('k') | webkit/tools/test_shell/webwidget_host_win.cc » ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "webkit/tools/test_shell/webwidget_host.h" 5 #include "webkit/tools/test_shell/webwidget_host.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 void WebWidgetHost::Resize(const gfx::Size &newsize) { 280 void WebWidgetHost::Resize(const gfx::Size &newsize) {
281 // The pixel buffer backing us is now the wrong size 281 // The pixel buffer backing us is now the wrong size
282 canvas_.reset(); 282 canvas_.reset();
283 283
284 webwidget_->Resize(gfx::Size(newsize.width(), newsize.height())); 284 webwidget_->Resize(gfx::Size(newsize.width(), newsize.height()));
285 } 285 }
286 286
287 void WebWidgetHost::Paint() { 287 void WebWidgetHost::Paint() {
288 PaintToCanvas();
289 PaintCanvasToView();
290 }
291
292 void WebWidgetHost::PaintToCanvas() {
293 int width = view_->allocation.width; 288 int width = view_->allocation.width;
294 int height = view_->allocation.height; 289 int height = view_->allocation.height;
295 gfx::Rect client_rect(width, height); 290 gfx::Rect client_rect(width, height);
296 291
297 // Allocate a canvas if necessary 292 // Allocate a canvas if necessary
298 if (!canvas_.get()) { 293 if (!canvas_.get()) {
299 ResetScrollRect(); 294 ResetScrollRect();
300 paint_rect_ = client_rect; 295 paint_rect_ = client_rect;
301 canvas_.reset(new skia::PlatformCanvas(width, height, true)); 296 canvas_.reset(new skia::PlatformCanvas(width, height, true));
302 if (!canvas_.get()) { 297 if (!canvas_.get()) {
(...skipping 18 matching lines...) Expand all
321 gfx::Rect rect(paint_rect_); 316 gfx::Rect rect(paint_rect_);
322 paint_rect_ = gfx::Rect(); 317 paint_rect_ = gfx::Rect();
323 318
324 DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; 319 DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations";
325 PaintRect(rect); 320 PaintRect(rect);
326 total_paint = total_paint.Union(rect); 321 total_paint = total_paint.Union(rect);
327 } 322 }
328 } 323 }
329 DCHECK(paint_rect_.IsEmpty()); 324 DCHECK(paint_rect_.IsEmpty());
330 325
331 }
332
333 void WebWidgetHost::PaintCanvasToView() {
334 // Invalidate the paint region on the widget's underlying gdk window. Note 326 // Invalidate the paint region on the widget's underlying gdk window. Note
335 // that gdk_window_invalidate_* will generate extra expose events, which 327 // that gdk_window_invalidate_* will generate extra expose events, which
336 // we wish to avoid. So instead we use calls to begin_paint/end_paint. 328 // we wish to avoid. So instead we use calls to begin_paint/end_paint.
337 GdkRectangle grect = { 329 GdkRectangle grect = {
338 0, 330 total_paint.x(),
339 0, 331 total_paint.y(),
340 canvas_->getDevice()->width(), 332 total_paint.width(),
341 canvas_->getDevice()->height(), 333 total_paint.height(),
342 }; 334 };
343 GdkWindow* window = view_->window; 335 GdkWindow* window = view_->window;
344 gdk_window_begin_paint_rect(window, &grect); 336 gdk_window_begin_paint_rect(window, &grect);
345 337
346 // BitBlit to the gdk window. 338 // BitBlit to the gdk window.
347 skia::PlatformDeviceLinux &platdev = canvas_->getTopPlatformDevice(); 339 skia::PlatformDeviceLinux &platdev = canvas_->getTopPlatformDevice();
348 skia::BitmapPlatformDeviceLinux* const bitdev = 340 skia::BitmapPlatformDeviceLinux* const bitdev =
349 static_cast<skia::BitmapPlatformDeviceLinux* >(&platdev); 341 static_cast<skia::BitmapPlatformDeviceLinux* >(&platdev);
350 cairo_t* cairo_drawable = gdk_cairo_create(window); 342 cairo_t* cairo_drawable = gdk_cairo_create(window);
351 cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0); 343 cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0);
352 cairo_paint(cairo_drawable); 344 cairo_paint(cairo_drawable);
353 cairo_destroy(cairo_drawable); 345 cairo_destroy(cairo_drawable);
354 346
355 gdk_window_end_paint(window); 347 gdk_window_end_paint(window);
356 } 348 }
357 349
358 void WebWidgetHost::DisplayForRepaint() {
359 PaintToCanvas();
360
361 // Paint a gray mask over everything for the repaint Layout tests.
362 const SkColor kMaskColor = SkColorSetARGB(168, 0, 0, 0); // alpha=0.66
363 canvas_->drawColor(kMaskColor, SkPorterDuff::kSrcOver_Mode);
364
365 PaintCanvasToView();
366 }
367
368 void WebWidgetHost::ResetScrollRect() { 350 void WebWidgetHost::ResetScrollRect() {
369 // This method is only needed for optimized scroll painting, which we don't 351 // This method is only needed for optimized scroll painting, which we don't
370 // care about in the test shell, yet. 352 // care about in the test shell, yet.
371 } 353 }
372 354
373 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { 355 void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
374 set_painting(true); 356 set_painting(true);
375 webwidget_->Paint(canvas_.get(), rect); 357 webwidget_->Paint(canvas_.get(), rect);
376 set_painting(false); 358 set_painting(false);
377 } 359 }
378 360
379 void WebWidgetHost::WindowDestroyed() { 361 void WebWidgetHost::WindowDestroyed() {
380 delete this; 362 delete this;
381 } 363 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/webwidget_host.h ('k') | webkit/tools/test_shell/webwidget_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698