Commit a9ee0245 authored by ccameron's avatar ccameron Committed by Commit bot

Add ColorBehavior to GraphicsLayer and GraphicsContext

Specify the ColorBehavior from GraphicsLayer to GraphicsContext.

Use the GraphicsLayer's ColorBehavior to determine if the
WebDisplayItemList has an implied color space.

This does not change any behavior, but makes implied behavior
explicit.

The ColorBehavior in GraphicsLayer is unused, but will be used by
future patches.

BUG=667411

Review-Url: https://codereview.chromium.org/2552893005
Cr-Commit-Position: refs/heads/master@{#437648}
parent f715bf88
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "platform/graphics/ContentLayerDelegate.h" #include "platform/graphics/ContentLayerDelegate.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/geometry/IntRect.h" #include "platform/geometry/IntRect.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h" #include "platform/graphics/GraphicsLayer.h"
...@@ -90,11 +89,9 @@ void ContentLayerDelegate::paintContents( ...@@ -90,11 +89,9 @@ void ContentLayerDelegate::paintContents(
paintController.paintArtifact().appendToWebDisplayItemList( paintController.paintArtifact().appendToWebDisplayItemList(
webDisplayItemList); webDisplayItemList);
if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { if (m_graphicsLayer->colorBehavior().isTransformToTargetColorSpace()) {
// TODO(ccameron): This color space should come from the GraphicsLayer.
// https://crbug.com/667411
webDisplayItemList->setImpliedColorSpace(gfx::ColorSpace::FromSkColorSpace( webDisplayItemList->setImpliedColorSpace(gfx::ColorSpace::FromSkColorSpace(
ColorBehavior::globalTargetColorSpace())); m_graphicsLayer->colorBehavior().targetColorSpace()));
} }
paintController.setDisplayItemConstructionIsDisabled(false); paintController.setDisplayItemConstructionIsDisabled(false);
paintController.setSubsequenceCachingIsDisabled(false); paintController.setSubsequenceCachingIsDisabled(false);
......
...@@ -56,11 +56,13 @@ namespace blink { ...@@ -56,11 +56,13 @@ namespace blink {
GraphicsContext::GraphicsContext(PaintController& paintController, GraphicsContext::GraphicsContext(PaintController& paintController,
DisabledMode disableContextOrPainting, DisabledMode disableContextOrPainting,
SkMetaData* metaData) SkMetaData* metaData,
ColorBehavior colorBehavior)
: m_canvas(nullptr), : m_canvas(nullptr),
m_paintController(paintController), m_paintController(paintController),
m_paintStateStack(), m_paintStateStack(),
m_paintStateIndex(0), m_paintStateIndex(0),
m_colorBehavior(colorBehavior),
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
m_layerCount(0), m_layerCount(0),
m_disableDestructionChecks(false), m_disableDestructionChecks(false),
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "platform/PlatformExport.h" #include "platform/PlatformExport.h"
#include "platform/fonts/Font.h" #include "platform/fonts/Font.h"
#include "platform/graphics/ColorBehavior.h"
#include "platform/graphics/DashArray.h" #include "platform/graphics/DashArray.h"
#include "platform/graphics/DrawLooperBuilder.h" #include "platform/graphics/DrawLooperBuilder.h"
#include "platform/graphics/GraphicsContextState.h" #include "platform/graphics/GraphicsContextState.h"
...@@ -70,9 +71,11 @@ class PLATFORM_EXPORT GraphicsContext { ...@@ -70,9 +71,11 @@ class PLATFORM_EXPORT GraphicsContext {
// the context from performance tests. // the context from performance tests.
}; };
explicit GraphicsContext(PaintController&, explicit GraphicsContext(
DisabledMode = NothingDisabled, PaintController&,
SkMetaData* = 0); DisabledMode = NothingDisabled,
SkMetaData* = 0,
ColorBehavior = ColorBehavior::transformToGlobalTarget());
~GraphicsContext(); ~GraphicsContext();
...@@ -80,6 +83,7 @@ class PLATFORM_EXPORT GraphicsContext { ...@@ -80,6 +83,7 @@ class PLATFORM_EXPORT GraphicsContext {
const SkCanvas* canvas() const { return m_canvas; } const SkCanvas* canvas() const { return m_canvas; }
PaintController& getPaintController() { return m_paintController; } PaintController& getPaintController() { return m_paintController; }
const ColorBehavior& getColorBehavior() const { return m_colorBehavior; }
bool contextDisabled() const { return m_disabledState; } bool contextDisabled() const { return m_disabledState; }
...@@ -446,6 +450,8 @@ class PLATFORM_EXPORT GraphicsContext { ...@@ -446,6 +450,8 @@ class PLATFORM_EXPORT GraphicsContext {
SkMetaData m_metaData; SkMetaData m_metaData;
const ColorBehavior m_colorBehavior;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
int m_layerCount; int m_layerCount;
bool m_disableDestructionChecks; bool m_disableDestructionChecks;
......
...@@ -110,12 +110,18 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) ...@@ -110,12 +110,18 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
m_contentsLayerId(0), m_contentsLayerId(0),
m_scrollableArea(nullptr), m_scrollableArea(nullptr),
m_renderingContext3d(0), m_renderingContext3d(0),
m_colorBehavior(ColorBehavior::transformToGlobalTarget()),
m_hasPreferredRasterBounds(false) { m_hasPreferredRasterBounds(false) {
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
if (m_client) if (m_client)
m_client->verifyNotPainting(); m_client->verifyNotPainting();
#endif #endif
// In true color mode, no inputs are adjusted, and all colors are converted
// at rasterization time.
if (RuntimeEnabledFeatures::trueColorRenderingEnabled())
m_colorBehavior = ColorBehavior::tag();
m_contentLayerDelegate = WTF::makeUnique<ContentLayerDelegate>(this); m_contentLayerDelegate = WTF::makeUnique<ContentLayerDelegate>(this);
m_layer = Platform::current()->compositorSupport()->createContentLayer( m_layer = Platform::current()->compositorSupport()->createContentLayer(
m_contentLayerDelegate.get()); m_contentLayerDelegate.get());
...@@ -327,7 +333,8 @@ bool GraphicsLayer::paintWithoutCommit( ...@@ -327,7 +333,8 @@ bool GraphicsLayer::paintWithoutCommit(
return false; return false;
} }
GraphicsContext context(getPaintController(), disabledMode); GraphicsContext context(getPaintController(), disabledMode, nullptr,
m_colorBehavior);
m_previousInterestRect = *interestRect; m_previousInterestRect = *interestRect;
m_client->paintContents(this, context, m_paintingPhase, *interestRect); m_client->paintContents(this, context, m_paintingPhase, *interestRect);
...@@ -1234,7 +1241,9 @@ sk_sp<SkPicture> GraphicsLayer::capturePicture() { ...@@ -1234,7 +1241,9 @@ sk_sp<SkPicture> GraphicsLayer::capturePicture() {
return nullptr; return nullptr;
IntSize intSize = expandedIntSize(size()); IntSize intSize = expandedIntSize(size());
GraphicsContext graphicsContext(getPaintController()); GraphicsContext graphicsContext(getPaintController(),
GraphicsContext::NothingDisabled, nullptr,
m_colorBehavior);
graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize));
getPaintController().paintArtifact().replay(graphicsContext); getPaintController().paintArtifact().replay(graphicsContext);
return graphicsContext.endRecording(); return graphicsContext.endRecording();
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "platform/geometry/FloatSize.h" #include "platform/geometry/FloatSize.h"
#include "platform/geometry/IntRect.h" #include "platform/geometry/IntRect.h"
#include "platform/graphics/Color.h" #include "platform/graphics/Color.h"
#include "platform/graphics/ColorBehavior.h"
#include "platform/graphics/CompositorElementId.h" #include "platform/graphics/CompositorElementId.h"
#include "platform/graphics/ContentLayerDelegate.h" #include "platform/graphics/ContentLayerDelegate.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
...@@ -286,6 +287,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient, ...@@ -286,6 +287,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient,
void setPreferredRasterBounds(const IntSize&); void setPreferredRasterBounds(const IntSize&);
void clearPreferredRasterBounds(); void clearPreferredRasterBounds();
const ColorBehavior& colorBehavior() const { return m_colorBehavior; }
protected: protected:
String debugName(cc::Layer*) const; String debugName(cc::Layer*) const;
bool shouldFlattenTransform() const { return m_shouldFlattenTransform; } bool shouldFlattenTransform() const { return m_shouldFlattenTransform; }
...@@ -402,6 +405,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient, ...@@ -402,6 +405,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient,
std::unique_ptr<PaintController> m_paintController; std::unique_ptr<PaintController> m_paintController;
ColorBehavior m_colorBehavior;
IntRect m_previousInterestRect; IntRect m_previousInterestRect;
IntSize m_preferredRasterBounds; IntSize m_preferredRasterBounds;
bool m_hasPreferredRasterBounds; bool m_hasPreferredRasterBounds;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment