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

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

Issue 1224783002: add matrix options to drawDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: modify 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
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkDrawable.h" 9 #include "SkDrawable.h"
10 #include "SkThread.h" 10 #include "SkThread.h"
(...skipping 14 matching lines...) Expand all
25 25
26 static void draw_bbox(SkCanvas* canvas, const SkRect& r) { 26 static void draw_bbox(SkCanvas* canvas, const SkRect& r) {
27 SkPaint paint; 27 SkPaint paint;
28 paint.setStyle(SkPaint::kStroke_Style); 28 paint.setStyle(SkPaint::kStroke_Style);
29 paint.setColor(0xFFFF7088); 29 paint.setColor(0xFFFF7088);
30 canvas->drawRect(r, paint); 30 canvas->drawRect(r, paint);
31 canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint); 31 canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint);
32 canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint); 32 canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint);
33 } 33 }
34 34
35 void SkDrawable::draw(SkCanvas* canvas) { 35 void SkDrawable::draw(SkCanvas* canvas, const SkMatrix* matrix) {
36 SkAutoCanvasRestore acr(canvas, true); 36 SkAutoCanvasRestore acr(canvas, true);
37 if (matrix) {
38 canvas->concat(*matrix);
39 }
37 this->onDraw(canvas); 40 this->onDraw(canvas);
38 41
39 if (false) { 42 if (false) {
40 draw_bbox(canvas, this->getBounds()); 43 draw_bbox(canvas, this->getBounds());
41 } 44 }
42 } 45 }
43 46
47 void SkDrawable::draw(SkCanvas* canvas, SkScalar x, SkScalar y) {
48 SkMatrix matrix = SkMatrix::MakeTrans(x, y);
49 this->draw(canvas, &matrix);
50 }
51
44 SkPicture* SkDrawable::newPictureSnapshot() { 52 SkPicture* SkDrawable::newPictureSnapshot() {
45 return this->onNewPictureSnapshot(); 53 return this->onNewPictureSnapshot();
46 } 54 }
47 55
48 uint32_t SkDrawable::getGenerationID() { 56 uint32_t SkDrawable::getGenerationID() {
49 if (0 == fGenerationID) { 57 if (0 == fGenerationID) {
50 fGenerationID = next_generation_id(); 58 fGenerationID = next_generation_id();
51 } 59 }
52 return fGenerationID; 60 return fGenerationID;
53 } 61 }
(...skipping 14 matching lines...) Expand all
68 SkPictureRecorder recorder; 76 SkPictureRecorder recorder;
69 77
70 const SkRect bounds = this->getBounds(); 78 const SkRect bounds = this->getBounds();
71 SkCanvas* canvas = recorder.beginRecording(bounds, NULL, 0); 79 SkCanvas* canvas = recorder.beginRecording(bounds, NULL, 0);
72 this->draw(canvas); 80 this->draw(canvas);
73 if (false) { 81 if (false) {
74 draw_bbox(canvas, bounds); 82 draw_bbox(canvas, bounds);
75 } 83 }
76 return recorder.endRecording(); 84 return recorder.endRecording();
77 } 85 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkRecordDraw.cpp » ('j') | src/core/SkRecords.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698