b613c266df
This reverts commit 8240750718
.
Reason for revert: Breaking WebView (chromium:663959)
Original change's description:
> Change SkCanvas to *not* inherit from SkRefCnt
>
> Definitely tricky for classes like SkNWayCanvas, where the caller (today)
> need not pay attention to ownership of the canvases it gave the NWay
> (after this CL, the caller *must* managed ownership)
>
> BUG=skia:
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4441
>
> DOCS_PREVIEW= https://skia.org/?cl=4441
>
> Change-Id: Ib1ac07a3cdf0686d78e7aaa4735d45cc90bea081
> Reviewed-on: https://skia-review.googlesource.com/4441
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
>
TBR=djsollen@google.com,mtklein@google.com,halcanary@google.com,robertphillips@google.com,fmalita@chromium.org,fmalita@google.com,reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I5e3b3e876b7d2c09833cf841801321033b6b968b
Reviewed-on: https://skia-review.googlesource.com/4687
Commit-Queue: Heather Miller <hcm@google.com>
Reviewed-by: Heather Miller <hcm@google.com>
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
/*
|
|
* Copyright 2014 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkMultiPictureDraw_DEFINED
|
|
#define SkMultiPictureDraw_DEFINED
|
|
|
|
#include "../private/SkTDArray.h"
|
|
#include "SkMatrix.h"
|
|
|
|
class SkCanvas;
|
|
class SkPaint;
|
|
class SkPicture;
|
|
|
|
/** \class SkMultiPictureDraw
|
|
|
|
The MultiPictureDraw object accepts several picture/canvas pairs and
|
|
then attempts to optimally draw the pictures into the canvases, sharing
|
|
as many resources as possible.
|
|
*/
|
|
class SK_API SkMultiPictureDraw {
|
|
public:
|
|
/**
|
|
* Create an object to optimize the drawing of multiple pictures.
|
|
* @param reserve Hint for the number of add calls expected to be issued
|
|
*/
|
|
SkMultiPictureDraw(int reserve = 0);
|
|
~SkMultiPictureDraw() { this->reset(); }
|
|
|
|
/**
|
|
* Add a canvas/picture pair for later rendering.
|
|
* @param canvas the canvas in which to draw picture
|
|
* @param picture the picture to draw into canvas
|
|
* @param matrix if non-NULL, applied to the CTM when drawing
|
|
* @param paint if non-NULL, draw picture to a temporary buffer
|
|
* and then apply the paint when the result is drawn
|
|
*/
|
|
void add(SkCanvas* canvas,
|
|
const SkPicture* picture,
|
|
const SkMatrix* matrix = NULL,
|
|
const SkPaint* paint = NULL);
|
|
|
|
/**
|
|
* Perform all the previously added draws. This will reset the state
|
|
* of this object. If flush is true, all canvases are flushed after
|
|
* draw.
|
|
*/
|
|
void draw(bool flush = false);
|
|
|
|
/**
|
|
* Abandon all buffered draws and reset to the initial state.
|
|
*/
|
|
void reset();
|
|
|
|
private:
|
|
struct DrawData {
|
|
SkCanvas* fCanvas; // reffed
|
|
const SkPicture* fPicture; // reffed
|
|
SkMatrix fMatrix;
|
|
SkPaint* fPaint; // owned
|
|
|
|
void init(SkCanvas*, const SkPicture*, const SkMatrix*, const SkPaint*);
|
|
void draw();
|
|
|
|
static void Reset(SkTDArray<DrawData>&);
|
|
};
|
|
|
|
SkTDArray<DrawData> fThreadSafeDrawData;
|
|
SkTDArray<DrawData> fGPUDrawData;
|
|
};
|
|
|
|
#endif
|