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/SkFloodImageFilter.cpp

Issue 24157005: Moving 4 SkImageFilter derived classes from blink to skia (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Merged offset filters together Created 7 years, 3 months 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 "SkFloodImageFilter.h"
9 #include "SkBitmap.h"
10 #include "SkCanvas.h"
11 #include "SkDevice.h"
12 #include "SkFlattenableBuffers.h"
13 #include "SkMatrix.h"
14 #include "SkPaint.h"
15
16 SkFloodImageFilter::SkFloodImageFilter(SkFlattenableReadBuffer& buffer) : INHERI TED(buffer) {
17 fColor = buffer.readColor();
18 }
19
20 void SkFloodImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
21 this->INHERITED::flatten(buffer);
22 buffer.writeColor(fColor);
23 }
24
25 bool SkFloodImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
26 SkBitmap* result, SkIPoint* offset) {
27 if (!src.width() || !src.height()) {
28 return false;
29 }
30
31 SkIRect bounds;
32 src.getBounds(&bounds);
33 if (!applyCropRect(&bounds, ctm)) {
34 return false;
35 }
36
37 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
38 SkCanvas canvas(device.get());
39 SkPaint paint;
40 paint.setColor(fColor);
41 canvas.drawRect(SkRect::MakeWH(SkIntToScalar(src.width()),
42 SkIntToScalar(src.height())), paint);
43 *result = device->accessBitmap(false);
44 offset->fX += bounds.left();
45 offset->fY += bounds.top();
46 return true;
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698