Skip to content

Commit

Permalink
Don't store results of skia::GetBitmapContext()
Browse files Browse the repository at this point in the history
We'd like to get rid of skia::GetBitmapContext(); as a small step
in that direction while we figure out how to handle all of its
side effects, this moves the only invocation of it in Chrome proper
to the same function where it's used, avoiding the need to store
a context on the (mac-specific) CanvasSkiaPaint object.

R=danakj@chromium.org
BUG=543755

Review URL: https://codereview.chromium.org/1848883005

Cr-Commit-Position: refs/heads/master@{#384653}
  • Loading branch information
Naburimannu authored and Commit bot committed Apr 1, 2016
1 parent f3e6441 commit eddf096
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion ui/gfx/canvas_paint_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class GFX_EXPORT CanvasSkiaPaint : public Canvas {
private:
void Init(bool opaque);

CGContext* context_;
NSRect rectangle_;
// See description above setter.
bool composite_alpha_;
Expand Down
14 changes: 6 additions & 8 deletions ui/gfx/canvas_paint_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
namespace gfx {

CanvasSkiaPaint::CanvasSkiaPaint(NSRect dirtyRect)
: context_(NULL),
rectangle_(dirtyRect),
: rectangle_(dirtyRect),
composite_alpha_(false) {
Init(true);
}

CanvasSkiaPaint::CanvasSkiaPaint(NSRect dirtyRect, bool opaque)
: context_(NULL),
rectangle_(dirtyRect),
: rectangle_(dirtyRect),
composite_alpha_(false) {
Init(opaque);
}

CanvasSkiaPaint::~CanvasSkiaPaint() {
if (!is_empty()) {
sk_canvas()->restoreToCount(1);
SkCanvas* canvas = sk_canvas();
canvas->restoreToCount(1);

// Blit the dirty rect to the current context.
CGImageRef image = CGBitmapContextCreateImage(context_);
CGImageRef image =
CGBitmapContextCreateImage(skia::GetBitmapContext(*canvas));
CGRect dest_rect = NSRectToCGRect(rectangle_);

CGContextRef destination_context =
Expand Down Expand Up @@ -67,8 +67,6 @@
// surface.
canvas->translate(-SkDoubleToScalar(NSMinX(rectangle_)),
-SkDoubleToScalar(NSMinY(rectangle_)));

context_ = skia::GetBitmapContext(*canvas);
}

} // namespace skia
Expand Down

0 comments on commit eddf096

Please sign in to comment.