| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkDeferredCanvas.h" | 9 #include "SkDeferredCanvas.h" |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (paint) { | 39 if (paint) { |
| 40 SkShader* shader = paint->getShader(); | 40 SkShader* shader = paint->getShader(); |
| 41 // Here we detect the case where the shader is an SkBitmapProcShader | 41 // Here we detect the case where the shader is an SkBitmapProcShader |
| 42 // with a gpu texture attached. Checking this without RTTI | 42 // with a gpu texture attached. Checking this without RTTI |
| 43 // requires making the assumption that only gradient shaders | 43 // requires making the assumption that only gradient shaders |
| 44 // and SkBitmapProcShader implement asABitmap(). The following | 44 // and SkBitmapProcShader implement asABitmap(). The following |
| 45 // code may need to be revised if that assumption is ever broken. | 45 // code may need to be revised if that assumption is ever broken. |
| 46 if (shader && !shader->asAGradient(NULL)) { | 46 if (shader && !shader->asAGradient(NULL)) { |
| 47 SkBitmap bm; | 47 SkBitmap bm; |
| 48 if (shader->asABitmap(&bm, NULL, NULL) && | 48 if (shader->asABitmap(&bm, NULL, NULL) && |
| 49 NULL != bm.getTexture()) { | 49 bm.getTexture()) { |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 | 56 |
| 57 //----------------------------------------------------------------------------- | 57 //----------------------------------------------------------------------------- |
| 58 // DeferredPipeController | 58 // DeferredPipeController |
| 59 //----------------------------------------------------------------------------- | 59 //----------------------------------------------------------------------------- |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 fFreshFrame = false; | 329 fFreshFrame = false; |
| 330 return ret; | 330 return ret; |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool SkDeferredDevice::hasPendingCommands() { | 333 bool SkDeferredDevice::hasPendingCommands() { |
| 334 return fPipeController.hasPendingCommands(); | 334 return fPipeController.hasPendingCommands(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void SkDeferredDevice::aboutToDraw() | 337 void SkDeferredDevice::aboutToDraw() |
| 338 { | 338 { |
| 339 if (NULL != fNotificationClient) { | 339 if (fNotificationClient) { |
| 340 fNotificationClient->prepareForDraw(); | 340 fNotificationClient->prepareForDraw(); |
| 341 } | 341 } |
| 342 if (fCanDiscardCanvasContents) { | 342 if (fCanDiscardCanvasContents) { |
| 343 if (NULL != fSurface) { | 343 if (fSurface) { |
| 344 fSurface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeM
ode); | 344 fSurface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeM
ode); |
| 345 } | 345 } |
| 346 fCanDiscardCanvasContents = false; | 346 fCanDiscardCanvasContents = false; |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 void SkDeferredDevice::flushPendingCommands(PlaybackMode playbackMode) { | 350 void SkDeferredDevice::flushPendingCommands(PlaybackMode playbackMode) { |
| 351 if (!fPipeController.hasPendingCommands()) { | 351 if (!fPipeController.hasPendingCommands()) { |
| 352 return; | 352 return; |
| 353 } | 353 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (fDeferredDrawing) { | 597 if (fDeferredDrawing) { |
| 598 this->getDeferredDevice()->flushPendingCommands(kSilent_PlaybackMode); | 598 this->getDeferredDevice()->flushPendingCommands(kSilent_PlaybackMode); |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 | 601 |
| 602 SkDeferredCanvas::~SkDeferredCanvas() { | 602 SkDeferredCanvas::~SkDeferredCanvas() { |
| 603 } | 603 } |
| 604 | 604 |
| 605 SkSurface* SkDeferredCanvas::setSurface(SkSurface* surface) { | 605 SkSurface* SkDeferredCanvas::setSurface(SkSurface* surface) { |
| 606 SkDeferredDevice* deferredDevice = this->getDeferredDevice(); | 606 SkDeferredDevice* deferredDevice = this->getDeferredDevice(); |
| 607 SkASSERT(NULL != deferredDevice); | 607 SkASSERT(deferredDevice); |
| 608 // By swapping the surface into the existing device, we preserve | 608 // By swapping the surface into the existing device, we preserve |
| 609 // all pending commands, which can help to seamlessly recover from | 609 // all pending commands, which can help to seamlessly recover from |
| 610 // a lost accelerated graphics context. | 610 // a lost accelerated graphics context. |
| 611 deferredDevice->setSurface(surface); | 611 deferredDevice->setSurface(surface); |
| 612 return surface; | 612 return surface; |
| 613 } | 613 } |
| 614 | 614 |
| 615 SkDeferredCanvas::NotificationClient* SkDeferredCanvas::setNotificationClient( | 615 SkDeferredCanvas::NotificationClient* SkDeferredCanvas::setNotificationClient( |
| 616 NotificationClient* notificationClient) { | 616 NotificationClient* notificationClient) { |
| 617 | 617 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 937 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
| 938 this->drawingCanvas()->setDrawFilter(filter); | 938 this->drawingCanvas()->setDrawFilter(filter); |
| 939 this->INHERITED::setDrawFilter(filter); | 939 this->INHERITED::setDrawFilter(filter); |
| 940 this->recordedDrawCommand(); | 940 this->recordedDrawCommand(); |
| 941 return filter; | 941 return filter; |
| 942 } | 942 } |
| 943 | 943 |
| 944 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 944 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
| 945 return this->drawingCanvas(); | 945 return this->drawingCanvas(); |
| 946 } | 946 } |
| OLD | NEW |