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

Side by Side Diff: Source/core/html/HTMLCanvasElement.cpp

Issue 293963009: Fixing GraphicsContext state checks to support oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updated test expectations Created 6 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 HTMLCanvasElement::~HTMLCanvasElement() 92 HTMLCanvasElement::~HTMLCanvasElement()
93 { 93 {
94 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory); 94 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory);
95 HashSet<CanvasObserver*>::iterator end = m_observers.end(); 95 HashSet<CanvasObserver*>::iterator end = m_observers.end();
96 for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it) 96 for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
97 (*it)->canvasDestroyed(this); 97 (*it)->canvasDestroyed(this);
98 98
99 #if !ENABLE(OILPAN) 99 #if !ENABLE(OILPAN)
100 m_context.clear(); // Ensure this goes away before the ImageBuffer. 100 // Ensure these go away before the ImageBuffer.
101 m_contextStateSaver.clear();
102 m_context.clear();
101 #endif 103 #endif
102 } 104 }
103 105
104 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt ring& value) 106 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt ring& value)
105 { 107 {
106 if (name == widthAttr || name == heightAttr) 108 if (name == widthAttr || name == heightAttr)
107 reset(); 109 reset();
108 HTMLElement::parseAttribute(name, value); 110 HTMLElement::parseAttribute(name, value);
109 } 111 }
110 112
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (!surface->isValid()) 491 if (!surface->isValid())
490 return; 492 return;
491 493
492 m_imageBuffer = ImageBuffer::create(surface.release()); 494 m_imageBuffer = ImageBuffer::create(surface.release());
493 m_imageBuffer->setClient(this); 495 m_imageBuffer->setClient(this);
494 496
495 m_didFailToCreateImageBuffer = false; 497 m_didFailToCreateImageBuffer = false;
496 498
497 updateExternallyAllocatedMemory(); 499 updateExternallyAllocatedMemory();
498 500
499 if (is3D()) { 501 if (is3D()) {
Mads Ager (chromium) 2014/05/22 05:53:03 Is it possible to get here where m_context has not
Justin Novosad 2014/05/26 17:17:51 Not supposed to. Line 524
500 // Early out for WebGL canvases 502 // Early out for WebGL canvases
501 return; 503 return;
502 } 504 }
503 505
504 m_imageBuffer->setClient(this); 506 m_imageBuffer->setClient(this);
505 m_imageBuffer->context()->setShouldClampToSourceRect(false); 507 m_imageBuffer->context()->setShouldClampToSourceRect(false);
506 m_imageBuffer->context()->disableAntialiasingOptimizationForHairlineImages() ; 508 m_imageBuffer->context()->disableAntialiasingOptimizationForHairlineImages() ;
507 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol ationQuality); 509 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol ationQuality);
508 // Enabling MSAA overrides a request to disable antialiasing. This is true r egardless of whether the 510 // Enabling MSAA overrides a request to disable antialiasing. This is true r egardless of whether the
509 // rendering mode is accelerated or not. For consistency, we don't want to a pply AA in accelerated 511 // rendering mode is accelerated or not. For consistency, we don't want to a pply AA in accelerated
510 // canvases but not in unaccelerated canvases. 512 // canvases but not in unaccelerated canvases.
511 if (!msaaSampleCount && document().settings() && !document().settings()->ant ialiased2dCanvasEnabled()) 513 if (!msaaSampleCount && document().settings() && !document().settings()->ant ialiased2dCanvasEnabled())
512 m_imageBuffer->context()->setShouldAntialias(false); 514 m_imageBuffer->context()->setShouldAntialias(false);
513 // GraphicsContext's defaults don't always agree with the 2d canvas spec. 515 // GraphicsContext's defaults don't always agree with the 2d canvas spec.
514 // See CanvasRenderingContext2D::State::State() for more information. 516 // See CanvasRenderingContext2D::State::State() for more information.
515 m_imageBuffer->context()->setMiterLimit(10); 517 m_imageBuffer->context()->setMiterLimit(10);
516 m_imageBuffer->context()->setStrokeThickness(1); 518 m_imageBuffer->context()->setStrokeThickness(1);
519 #if !ASSERT_DISABLED
520 m_imageBuffer->context()->disableDestructionChecks(); // 2D canvas is allowe d to leave context in an unfinalized state.
f(malita) 2014/05/27 20:28:22 If we have exclusive control of the initialization
Justin Novosad 2014/05/27 22:25:25 Right no ImageBuffer is not explicitly aware that
521 #endif
517 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer- >context())); 522 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer- >context()));
518 523
519 if (m_context) 524 if (m_context)
520 setNeedsCompositingUpdate(); 525 setNeedsCompositingUpdate();
521 } 526 }
522 527
523 void HTMLCanvasElement::notifySurfaceInvalid() 528 void HTMLCanvasElement::notifySurfaceInvalid()
524 { 529 {
525 if (m_context && m_context->is2d()) { 530 if (m_context && m_context->is2d()) {
526 CanvasRenderingContext2D* context2d = toCanvasRenderingContext2D(m_conte xt.get()); 531 CanvasRenderingContext2D* context2d = toCanvasRenderingContext2D(m_conte xt.get());
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 { 698 {
694 return !originClean(); 699 return !originClean();
695 } 700 }
696 701
697 FloatSize HTMLCanvasElement::sourceSize() const 702 FloatSize HTMLCanvasElement::sourceSize() const
698 { 703 {
699 return FloatSize(width(), height()); 704 return FloatSize(width(), height());
700 } 705 }
701 706
702 } 707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698