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 @@
#include "platform/graphics/ContentLayerDelegate.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/geometry/IntRect.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
......@@ -90,11 +89,9 @@ void ContentLayerDelegate::paintContents(
paintController.paintArtifact().appendToWebDisplayItemList(
webDisplayItemList);
if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) {
// TODO(ccameron): This color space should come from the GraphicsLayer.
// https://crbug.com/667411
if (m_graphicsLayer->colorBehavior().isTransformToTargetColorSpace()) {
webDisplayItemList->setImpliedColorSpace(gfx::ColorSpace::FromSkColorSpace(
ColorBehavior::globalTargetColorSpace()));
m_graphicsLayer->colorBehavior().targetColorSpace()));
}
paintController.setDisplayItemConstructionIsDisabled(false);
paintController.setSubsequenceCachingIsDisabled(false);
......
......@@ -56,11 +56,13 @@ namespace blink {
GraphicsContext::GraphicsContext(PaintController& paintController,
DisabledMode disableContextOrPainting,
SkMetaData* metaData)
SkMetaData* metaData,
ColorBehavior colorBehavior)
: m_canvas(nullptr),
m_paintController(paintController),
m_paintStateStack(),
m_paintStateIndex(0),
m_colorBehavior(colorBehavior),
#if DCHECK_IS_ON()
m_layerCount(0),
m_disableDestructionChecks(false),
......
......@@ -30,6 +30,7 @@
#include "platform/PlatformExport.h"
#include "platform/fonts/Font.h"
#include "platform/graphics/ColorBehavior.h"
#include "platform/graphics/DashArray.h"
#include "platform/graphics/DrawLooperBuilder.h"
#include "platform/graphics/GraphicsContextState.h"
......@@ -70,9 +71,11 @@ class PLATFORM_EXPORT GraphicsContext {
// the context from performance tests.
};
explicit GraphicsContext(PaintController&,
DisabledMode = NothingDisabled,
SkMetaData* = 0);
explicit GraphicsContext(
PaintController&,
DisabledMode = NothingDisabled,
SkMetaData* = 0,
ColorBehavior = ColorBehavior::transformToGlobalTarget());
~GraphicsContext();
......@@ -80,6 +83,7 @@ class PLATFORM_EXPORT GraphicsContext {
const SkCanvas* canvas() const { return m_canvas; }
PaintController& getPaintController() { return m_paintController; }
const ColorBehavior& getColorBehavior() const { return m_colorBehavior; }
bool contextDisabled() const { return m_disabledState; }
......@@ -446,6 +450,8 @@ class PLATFORM_EXPORT GraphicsContext {
SkMetaData m_metaData;
const ColorBehavior m_colorBehavior;
#if DCHECK_IS_ON()
int m_layerCount;
bool m_disableDestructionChecks;
......
......@@ -110,12 +110,18 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
m_contentsLayerId(0),
m_scrollableArea(nullptr),
m_renderingContext3d(0),
m_colorBehavior(ColorBehavior::transformToGlobalTarget()),
m_hasPreferredRasterBounds(false) {
#if ENABLE(ASSERT)
if (m_client)
m_client->verifyNotPainting();
#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_layer = Platform::current()->compositorSupport()->createContentLayer(
m_contentLayerDelegate.get());
......@@ -327,7 +333,8 @@ bool GraphicsLayer::paintWithoutCommit(
return false;
}
GraphicsContext context(getPaintController(), disabledMode);
GraphicsContext context(getPaintController(), disabledMode, nullptr,
m_colorBehavior);
m_previousInterestRect = *interestRect;
m_client->paintContents(this, context, m_paintingPhase, *interestRect);
......@@ -1234,7 +1241,9 @@ sk_sp<SkPicture> GraphicsLayer::capturePicture() {
return nullptr;
IntSize intSize = expandedIntSize(size());
GraphicsContext graphicsContext(getPaintController());
GraphicsContext graphicsContext(getPaintController(),
GraphicsContext::NothingDisabled, nullptr,
m_colorBehavior);
graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize));
getPaintController().paintArtifact().replay(graphicsContext);
return graphicsContext.endRecording();
......
......@@ -34,6 +34,7 @@
#include "platform/geometry/FloatSize.h"
#include "platform/geometry/IntRect.h"
#include "platform/graphics/Color.h"
#include "platform/graphics/ColorBehavior.h"
#include "platform/graphics/CompositorElementId.h"
#include "platform/graphics/ContentLayerDelegate.h"
#include "platform/graphics/GraphicsContext.h"
......@@ -286,6 +287,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient,
void setPreferredRasterBounds(const IntSize&);
void clearPreferredRasterBounds();
const ColorBehavior& colorBehavior() const { return m_colorBehavior; }
protected:
String debugName(cc::Layer*) const;
bool shouldFlattenTransform() const { return m_shouldFlattenTransform; }
......@@ -402,6 +405,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient,
std::unique_ptr<PaintController> m_paintController;
ColorBehavior m_colorBehavior;
IntRect m_previousInterestRect;
IntSize m_preferredRasterBounds;
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