forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reapply 164660 w/ fix to add UI_EXPORT to new classes, so we can link…
… 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
Showing
15 changed files
with
309 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
Oops, something went wrong.