summaryrefslogtreecommitdiffstats
path: root/ui/compositor/compositing_recorder.cc
blob: 20426af49ce9cfaf0c6bf79e0c08b86557c30de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2015 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 "ui/compositor/compositing_recorder.h"

#include "ui/compositor/paint_context.h"
#include "ui/gfx/canvas.h"

namespace ui {

CompositingRecorder::CompositingRecorder(const PaintContext& context,
                                         uint8_t alpha)
    : canvas_(context.canvas()), saved_(alpha < 255) {
  if (saved_)
    canvas_->SaveLayerAlpha(alpha);
}

CompositingRecorder::~CompositingRecorder() {
  if (saved_)
    canvas_->Restore();
}

}  // namespace ui