summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/graphics/paint_generated_image.cc
blob: 084304ea8ccb1d6943fac34b93b68e1d76fb8b62 (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
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2016 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 "third_party/blink/renderer/platform/graphics/paint_generated_image.h"

#include "third_party/blink/renderer/platform/geometry/float_rect.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_canvas.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record.h"

namespace blink {

void PaintGeneratedImage::Draw(cc::PaintCanvas* canvas,
                               const PaintFlags& flags,
                               const FloatRect& dest_rect,
                               const FloatRect& src_rect,
                               RespectImageOrientationEnum,
                               ImageClampingMode,
                               ImageDecodingMode) {
  PaintCanvasAutoRestore ar(canvas, true);
  canvas->clipRect(dest_rect);
  canvas->concat(SkMatrix::MakeRectToRect(src_rect, dest_rect,
                                          SkMatrix::kFill_ScaleToFit));
  SkRect bounds = src_rect;
  canvas->saveLayer(&bounds, &flags);
  canvas->drawPicture(record_);
}

void PaintGeneratedImage::DrawTile(GraphicsContext& context,
                                   const FloatRect& src_rect,
                                   RespectImageOrientationEnum) {
  context.DrawRecord(record_);
}

}  // namespace blink