| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_PAINT_RECORD_PAINT_CANVAS_H_ | 5 #ifndef CC_PAINT_RECORD_PAINT_CANVAS_H_ |
| 6 #define CC_PAINT_RECORD_PAINT_CANVAS_H_ | 6 #define CC_PAINT_RECORD_PAINT_CANVAS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/optional.h" | 13 #include "base/optional.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "cc/paint/paint_canvas.h" | 15 #include "cc/paint/paint_canvas.h" |
| 16 #include "cc/paint/paint_flags.h" | 16 #include "cc/paint/paint_flags.h" |
| 17 #include "cc/paint/paint_record.h" | 17 #include "cc/paint/paint_record.h" |
| 18 #include "third_party/skia/include/utils/SkNoDrawCanvas.h" | 18 #include "third_party/skia/include/utils/SkNoDrawCanvas.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 | 21 |
| 22 class PaintOpBuffer; | 22 class PaintOpBuffer; |
| 23 class PaintFlags; | 23 class PaintFlags; |
| 24 | 24 |
| 25 class CC_PAINT_EXPORT RecordPaintCanvas final : public PaintCanvas { | 25 class CC_PAINT_EXPORT RecordPaintCanvas final : public PaintCanvas { |
| 26 public: | 26 public: |
| 27 explicit RecordPaintCanvas(PaintOpBuffer* buffer); | 27 explicit RecordPaintCanvas(PaintOpBuffer* buffer, const SkRect& bounds); |
| 28 ~RecordPaintCanvas() override; | 28 ~RecordPaintCanvas() override; |
| 29 | 29 |
| 30 SkMetaData& getMetaData() override; | 30 SkMetaData& getMetaData() override; |
| 31 SkImageInfo imageInfo() const override; | 31 SkImageInfo imageInfo() const override; |
| 32 | 32 |
| 33 void flush() override; | 33 void flush() override; |
| 34 | 34 |
| 35 int save() override; | 35 int save() override; |
| 36 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override; | 36 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override; |
| 37 int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) override; | 37 int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) override; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 // TODO(enne): Although RecordPaintCanvas is mostly a write-only interface | 142 // TODO(enne): Although RecordPaintCanvas is mostly a write-only interface |
| 143 // where paint commands are stored, occasionally users of PaintCanvas want | 143 // where paint commands are stored, occasionally users of PaintCanvas want |
| 144 // to ask stateful questions mid-stream of clip and transform state. | 144 // to ask stateful questions mid-stream of clip and transform state. |
| 145 // To avoid duplicating all this code (for now?), just forward to an SkCanvas | 145 // To avoid duplicating all this code (for now?), just forward to an SkCanvas |
| 146 // that's not backed by anything but can answer these questions. | 146 // that's not backed by anything but can answer these questions. |
| 147 // | 147 // |
| 148 // This is mutable so that const functions (e.g. quickReject) that may | 148 // This is mutable so that const functions (e.g. quickReject) that may |
| 149 // lazy initialize the canvas can still be const. | 149 // lazy initialize the canvas can still be const. |
| 150 mutable base::Optional<SkNoDrawCanvas> canvas_; | 150 mutable base::Optional<SkNoDrawCanvas> canvas_; |
| 151 SkRect recording_bounds_; |
| 151 | 152 |
| 152 DISALLOW_COPY_AND_ASSIGN(RecordPaintCanvas); | 153 DISALLOW_COPY_AND_ASSIGN(RecordPaintCanvas); |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 } // namespace cc | 156 } // namespace cc |
| 156 | 157 |
| 157 #endif // CC_PAINT_RECORD_PAINT_CANVAS_H_ | 158 #endif // CC_PAINT_RECORD_PAINT_CANVAS_H_ |
| OLD | NEW |