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

Side by Side Diff: src/core/SkPictureImageGenerator.cpp

Issue 1240093004: SkPictureImageGenerator (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: added GM Created 5 years, 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 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
8 #include "SkPictureImageGenerator.h"
9
10 #include "SkCanvas.h"
11 #include "SkMatrix.h"
12 #include "SkPaint.h"
13 #include "SkPicture.h"
14
15 SkImageGenerator* SkPictureImageGenerator::Create(const SkISize& size, const SkP icture* picture,
16 const SkMatrix* matrix, const SkPaint* paint) {
17 if (!picture || size.isEmpty()) {
18 return nullptr;
19 }
20
21 return SkNEW_ARGS(SkPictureImageGenerator, (size, picture, matrix, paint));
22 }
23
24 SkPictureImageGenerator::SkPictureImageGenerator(const SkISize& size, const SkPi cture* picture,
25 const SkMatrix* matrix, const S kPaint* paint)
26 : INHERITED(SkImageInfo::MakeN32Premul(size))
27 , fPicture(SkRef(picture)) {
28
29 if (matrix) {
30 fMatrix = *matrix;
31 } else {
32 fMatrix.reset();
33 }
34
35 if (paint) {
36 fPaint.set(*paint);
37 }
38 }
39
robertphillips 2015/07/20 17:32:43 So is there no way to have this work in GPU land?
f(malita) 2015/07/20 20:13:38 Not at this point :( It would be super nice to ha
40 bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
41 SkPMColor ctable[], int* ctableCount) {
42 if (info != getInfo() || ctable || ctableCount) {
43 return false;
44 }
45
46 SkBitmap bitmap;
47 if (!bitmap.installPixels(info, pixels, rowBytes)) {
48 return false;
49 }
50
51 bitmap.eraseColor(SK_ColorTRANSPARENT);
52 SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
53 canvas.drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
54
55 return true;
56 }
OLDNEW
« gm/pictureimagegenerator.cpp ('K') | « src/core/SkPictureImageGenerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698