Merge "Fix drawColor/drawPaint bounds" into nyc-dev

am: 388e43f419

* commit '388e43f4193bd2f1fd3687fada6bddab623f9a8c':
  Fix drawColor/drawPaint bounds
This commit is contained in:
Chris Craik
2016-02-23 23:43:57 +00:00
committed by android-build-merger
2 changed files with 19 additions and 2 deletions

View File

@@ -241,10 +241,13 @@ void RecordingCanvas::drawColor(int color, SkXfermode::Mode mode) {
}
void RecordingCanvas::drawPaint(const SkPaint& paint) {
const ClipBase* clip = getRecordedClip();
// if there's no current clip, draw a big rect and hope we cover the eventual clip bounds
Rect bounds = clip ? clip->rect : Rect(-10000, -10000, 10000, 10000);
addOp(alloc().create_trivial<RectOp>(
mState.getRenderTargetClipBounds(), // OK, since we've not passed transform
bounds,
Matrix4::identity(),
getRecordedClip(),
clip,
refPaint(&paint)));
}

View File

@@ -19,6 +19,7 @@
#include <RecordedOp.h>
#include <RecordingCanvas.h>
#include <tests/common/TestUtils.h>
#include <utils/Color.h>
namespace android {
namespace uirenderer {
@@ -185,6 +186,19 @@ TEST(RecordingCanvas, drawText_forceAlignLeft) {
ASSERT_EQ(3, count);
}
TEST(RecordingCanvas, drawColor) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
canvas.drawColor(Color::Black, SkXfermode::kSrcOver_Mode);
});
ASSERT_EQ(1u, dl->getOps().size()) << "Must be exactly one op";
auto op = *(dl->getOps()[0]);
EXPECT_EQ(RecordedOpId::RectOp, op.opId);
EXPECT_EQ(nullptr, op.localClip);
EXPECT_TRUE(op.unmappedBounds.contains(Rect(-1000, -1000, 1000, 1000)))
<< "no clip, unmappedBounds should resolve to be much larger than DL bounds";
}
TEST(RecordingCanvas, backgroundAndImage) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 200, [](RecordingCanvas& canvas) {
SkBitmap bitmap;