Skip to content

Commit

Permalink
reapply 164660 w/ fix to add UI_EXPORT to new classes, so we can link…
Browse files Browse the repository at this point in the history
… in component build.

https://codereview.chromium.org/11193037/
Review URL: https://codereview.chromium.org/11338013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164905 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
reed@google.com committed Oct 30, 2012
1 parent 03e09f1 commit 263fc7a
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 342 deletions.
4 changes: 3 additions & 1 deletion chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ void InfoBarContainerGtk::PaintArrowOn(GtkWidget* widget,
paint.setShader(gradient_shader);
gradient_shader->unref();

skia::PlatformCanvasPaint canvas(expose, false);
gfx::CanvasSkiaPaint canvas_paint(expose, false);
SkCanvas& canvas = *canvas_paint.sk_canvas();

canvas.drawPath(path, paint);

paint.setShader(NULL);
Expand Down
23 changes: 0 additions & 23 deletions skia/ext/canvas_paint.h

This file was deleted.

23 changes: 0 additions & 23 deletions skia/ext/canvas_paint_common.h

This file was deleted.

117 changes: 0 additions & 117 deletions skia/ext/canvas_paint_gtk.h

This file was deleted.

120 changes: 0 additions & 120 deletions skia/ext/canvas_paint_mac.h

This file was deleted.

5 changes: 0 additions & 5 deletions skia/skia.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@
'ext/bitmap_platform_device_mac.h',
'ext/bitmap_platform_device_win.cc',
'ext/bitmap_platform_device_win.h',
'ext/canvas_paint.h',
'ext/canvas_paint_common.h',
'ext/canvas_paint_gtk.h',
'ext/canvas_paint_mac.h',
'ext/canvas_paint_win.h',
'ext/convolver.cc',
'ext/convolver.h',
'ext/google_logging.cc',
Expand Down
72 changes: 72 additions & 0 deletions ui/gfx/canvas_paint_gtk.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/rect.h"

namespace gfx {

CanvasSkiaPaint::CanvasSkiaPaint(GdkEventExpose* event)
: context_(NULL),
window_(event->window),
region_(gdk_region_copy(event->region)),
composite_alpha_(false) {
Init(true);
}

CanvasSkiaPaint::CanvasSkiaPaint(GdkEventExpose* event, bool opaque)
: context_(NULL),
window_(event->window),
region_(gdk_region_copy(event->region)),
composite_alpha_(false) {
Init(opaque);
}

CanvasSkiaPaint::~CanvasSkiaPaint() {
if (!is_empty()) {
platform_canvas()->restoreToCount(1);

// Blit the dirty rect to the window.
CHECK(window_);
cairo_t* cr = gdk_cairo_create(window_);
CHECK(cr);
if (composite_alpha_)
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_surface_t* source_surface = cairo_get_target(context_);
CHECK(source_surface);
// Flush cairo's cache of the surface.
cairo_surface_mark_dirty(source_surface);
GdkRectangle bounds = rectangle();
cairo_set_source_surface(cr, source_surface, bounds.x, bounds.y);
gdk_cairo_region(cr, region_);
cairo_fill(cr);
cairo_destroy(cr);
}

gdk_region_destroy(region_);
}

void CanvasSkiaPaint::Init(bool opaque) {
GdkRectangle bounds = rectangle();
skia::PlatformCanvas* canvas = platform_canvas();
if (!canvas->initialize(bounds.width, bounds.height, opaque, NULL)) {
// Cause a deliberate crash;
CHECK(false);
}
// No need to clear the canvas, because cairo automatically performs the
// clear.

// Need to translate so that the dirty region appears at the origin of the
// surface.
canvas->translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y));

context_ = skia::BeginPlatformPaint(canvas);
}

} // namespace gfx


Loading

0 comments on commit 263fc7a

Please sign in to comment.