OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SampleApp.h" | 8 #include "SampleApp.h" |
8 | 9 |
9 #include "SkData.h" | 10 #include "SkData.h" |
10 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
11 #include "SkDevice.h" | 12 #include "SkDevice.h" |
12 #include "SkGraphics.h" | 13 #include "SkGraphics.h" |
13 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
14 #include "SkImageEncoder.h" | 15 #include "SkImageEncoder.h" |
15 #include "SkPaint.h" | 16 #include "SkPaint.h" |
16 #include "SkPicture.h" | 17 #include "SkPicture.h" |
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2378 | 2379 |
2379 canvas = writer.startRecording(pc, flags); | 2380 canvas = writer.startRecording(pc, flags); |
2380 //Must draw before controller goes out of scope and sends data | 2381 //Must draw before controller goes out of scope and sends data |
2381 this->INHERITED::draw(canvas); | 2382 this->INHERITED::draw(canvas); |
2382 //explicitly end recording to ensure writer is flushed before the memory | 2383 //explicitly end recording to ensure writer is flushed before the memory |
2383 //is freed in the deconstructor of the controller | 2384 //is freed in the deconstructor of the controller |
2384 writer.endRecording(); | 2385 writer.endRecording(); |
2385 } | 2386 } |
2386 } | 2387 } |
2387 | 2388 |
2388 #include "SkBounder.h" | |
2389 | |
2390 class DebugHitTestBounder : public SkBounder { | |
2391 public: | |
2392 DebugHitTestBounder(int x, int y) { | |
2393 fLoc.set(x, y); | |
2394 } | |
2395 | |
2396 virtual bool onIRect(const SkIRect& bounds) SK_OVERRIDE { | |
2397 if (bounds.contains(fLoc.x(), fLoc.y())) { | |
2398 // | |
2399 // Set a break-point here to see what was being drawn under | |
2400 // the click point (just needed a line of code to stop the debugger) | |
2401 // | |
2402 bounds.centerX(); | |
2403 } | |
2404 return true; | |
2405 } | |
2406 | |
2407 private: | |
2408 SkIPoint fLoc; | |
2409 typedef SkBounder INHERITED; | |
2410 }; | |
2411 | |
2412 void SampleView::onDraw(SkCanvas* canvas) { | 2389 void SampleView::onDraw(SkCanvas* canvas) { |
2413 this->onDrawBackground(canvas); | 2390 this->onDrawBackground(canvas); |
2414 | 2391 |
2415 DebugHitTestBounder bounder(fDebugHitTestLoc.x(), fDebugHitTestLoc.y()); | |
2416 if (fDebugHitTest) { | |
2417 canvas->setBounder(&bounder); | |
2418 } | |
2419 | |
2420 for (int i = 0; i < fRepeatCount; i++) { | 2392 for (int i = 0; i < fRepeatCount; i++) { |
2421 SkAutoCanvasRestore acr(canvas, true); | 2393 SkAutoCanvasRestore acr(canvas, true); |
2422 this->onDrawContent(canvas); | 2394 this->onDrawContent(canvas); |
2423 } | 2395 } |
2424 | 2396 |
2425 fDebugHitTest = false; | 2397 fDebugHitTest = false; |
scroggo
2014/06/03 13:52:59
Can you also remove fDebugHitTest? I think it will
reed1
2014/06/03 17:38:49
Done.
| |
2426 canvas->setBounder(NULL); | |
2427 } | 2398 } |
2428 | 2399 |
2429 void SampleView::onDrawBackground(SkCanvas* canvas) { | 2400 void SampleView::onDrawBackground(SkCanvas* canvas) { |
2430 canvas->drawColor(fBGColor); | 2401 canvas->drawColor(fBGColor); |
2431 } | 2402 } |
2432 | 2403 |
2433 /////////////////////////////////////////////////////////////////////////////// | 2404 /////////////////////////////////////////////////////////////////////////////// |
2434 | 2405 |
2435 template <typename T> void SkTBSort(T array[], int count) { | 2406 template <typename T> void SkTBSort(T array[], int count) { |
2436 for (int i = 1; i < count - 1; i++) { | 2407 for (int i = 1; i < count - 1; i++) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2565 SkGraphics::Init(); | 2536 SkGraphics::Init(); |
2566 SkEvent::Init(); | 2537 SkEvent::Init(); |
2567 } | 2538 } |
2568 | 2539 |
2569 // FIXME: this should be in a header | 2540 // FIXME: this should be in a header |
2570 void application_term(); | 2541 void application_term(); |
2571 void application_term() { | 2542 void application_term() { |
2572 SkEvent::Term(); | 2543 SkEvent::Term(); |
2573 SkGraphics::Term(); | 2544 SkGraphics::Term(); |
2574 } | 2545 } |
OLD | NEW |