Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/effects/SkPictureSource.cpp

Issue 114263002: Implement an SkPicture image filter source. This is required for the external-SVG reference feature… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 The Android Open Source Project
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
8 #include "SkPictureSource.h"
9 #include "SkDevice.h"
10 #include "SkCanvas.h"
11 #include "SkFlattenableBuffers.h"
12 #include "SkValidationUtils.h"
13
14 SkPictureSource::SkPictureSource(const SkPicture& picture)
15 : INHERITED(0, 0),
16 fPicture(picture),
17 fRect(SkRect::MakeWH(picture.width(), picture.height())) {
18 }
19
20 SkPictureSource::SkPictureSource(const SkPicture& picture, const SkRect& rect)
21 : INHERITED(0, 0),
22 fPicture(picture),
23 fRect(rect) {
24 }
25
26 SkPictureSource::SkPictureSource(SkFlattenableReadBuffer& buffer)
27 : INHERITED(0, buffer) {
28 // FIXME: unflatten picture here.
29 buffer.readRect(&fRect);
30 }
31
32 void SkPictureSource::flatten(SkFlattenableWriteBuffer& buffer) const {
33 this->INHERITED::flatten(buffer);
34 // FIXME: flatten picture here.
35 buffer.writeRect(fRect);
36 }
37
38 bool SkPictureSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatri x& matrix,
39 SkBitmap* result, SkIPoint* offset) {
40 SkRect floatBounds;
41 SkIRect bounds;
42 matrix.mapRect(&floatBounds, fRect);
43 floatBounds.roundOut(&bounds);
44
45 if (bounds.isEmpty()) {
46 return true;
47 }
48
49 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
50 if (NULL == device.get()) {
51 return false;
52 }
53
54 SkCanvas canvas(device.get());
55 SkPaint paint;
56
57 canvas.translate(-bounds.fLeft, -bounds.fTop);
58 canvas.concat(matrix);
59 canvas.drawPicture(fPicture);
60
61 *result = device.get()->accessBitmap(false);
62 offset->fX += bounds.fLeft;
63 offset->fY += bounds.fTop;
64 return true;
65 }
OLDNEW
« include/effects/SkPictureSource.h ('K') | « include/effects/SkPictureSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698