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

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

Issue 722043005: Revert of allow pictures to have a full bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkCanvasDrawable.h" 9 #include "SkCanvasDrawable.h"
10 #include "SkThread.h" 10 #include "SkThread.h"
11 11
12 static int32_t next_generation_id() { 12 static int32_t next_generation_id() {
13 static int32_t gCanvasDrawableGenerationID; 13 static int32_t gCanvasDrawableGenerationID;
14 14
15 // do a loop in case our global wraps around, as we never want to 15 // do a loop in case our global wraps around, as we never want to
16 // return a 0 16 // return a 0
17 int32_t genID; 17 int32_t genID;
18 do { 18 do {
19 genID = sk_atomic_inc(&gCanvasDrawableGenerationID) + 1; 19 genID = sk_atomic_inc(&gCanvasDrawableGenerationID) + 1;
20 } while (0 == genID); 20 } while (0 == genID);
21 return genID; 21 return genID;
22 } 22 }
23 23
24 SkCanvasDrawable::SkCanvasDrawable() : fGenerationID(0) {} 24 SkCanvasDrawable::SkCanvasDrawable() : fGenerationID(0) {}
25 25
26 static void draw_bbox(SkCanvas* canvas, const SkRect& r) {
27 SkPaint paint;
28 paint.setStyle(SkPaint::kStroke_Style);
29 paint.setColor(0xFFFF7088);
30 canvas->drawRect(r, 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);
33 }
34
35 void SkCanvasDrawable::draw(SkCanvas* canvas) { 26 void SkCanvasDrawable::draw(SkCanvas* canvas) {
36 SkAutoCanvasRestore acr(canvas, true); 27 SkAutoCanvasRestore acr(canvas, true);
37 this->onDraw(canvas); 28 this->onDraw(canvas);
38
39 if (false) {
40 draw_bbox(canvas, this->getBounds());
41 }
42 } 29 }
43 30
44 SkPicture* SkCanvasDrawable::newPictureSnapshot(SkBBHFactory* bbhFactory, uint32 _t recordFlags) { 31 SkPicture* SkCanvasDrawable::newPictureSnapshot(SkBBHFactory* bbhFactory, uint32 _t recordFlags) {
45 return this->onNewPictureSnapshot(bbhFactory, recordFlags); 32 return this->onNewPictureSnapshot(bbhFactory, recordFlags);
46 } 33 }
47 34
48 uint32_t SkCanvasDrawable::getGenerationID() { 35 uint32_t SkCanvasDrawable::getGenerationID() {
49 if (0 == fGenerationID) { 36 if (0 == fGenerationID) {
50 fGenerationID = next_generation_id(); 37 fGenerationID = next_generation_id();
51 } 38 }
52 return fGenerationID; 39 return fGenerationID;
53 } 40 }
54 41
55 SkRect SkCanvasDrawable::getBounds() { 42 SkRect SkCanvasDrawable::getBounds() {
56 return this->onGetBounds(); 43 return this->onGetBounds();
57 } 44 }
58 45
59 void SkCanvasDrawable::notifyDrawingChanged() { 46 void SkCanvasDrawable::notifyDrawingChanged() {
60 fGenerationID = 0; 47 fGenerationID = 0;
61 } 48 }
62 49
63 //////////////////////////////////////////////////////////////////////////////// ///////// 50 //////////////////////////////////////////////////////////////////////////////// /////////
64 51
65 #include "SkPictureRecorder.h" 52 #include "SkPictureRecorder.h"
66 53
67 SkPicture* SkCanvasDrawable::onNewPictureSnapshot(SkBBHFactory* bbhFactory, uint 32_t recordFlags) { 54 SkPicture* SkCanvasDrawable::onNewPictureSnapshot(SkBBHFactory* bbhFactory, uint 32_t recordFlags) {
55 const SkRect bounds = this->getBounds();
68 SkPictureRecorder recorder; 56 SkPictureRecorder recorder;
69 57 this->draw(recorder.beginRecording(bounds.width(), bounds.height(), bbhFacto ry, recordFlags));
70 const SkRect bounds = this->getBounds();
71 SkCanvas* canvas = recorder.beginRecording(bounds, bbhFactory, recordFlags);
72 this->draw(canvas);
73 if (false) {
74 draw_bbox(canvas, bounds);
75 }
76 return recorder.endRecording(); 58 return recorder.endRecording();
77 } 59 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698