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

Side by Side Diff: src/utils/SkDeferredCanvas.cpp

Issue 933043006: Implement SkBaseDevice snapshot support Base URL: https://skia.googlesource.com/skia.git@skimage-filters-04-snapshot-devices
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | tests/DeferredCanvasTest.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 /* 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { 252 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE {
253 return false; 253 return false;
254 } 254 }
255 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, 255 virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
256 const SkImageFilter::Context&, SkBitmap*, SkIPoint* ) SK_OVERRIDE { 256 const SkImageFilter::Context&, SkBitmap*, SkIPoint* ) SK_OVERRIDE {
257 return false; 257 return false;
258 } 258 }
259 259
260 private: 260 private:
261 void flush() SK_OVERRIDE; 261 void flush() SK_OVERRIDE;
262 void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE {} 262 void replaceBitmapBackend(const SkBitmap&) SK_OVERRIDE {}
263 263
264 void beginRecording(); 264 void beginRecording();
265 void init(); 265 void init();
266 void aboutToDraw(); 266 void aboutToDraw();
267 void prepareForImmediatePixelWrite(); 267 void prepareForImmediatePixelWrite();
268 268
269 DeferredPipeController fPipeController; 269 DeferredPipeController fPipeController;
270 SkGPipeWriter fPipeWriter; 270 SkGPipeWriter fPipeWriter;
271 SkCanvas* fImmediateCanvas; 271 SkCanvas* fImmediateCanvas;
272 SkCanvas* fRecordingCanvas; 272 SkCanvas* fRecordingCanvas;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 bool SkDeferredDevice::hasPendingCommands() { 346 bool SkDeferredDevice::hasPendingCommands() {
347 return fPipeController.hasPendingCommands(); 347 return fPipeController.hasPendingCommands();
348 } 348 }
349 349
350 void SkDeferredDevice::aboutToDraw() 350 void SkDeferredDevice::aboutToDraw()
351 { 351 {
352 if (fNotificationClient) { 352 if (fNotificationClient) {
353 fNotificationClient->prepareForDraw(); 353 fNotificationClient->prepareForDraw();
354 } 354 }
355 if (fCanDiscardCanvasContents) { 355 if (fCanDiscardCanvasContents) {
356 if (fSurface) { 356 fImmediateCanvas->discard();
357 fSurface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeM ode);
358 }
359 fCanDiscardCanvasContents = false; 357 fCanDiscardCanvasContents = false;
360 } 358 }
361 } 359 }
362 360
363 void SkDeferredDevice::flushPendingCommands(PlaybackMode playbackMode) { 361 void SkDeferredDevice::flushPendingCommands(PlaybackMode playbackMode) {
364 if (!fPipeController.hasPendingCommands()) { 362 if (!fPipeController.hasPendingCommands()) {
365 return; 363 return;
366 } 364 }
367 if (playbackMode == kNormal_PlaybackMode) { 365 if (playbackMode == kNormal_PlaybackMode) {
368 aboutToDraw(); 366 aboutToDraw();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 return immediateDevice()->accessRenderTarget(); 435 return immediateDevice()->accessRenderTarget();
438 } 436 }
439 437
440 void SkDeferredDevice::prepareForImmediatePixelWrite() { 438 void SkDeferredDevice::prepareForImmediatePixelWrite() {
441 // The purpose of the following code is to make sure commands are flushed, t hat 439 // The purpose of the following code is to make sure commands are flushed, t hat
442 // aboutToDraw() is called and that notifyContentWillChange is called, witho ut 440 // aboutToDraw() is called and that notifyContentWillChange is called, witho ut
443 // calling anything redundantly. 441 // calling anything redundantly.
444 if (fPipeController.hasPendingCommands()) { 442 if (fPipeController.hasPendingCommands()) {
445 this->flushPendingCommands(kNormal_PlaybackMode); 443 this->flushPendingCommands(kNormal_PlaybackMode);
446 } else { 444 } else {
447 bool mustNotifyDirectly = !fCanDiscardCanvasContents;
448 this->aboutToDraw(); 445 this->aboutToDraw();
449 if (mustNotifyDirectly) {
450 fSurface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMo de);
451 }
452 } 446 }
453 447
454 fImmediateCanvas->flush(); 448 fImmediateCanvas->flush();
455 } 449 }
456 450
457 bool SkDeferredDevice::onWritePixels(const SkImageInfo& info, const void* pixels , size_t rowBytes, 451 bool SkDeferredDevice::onWritePixels(const SkImageInfo& info, const void* pixels , size_t rowBytes,
458 int x, int y) { 452 int x, int y) {
459 SkASSERT(x >= 0 && y >= 0); 453 SkASSERT(x >= 0 && y >= 0);
460 SkASSERT(x + info.width() <= width()); 454 SkASSERT(x + info.width() <= width());
461 SkASSERT(y + info.height() <= height()); 455 SkASSERT(y + info.height() <= height());
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { 973 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
980 this->drawingCanvas()->setDrawFilter(filter); 974 this->drawingCanvas()->setDrawFilter(filter);
981 this->INHERITED::setDrawFilter(filter); 975 this->INHERITED::setDrawFilter(filter);
982 this->recordedDrawCommand(); 976 this->recordedDrawCommand();
983 return filter; 977 return filter;
984 } 978 }
985 979
986 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { 980 SkCanvas* SkDeferredCanvas::canvasForDrawIter() {
987 return this->drawingCanvas(); 981 return this->drawingCanvas();
988 } 982 }
OLDNEW
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698