commit-bot@chromium.org | c4b21e6 | 2014-04-11 18:33:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 8 | #ifndef SkRecordDraw_DEFINED |
| 9 | #define SkRecordDraw_DEFINED |
| 10 | |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 11 | #include "SkBBoxHierarchy.h" |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 12 | #include "SkBigPicture.h" |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 13 | #include "SkCanvas.h" |
robertphillips | 4815fe5 | 2014-09-16 10:32:43 -0700 | [diff] [blame] | 14 | #include "SkMatrix.h" |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 15 | #include "SkRecord.h" |
| 16 | |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame] | 17 | class SkDrawable; |
robertphillips | 8236591 | 2014-11-12 09:32:34 -0800 | [diff] [blame] | 18 | class SkLayerInfo; |
| 19 | |
mtklein | 40732b3 | 2015-10-24 07:45:47 -0700 | [diff] [blame^] | 20 | // Calculate conservative identity space bounds for each op in the record. |
| 21 | void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkRect bounds[]); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 22 | |
mtklein | 40732b3 | 2015-10-24 07:45:47 -0700 | [diff] [blame^] | 23 | // SkRecordFillBounds(), and gathers information about saveLayers and stores it for later |
| 24 | // use (e.g., layer hoisting). The gathered information is sufficient to determine |
| 25 | // where each saveLayer will land and which ops in the picture it represents. |
| 26 | void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord&, SkRect bounds[], |
| 27 | const SkBigPicture::SnapshotArray*, SkLayerInfo* data); |
robertphillips | 4e8e342 | 2014-11-12 06:46:08 -0800 | [diff] [blame] | 28 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 29 | // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::Draw. |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 30 | void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePicts[], |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame] | 31 | SkDrawable* const drawables[], int drawableCount, |
robertphillips | 783fe16 | 2015-01-07 07:28:41 -0800 | [diff] [blame] | 32 | const SkBBoxHierarchy*, SkPicture::AbortCallback*); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 33 | |
reed | 8eddfb5 | 2014-12-04 07:50:14 -0800 | [diff] [blame] | 34 | // Draw a portion of an SkRecord into an SkCanvas. |
robertphillips | 4815fe5 | 2014-09-16 10:32:43 -0700 | [diff] [blame] | 35 | // When drawing a portion of an SkRecord the CTM on the passed in canvas must be |
| 36 | // the composition of the replay matrix with the record-time CTM (for the portion |
| 37 | // of the record that is being replayed). For setMatrix calls to behave correctly |
| 38 | // the initialCTM parameter must set to just the replay matrix. |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 39 | void SkRecordPartialDraw(const SkRecord&, SkCanvas*, |
| 40 | SkPicture const* const drawablePicts[], int drawableCount, |
mtklein | c6ad06a | 2015-08-19 09:51:00 -0700 | [diff] [blame] | 41 | int start, int stop, const SkMatrix& initialCTM); |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 42 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 43 | namespace SkRecords { |
| 44 | |
| 45 | // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
| 46 | class Draw : SkNoncopyable { |
| 47 | public: |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 48 | explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame] | 49 | SkDrawable* const drawables[], int drawableCount, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 50 | const SkMatrix* initialCTM = nullptr) |
robertphillips | 4815fe5 | 2014-09-16 10:32:43 -0700 | [diff] [blame] | 51 | : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 52 | , fCanvas(canvas) |
| 53 | , fDrawablePicts(drawablePicts) |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 54 | , fDrawables(drawables) |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 55 | , fDrawableCount(drawableCount) |
| 56 | {} |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 57 | |
danakj | d239d42 | 2014-11-03 12:43:30 -0800 | [diff] [blame] | 58 | // This operator calls methods on the |canvas|. The various draw() wrapper |
| 59 | // methods around SkCanvas are defined by the DRAW() macro in |
| 60 | // SkRecordDraw.cpp. |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 61 | template <typename T> void operator()(const T& r) { |
mtklein | f4078ad | 2014-08-08 10:05:19 -0700 | [diff] [blame] | 62 | this->draw(r); |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 63 | } |
| 64 | |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 65 | protected: |
| 66 | SkPicture const* const* drawablePicts() const { return fDrawablePicts; } |
| 67 | int drawableCount() const { return fDrawableCount; } |
| 68 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 69 | private: |
| 70 | // No base case, so we'll be compile-time checked that we implement all possibilities. |
| 71 | template <typename T> void draw(const T&); |
| 72 | |
commit-bot@chromium.org | 0a98d87 | 2014-05-19 15:15:24 +0000 | [diff] [blame] | 73 | const SkMatrix fInitialCTM; |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 74 | SkCanvas* fCanvas; |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 75 | SkPicture const* const* fDrawablePicts; |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame] | 76 | SkDrawable* const* fDrawables; |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 77 | int fDrawableCount; |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 80 | } // namespace SkRecords |
| 81 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 82 | #endif//SkRecordDraw_DEFINED |