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

Side by Side Diff: Source/platform/graphics/GraphicsContext.h

Issue 1164683007: Copy SkMetaData before painting printed plugin contents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/graphics/GraphicsContext.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 (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008-2009 Torch Mobile, Inc. 3 * Copyright (C) 2008-2009 Torch Mobile, Inc.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 19 matching lines...) Expand all
30 30
31 #include "platform/PlatformExport.h" 31 #include "platform/PlatformExport.h"
32 #include "platform/fonts/Font.h" 32 #include "platform/fonts/Font.h"
33 #include "platform/geometry/FloatRect.h" 33 #include "platform/geometry/FloatRect.h"
34 #include "platform/geometry/FloatRoundedRect.h" 34 #include "platform/geometry/FloatRoundedRect.h"
35 #include "platform/graphics/DashArray.h" 35 #include "platform/graphics/DashArray.h"
36 #include "platform/graphics/DrawLooperBuilder.h" 36 #include "platform/graphics/DrawLooperBuilder.h"
37 #include "platform/graphics/ImageOrientation.h" 37 #include "platform/graphics/ImageOrientation.h"
38 #include "platform/graphics/GraphicsContextState.h" 38 #include "platform/graphics/GraphicsContextState.h"
39 #include "platform/graphics/skia/SkiaUtils.h" 39 #include "platform/graphics/skia/SkiaUtils.h"
40 #include "third_party/skia/include/core/SkMetaData.h"
40 #include "third_party/skia/include/core/SkPictureRecorder.h" 41 #include "third_party/skia/include/core/SkPictureRecorder.h"
41 #include "third_party/skia/include/core/SkRegion.h" 42 #include "third_party/skia/include/core/SkRegion.h"
42 #include "wtf/FastAllocBase.h" 43 #include "wtf/FastAllocBase.h"
43 #include "wtf/Forward.h" 44 #include "wtf/Forward.h"
44 #include "wtf/Noncopyable.h" 45 #include "wtf/Noncopyable.h"
45 #include "wtf/PassOwnPtr.h" 46 #include "wtf/PassOwnPtr.h"
46 47
47 class SkBitmap; 48 class SkBitmap;
48 class SkImage; 49 class SkImage;
49 class SkPaint; 50 class SkPaint;
(...skipping 16 matching lines...) Expand all
66 enum AccessMode { 67 enum AccessMode {
67 ReadOnly, 68 ReadOnly,
68 ReadWrite 69 ReadWrite
69 }; 70 };
70 71
71 enum DisabledMode { 72 enum DisabledMode {
72 NothingDisabled = 0, // Run as normal. 73 NothingDisabled = 0, // Run as normal.
73 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of th e context from performance tests. 74 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of th e context from performance tests.
74 }; 75 };
75 76
76 explicit GraphicsContext(DisplayItemList*, DisabledMode = NothingDisabled); 77 explicit GraphicsContext(DisplayItemList*, DisabledMode = NothingDisabled, S kMetaData* = 0);
77 78
78 // TODO(chrishtr): Once Slimming Paint launches this should be removed (crbu g.com/471333). 79 // TODO(chrishtr): Once Slimming Paint launches this should be removed (crbu g.com/471333).
79 // A 0 canvas is allowed, but in such cases the context must only have canva s 80 // A 0 canvas is allowed, but in such cases the context must only have canva s
80 // related commands called when within a beginRecording/endRecording block. 81 // related commands called when within a beginRecording/endRecording block.
81 // Furthermore, save/restore calls must be balanced any time the canvas is 0 . 82 // Furthermore, save/restore calls must be balanced any time the canvas is 0 .
82 static PassOwnPtr<GraphicsContext> deprecatedCreateWithCanvas(SkCanvas*, Dis abledMode = NothingDisabled); 83 static PassOwnPtr<GraphicsContext> deprecatedCreateWithCanvas(SkCanvas*, Dis abledMode = NothingDisabled, SkMetaData* = 0);
83 84
84 ~GraphicsContext(); 85 ~GraphicsContext();
85 86
86 SkCanvas* canvas() { return m_canvas; } 87 SkCanvas* canvas() { return m_canvas; }
87 const SkCanvas* canvas() const { return m_canvas; } 88 const SkCanvas* canvas() const { return m_canvas; }
88 89
89 DisplayItemList* displayItemList() { return m_displayItemList; } 90 DisplayItemList* displayItemList() { return m_displayItemList; }
90 91
91 void resetCanvas(SkCanvas*); 92 void resetCanvas(SkCanvas*);
92 93
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // public decl needed for OwnPtr wrapper. 300 // public decl needed for OwnPtr wrapper.
300 class RecordingState; 301 class RecordingState;
301 302
302 #if ENABLE(ASSERT) 303 #if ENABLE(ASSERT)
303 void setInDrawingRecorder(bool); 304 void setInDrawingRecorder(bool);
304 #endif 305 #endif
305 306
306 static PassRefPtr<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFi lter); 307 static PassRefPtr<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFi lter);
307 308
308 private: 309 private:
309 explicit GraphicsContext(SkCanvas*, DisplayItemList*, DisabledMode = Nothing Disabled); 310 explicit GraphicsContext(SkCanvas*, DisplayItemList*, DisabledMode = Nothing Disabled, SkMetaData* = 0);
310 311
311 const GraphicsContextState* immutableState() const { return m_paintState; } 312 const GraphicsContextState* immutableState() const { return m_paintState; }
312 313
313 GraphicsContextState* mutableState() 314 GraphicsContextState* mutableState()
314 { 315 {
315 realizePaintSave(); 316 realizePaintSave();
316 return m_paintState; 317 return m_paintState;
317 } 318 }
318 319
319 template<typename DrawTextFunc> 320 template<typename DrawTextFunc>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 m_paintState = m_paintStateStack[m_paintStateIndex].get(); 364 m_paintState = m_paintStateStack[m_paintStateIndex].get();
364 m_paintState->copy(*priorPaintState); 365 m_paintState->copy(*priorPaintState);
365 } 366 }
366 } 367 }
367 } 368 }
368 369
369 void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& round edHoleRect, const Color&); 370 void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& round edHoleRect, const Color&);
370 371
371 bool isRecording() const; 372 bool isRecording() const;
372 373
374 const SkMetaData& metaData() const { return m_metaData; }
375
373 // null indicates painting is contextDisabled. Never delete this object. 376 // null indicates painting is contextDisabled. Never delete this object.
374 SkCanvas* m_canvas; 377 SkCanvas* m_canvas;
375 378
376 // This stores the canvas object used to construct the GraphicsContext, if a ny. It is only 379 // This stores the canvas object used to construct the GraphicsContext, if a ny. It is only
377 // used when Slimming Paint is active. 380 // used when Slimming Paint is active.
378 SkCanvas* m_originalCanvas; 381 SkCanvas* m_originalCanvas;
379 382
380 // This being null indicates not to paint into a DisplayItemList, and instea d directly into the canvas. 383 // This being null indicates not to paint into a DisplayItemList, and instea d directly into the canvas.
381 DisplayItemList* m_displayItemList; 384 DisplayItemList* m_displayItemList;
382 385
383 // Paint states stack. Enables local drawing state change with save()/restor e() calls. 386 // Paint states stack. Enables local drawing state change with save()/restor e() calls.
384 // This state controls the appearance of drawn content. 387 // This state controls the appearance of drawn content.
385 // We do not delete from this stack to avoid memory churn. 388 // We do not delete from this stack to avoid memory churn.
386 Vector<OwnPtr<GraphicsContextState>> m_paintStateStack; 389 Vector<OwnPtr<GraphicsContextState>> m_paintStateStack;
387 // Current index on the stack. May not be the last thing on the stack. 390 // Current index on the stack. May not be the last thing on the stack.
388 unsigned m_paintStateIndex; 391 unsigned m_paintStateIndex;
389 // Raw pointer to the current state. 392 // Raw pointer to the current state.
390 GraphicsContextState* m_paintState; 393 GraphicsContextState* m_paintState;
391 394
392 // Only used when Slimming Paint is off. When it is on, m_pictureRecorder is used instead. 395 // Only used when Slimming Paint is off. When it is on, m_pictureRecorder is used instead.
393 Vector<OwnPtr<RecordingState>> m_recordingStateStack; 396 Vector<OwnPtr<RecordingState>> m_recordingStateStack;
394 SkPictureRecorder m_pictureRecorder; 397 SkPictureRecorder m_pictureRecorder;
395 398
399 SkMetaData m_metaData;
400
396 #if ENABLE(ASSERT) 401 #if ENABLE(ASSERT)
397 unsigned m_layerCount; 402 unsigned m_layerCount;
398 bool m_disableDestructionChecks; 403 bool m_disableDestructionChecks;
399 bool m_inDrawingRecorder; 404 bool m_inDrawingRecorder;
400 #endif 405 #endif
401 406
402 const DisabledMode m_disabledState; 407 const DisabledMode m_disabledState;
403 408
404 float m_deviceScaleFactor; 409 float m_deviceScaleFactor;
405 410
406 unsigned m_accelerated : 1; 411 unsigned m_accelerated : 1;
407 unsigned m_printing : 1; 412 unsigned m_printing : 1;
413 unsigned m_hasMetaData : 1;
408 }; 414 };
409 415
410 } // namespace blink 416 } // namespace blink
411 417
412 #endif // GraphicsContext_h 418 #endif // GraphicsContext_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/GraphicsContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698