mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
e1776c67f8
- Bug 1199885 - Part 2: Add AsyncDragMetrics. r=kats (220a4f445e)
- Bug 1149482 - Localize the 'none' string for APZ in about:support. r=dvander (3e0128f62e)
- Bug 1199885 - Part 3: Add 'apz.drag.enabled' preference for async scrollbars. r=kats (5133061d3f)
- Bug 1199885 - Part 4: Let the hit testing tree know about the scroll thumb. r=kats (26a9a69443)
- Bug 1199885 - Part 5: Make mRootLayerTreeID const to prove that there's no data races. r=kats (88e2eb80f1)
- Bug 1199885 - Part 8: Add FindScrollNode to locate the scrollbar thumb. r=kats (a545ec9569)
- Bug 1199885 - Part 9: Let APZC handle the drag events. r=kats (4cc0f88153)
- Bug 1199885 - Part 9.5: Make the mouse events APZC aware. r=kats (69bd4caf94)
- Bug 1199885 - Part 10: Add APZTeeManager API to start an async scroll. r=kats (e212ee2750)
- Bug 1199885 - Part 12: Add StartScrollbarDrag IPC message. r=kats (705af3b233)
- Bug 1199885 - Part 13: Let nsSliderFrame trigger async scrolling via StartScrollbarDrag. r=kats (d31b5a790d)
- put in gstreamer as of 2015-10-05 Bug 1146482 (7cca45858c)
- pointer style (f8041af438)
- Bug 1197097 - Don't use a context-wide cycle-detection mechanism for detecting cycles during JSON.stringify. This prevents nested (yet separate) JSON.stringify, and it causes that algorithm to be affected by specification-unrelated operations like toSource. r=jonco (09652471c1)
- align to ugly grammaer of 1114782 (c760693693)
- remove space (7158a0c2bf)
- align to FF/TFF (27138a55bb)
- Bug 1205887 - Verify that MOZILLA_VERSION was set correctly, r=glandium (2269e8f31b)
- Bug 1205012 - Allow rust source code in SpiderMonkey; r=mshal (9ebca9ed28)
- Bug 1197281 - Use MOZ_FIND_WINSDK_VERSION for MOZ_WINSDK_MAXVER on mingw. r=glandium (2910b2160e)
- Bug 1207893 - Refactor how build backend execution is summarized. r=gps (56d8fecbc2)
- Bug 1207893 - Allow to create multiple build backends at once. r=gps (d8cba87d2b)
- Bug 1207897 - Add a configure option to build multiple build backends. r=gps (f9c7851d02)
- Bug 1188555 - part 1 - remove write-only configure.in variable NO_LD_ARCHIVE_FLAGS; r=mshal (461958b100)
- Bug 1188555 - part 2 - remove write-only configure.in variables MKSHLIB_{UN,}FORCE_ALL; r=mshal (1813210dda)
- Bug 1207882 - Ensure chrome manifests are created in a directory that exists when processing jar manifests. r=gps (59165a64cb)
- Bug 1204712 - Handle wildcards properly for localized content in jar manifests. r=gps (54dfb632c7)
- Bug 1188551: treat assertion failures as bad mozconfig; r=mshal (e307769de7)
- Bug 1181040 - Set ${var}_IS_SET variables for mk_add_options-defined variables. r=gps (19f169556b)
- Bug 1193015 - Require MOZ_GLX_USE_SURFACE_SHARING to enable WebGL surface sharing on GLX. r=jgilbert (9aa4fa8f41)
- Bug 1211324 (part 1) - Remove BILINEAR and GAUSSIAN filter constants. (3d9290ef02)
- Bug 1211324 (part 2) - Make gfx::FILTER::GOOD convert to GraphicsFilter::FILTER_GOOD. r=mattwoodrow. (16e7607c70)
- Bug 1208365 (part 1) - Remove unused EXTEND_PAD_EDGE. r=Bas. (10920e2bb6)
- Bug 1208365 (part 2) - Remove gfxPattern::Extend(). r=bas. (3703b9748a)
- Bug 1208365 (part 3) - Change gfxPattern::mExtend from a GraphicsExtend to a gfx::ExtendMode. r=bas. (b105d06e91)
- Bug 1208365 (part 4) - Remove gfxPattern::GraphicsExtend. r=bas. (7a16d48995)
- Bug 1211324 (part 3) - Remove GraphicsFilter::FILTER_FAST and replace it with FILTER_BEST. r=mattwoodrow. (b5101e049f)
- Bug 1211324 (part 4) - Replace GraphicsFilter constants with gfx::Filter equivalents. r=mattwoodrow. (c19b6b030e)
- Bug 1190117 - Track mLastProducerID and mLastFrameID explicitly in ImageLayerProperties. r=roc (ed9a5c777f)
- Bug 1211324 (part 5) - Remove GraphicsFilter and gfxGraphicsFilter. r=mattwoodrow. (0bd4ce7160)
- Bug 1194954 - Fix -Wunreachable-code warnings in gfx/layers and gfx/thebes. r=BenWa (1a3d68c490)
- Bug 1180509 - Fix judder of icons in Australis doorhanger menu at the end of its scale-in animation. r=roc (9b4df470fa)
- Bug 1206915 - Make paint dumping to a file e10s-friendly. r=mattwoodrow (87d2e12c2b)
- Bug 1206915 - Handle nested PaintFrame() calls correctly during paint dumping. r=mattwoodrow,BenWa (d30f77fbdd)
- Fix max texture size handling in displayport clamping. (bug 1135907 follow-up, r=kats) (a791894332)
- Fix bogus assertion in nsLayoutUtils::SetDisplayPortMargins. (bug 1156409, r=botond, a=philor) (b635b21c34)
- Bug 1169879 - Use only the critical displayport when computing image visibility. r=tn (9ec91c9527)
- Bug 1169881 - Recompute image visibility when display port margins change. r=tn (35a5bd3a51)
- Bug 1197765 - Compare text content inside frame instead of the content node for ruby autohiding. r=dbaron (00cf5b7674)
- Bug 1173580 - Record content descriptions in APZ test data. r=kats (7a72d1ac0a)
- Bug 1178971 - Changed line snapping behaviour depending on even/odd-ness of stroke width. r=mstange (495b32dc23)
- Bug 1208953: [mp3] Don't parse data we've already parsed. r=cpearce (72eed4309f)
- Bug 1137151: Marked destructor of |android::MediaCodecReader| as protected, r=sotaro (0632b34bc5)
- Bug 1205351 - Replace nsBaseHashtable::Enumerate() calls in dom/media/ with iterators r=cpearce (45976c24c0)
- Bug 1133624 - Add lang-specific ruby rules to ua.css. r=dbaron (46788cc220)
- Bug 1133624 - followup add fuzzy maxdiff on CLOSED TREE (1b6b62aded)
- Bug 1180443 - Consider whitespace collapse when calculating intrinsic isize of ruby. r=dbaron (3862184acd)
- Bug 1153764 - Avoid explicitly doing break before when there is ruby span. r=roc (71b4ec7749)
- add gstreamer parts (7e562556be)
- some preferences aligned to FF (b26d0b389c)
- Bug 1166301 - If APZ is enabled, clip fixed background images at the layer level rather than the display item level. r=mattwoodrow (5644e22090)
- Bug 1144990 - Dump display items with class id and name, r=roc (aa2e227e35)
- Bug 1205087 - Remove LayerManager parameter for ShouldFixToViewport. r=roc (00a1f2e36f)
- Bug 1205087 - Make nsSVGIntegrationUtils paint frame continuations manually since combining them meant that our reference frame wasn't an ancestor of all painted frames. r=roc (e40f6b7b81)
- Bug 1195400 - Check ancestor geometry roots when determining scrollability of a layer. r=mattwoodrow (4699b7e935)
- Bug 1205087 - Cache the AnimatedGeometryRoot on DisplayItem. r=roc (06bba311c3)
- Back out the bits of bug 1205087 that cache the AnimatedGeometryRoot on DisplayItem. r=backout (254057a6b6)
- Bug 1203190 - Don't intersect with the visible rect for fixed background images. r=mattwoodrow (1c5a432459)
- Bug 1208438 - Don't allow layers with scrolling clips to occlusion-cull layers behind them. r=mattwoodrow (c3d77a9846)
- Bug 1205630 - Translate a fixed background display item's clip rect correctly when setting it on the layer. r=mstange (49039f0e2d)
- Bug 1205630 - Reftest. r=mstange (a8db59eaee)
- Bug 1105832 - Also dump inactive layer managers when display list dumping is enabled. r=mattwoodrow (564fe5fcbc)
- Bug 1208661 - Move Dump() up from ContentClient to CompositableClient. r=BenWa (37915312b3)
330 lines
12 KiB
C++
330 lines
12 KiB
C++
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include <windows.h>
|
|
|
|
#include "nsMathUtils.h"
|
|
|
|
#include "gfxWindowsNativeDrawing.h"
|
|
#include "gfxWindowsSurface.h"
|
|
#include "gfxAlphaRecovery.h"
|
|
#include "gfxPattern.h"
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "gfx2DGlue.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::gfx;
|
|
|
|
enum {
|
|
RENDER_STATE_INIT,
|
|
|
|
RENDER_STATE_NATIVE_DRAWING,
|
|
RENDER_STATE_NATIVE_DRAWING_DONE,
|
|
|
|
RENDER_STATE_ALPHA_RECOVERY_BLACK,
|
|
RENDER_STATE_ALPHA_RECOVERY_BLACK_DONE,
|
|
RENDER_STATE_ALPHA_RECOVERY_WHITE,
|
|
RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE,
|
|
|
|
RENDER_STATE_DONE
|
|
};
|
|
|
|
gfxWindowsNativeDrawing::gfxWindowsNativeDrawing(gfxContext* ctx,
|
|
const gfxRect& nativeRect,
|
|
uint32_t nativeDrawFlags)
|
|
: mContext(ctx), mNativeRect(nativeRect), mNativeDrawFlags(nativeDrawFlags), mRenderState(RENDER_STATE_INIT)
|
|
{
|
|
}
|
|
|
|
HDC
|
|
gfxWindowsNativeDrawing::BeginNativeDrawing()
|
|
{
|
|
if (mRenderState == RENDER_STATE_INIT) {
|
|
nsRefPtr<gfxASurface> surf;
|
|
|
|
if (mContext->GetCairo()) {
|
|
surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y);
|
|
}
|
|
|
|
if (surf && surf->CairoStatus())
|
|
return nullptr;
|
|
|
|
gfxMatrix m = mContext->CurrentMatrix();
|
|
if (!m.HasNonTranslation())
|
|
mTransformType = TRANSLATION_ONLY;
|
|
else if (m.HasNonAxisAlignedTransform())
|
|
mTransformType = COMPLEX;
|
|
else
|
|
mTransformType = AXIS_ALIGNED_SCALE;
|
|
|
|
// if this is a native win32 surface, we don't have to
|
|
// redirect rendering to our own HDC; in some cases,
|
|
// we may be able to use the HDC from the surface directly.
|
|
if (surf &&
|
|
((surf->GetType() == gfxSurfaceType::Win32 ||
|
|
surf->GetType() == gfxSurfaceType::Win32Printing) &&
|
|
(surf->GetContentType() == gfxContentType::COLOR ||
|
|
(surf->GetContentType() == gfxContentType::COLOR_ALPHA &&
|
|
(mNativeDrawFlags & CAN_DRAW_TO_COLOR_ALPHA)))))
|
|
{
|
|
// grab the DC. This can fail if there is a complex clipping path,
|
|
// in which case we'll have to fall back.
|
|
mWinSurface = static_cast<gfxWindowsSurface*>(static_cast<gfxASurface*>(surf.get()));
|
|
mDC = mWinSurface->GetDCWithClip(mContext);
|
|
|
|
if (mDC) {
|
|
if (mTransformType == TRANSLATION_ONLY) {
|
|
mRenderState = RENDER_STATE_NATIVE_DRAWING;
|
|
|
|
mTranslation = m.GetTranslation();
|
|
} else if (((mTransformType == AXIS_ALIGNED_SCALE)
|
|
&& (mNativeDrawFlags & CAN_AXIS_ALIGNED_SCALE)) ||
|
|
(mNativeDrawFlags & CAN_COMPLEX_TRANSFORM))
|
|
{
|
|
mWorldTransform.eM11 = (FLOAT) m._11;
|
|
mWorldTransform.eM12 = (FLOAT) m._12;
|
|
mWorldTransform.eM21 = (FLOAT) m._21;
|
|
mWorldTransform.eM22 = (FLOAT) m._22;
|
|
mWorldTransform.eDx = (FLOAT) m._31;
|
|
mWorldTransform.eDy = (FLOAT) m._32;
|
|
|
|
mRenderState = RENDER_STATE_NATIVE_DRAWING;
|
|
}
|
|
}
|
|
}
|
|
|
|
// If we couldn't do native drawing, then we have to do two-buffer drawing
|
|
// and do alpha recovery
|
|
if (mRenderState == RENDER_STATE_INIT) {
|
|
mRenderState = RENDER_STATE_ALPHA_RECOVERY_BLACK;
|
|
|
|
// We round out our native rect here, that way the snapping will
|
|
// happen correctly.
|
|
mNativeRect.RoundOut();
|
|
|
|
// we only do the scale bit if we can do an axis aligned
|
|
// scale; otherwise we scale (if necessary) after
|
|
// rendering with cairo. Note that if we're doing alpha recovery,
|
|
// we cannot do a full complex transform with win32 (I mean, we could, but
|
|
// it would require more code that's not here.)
|
|
if (mTransformType == TRANSLATION_ONLY || !(mNativeDrawFlags & CAN_AXIS_ALIGNED_SCALE)) {
|
|
mScale = gfxSize(1.0, 1.0);
|
|
|
|
// Add 1 to the surface size; it's guaranteed to not be incorrect,
|
|
// and it fixes bug 382458
|
|
// There's probably a better fix, but I haven't figured out
|
|
// the root cause of the problem.
|
|
mTempSurfaceSize =
|
|
IntSize((int32_t) ceil(mNativeRect.Width() + 1),
|
|
(int32_t) ceil(mNativeRect.Height() + 1));
|
|
} else {
|
|
// figure out the scale factors
|
|
mScale = m.ScaleFactors(true);
|
|
|
|
mWorldTransform.eM11 = (FLOAT) mScale.width;
|
|
mWorldTransform.eM12 = 0.0f;
|
|
mWorldTransform.eM21 = 0.0f;
|
|
mWorldTransform.eM22 = (FLOAT) mScale.height;
|
|
mWorldTransform.eDx = 0.0f;
|
|
mWorldTransform.eDy = 0.0f;
|
|
|
|
// See comment above about "+1"
|
|
mTempSurfaceSize =
|
|
IntSize((int32_t) ceil(mNativeRect.Width() * mScale.width + 1),
|
|
(int32_t) ceil(mNativeRect.Height() * mScale.height + 1));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (mRenderState == RENDER_STATE_NATIVE_DRAWING) {
|
|
// we can just do native drawing directly to the context's surface
|
|
|
|
// do we need to use SetWorldTransform?
|
|
if (mTransformType != TRANSLATION_ONLY) {
|
|
SetGraphicsMode(mDC, GM_ADVANCED);
|
|
GetWorldTransform(mDC, &mOldWorldTransform);
|
|
SetWorldTransform(mDC, &mWorldTransform);
|
|
}
|
|
GetViewportOrgEx(mDC, &mOrigViewportOrigin);
|
|
SetViewportOrgEx(mDC,
|
|
mOrigViewportOrigin.x + (int)mDeviceOffset.x,
|
|
mOrigViewportOrigin.y + (int)mDeviceOffset.y,
|
|
nullptr);
|
|
|
|
return mDC;
|
|
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK ||
|
|
mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE)
|
|
{
|
|
// we're going to use mWinSurface to create our temporary surface here
|
|
|
|
// get us a RGB24 DIB; DIB is important, because
|
|
// we can later call GetImageSurface on it.
|
|
mWinSurface = new gfxWindowsSurface(mTempSurfaceSize);
|
|
mDC = mWinSurface->GetDC();
|
|
|
|
RECT r = { 0, 0, mTempSurfaceSize.width, mTempSurfaceSize.height };
|
|
if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK)
|
|
FillRect(mDC, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
|
|
else
|
|
FillRect(mDC, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
|
|
|
if ((mTransformType != TRANSLATION_ONLY) &&
|
|
(mNativeDrawFlags & CAN_AXIS_ALIGNED_SCALE))
|
|
{
|
|
SetGraphicsMode(mDC, GM_ADVANCED);
|
|
SetWorldTransform(mDC, &mWorldTransform);
|
|
}
|
|
|
|
return mDC;
|
|
} else {
|
|
NS_ERROR("Bogus render state!");
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
bool
|
|
gfxWindowsNativeDrawing::IsDoublePass()
|
|
{
|
|
if (mContext->GetDrawTarget()->GetBackendType() != mozilla::gfx::BackendType::CAIRO ||
|
|
mContext->GetDrawTarget()->IsDualDrawTarget()) {
|
|
return true;
|
|
}
|
|
|
|
nsRefPtr<gfxASurface> surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y);
|
|
if (!surf || surf->CairoStatus())
|
|
return false;
|
|
if (surf->GetType() != gfxSurfaceType::Win32 &&
|
|
surf->GetType() != gfxSurfaceType::Win32Printing) {
|
|
return true;
|
|
}
|
|
if ((surf->GetContentType() != gfxContentType::COLOR ||
|
|
(surf->GetContentType() == gfxContentType::COLOR_ALPHA &&
|
|
!(mNativeDrawFlags & CAN_DRAW_TO_COLOR_ALPHA))))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
gfxWindowsNativeDrawing::ShouldRenderAgain()
|
|
{
|
|
switch (mRenderState) {
|
|
case RENDER_STATE_NATIVE_DRAWING_DONE:
|
|
return false;
|
|
|
|
case RENDER_STATE_ALPHA_RECOVERY_BLACK_DONE:
|
|
mRenderState = RENDER_STATE_ALPHA_RECOVERY_WHITE;
|
|
return true;
|
|
|
|
case RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE:
|
|
return false;
|
|
|
|
default:
|
|
NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::ShouldRenderAgain");
|
|
break;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void
|
|
gfxWindowsNativeDrawing::EndNativeDrawing()
|
|
{
|
|
if (mRenderState == RENDER_STATE_NATIVE_DRAWING) {
|
|
// we drew directly to the HDC in the context; undo our changes
|
|
SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, nullptr);
|
|
|
|
if (mTransformType != TRANSLATION_ONLY)
|
|
SetWorldTransform(mDC, &mOldWorldTransform);
|
|
|
|
mWinSurface->MarkDirty();
|
|
|
|
mRenderState = RENDER_STATE_NATIVE_DRAWING_DONE;
|
|
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK) {
|
|
mBlackSurface = mWinSurface;
|
|
mWinSurface = nullptr;
|
|
|
|
mRenderState = RENDER_STATE_ALPHA_RECOVERY_BLACK_DONE;
|
|
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE) {
|
|
mWhiteSurface = mWinSurface;
|
|
mWinSurface = nullptr;
|
|
|
|
mRenderState = RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE;
|
|
} else {
|
|
NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::EndNativeDrawing");
|
|
}
|
|
}
|
|
|
|
void
|
|
gfxWindowsNativeDrawing::PaintToContext()
|
|
{
|
|
if (mRenderState == RENDER_STATE_NATIVE_DRAWING_DONE) {
|
|
// nothing to do, it already went to the context
|
|
mRenderState = RENDER_STATE_DONE;
|
|
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE) {
|
|
nsRefPtr<gfxImageSurface> black = mBlackSurface->GetAsImageSurface();
|
|
nsRefPtr<gfxImageSurface> white = mWhiteSurface->GetAsImageSurface();
|
|
if (!gfxAlphaRecovery::RecoverAlpha(black, white)) {
|
|
NS_ERROR("Alpha recovery failure");
|
|
return;
|
|
}
|
|
RefPtr<DataSourceSurface> source =
|
|
Factory::CreateWrappingDataSourceSurface(black->Data(),
|
|
black->Stride(),
|
|
black->GetSize(),
|
|
SurfaceFormat::B8G8R8A8);
|
|
|
|
mContext->Save();
|
|
mContext->SetMatrix(
|
|
mContext->CurrentMatrix().Translate(mNativeRect.TopLeft()));
|
|
mContext->NewPath();
|
|
mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.Size()));
|
|
|
|
nsRefPtr<gfxPattern> pat = new gfxPattern(source, Matrix());
|
|
|
|
gfxMatrix m;
|
|
m.Scale(mScale.width, mScale.height);
|
|
pat->SetMatrix(m);
|
|
|
|
if (mNativeDrawFlags & DO_NEAREST_NEIGHBOR_FILTERING)
|
|
pat->SetFilter(Filter::LINEAR);
|
|
|
|
pat->SetExtend(ExtendMode::CLAMP);
|
|
mContext->SetPattern(pat);
|
|
mContext->Fill();
|
|
mContext->Restore();
|
|
|
|
mRenderState = RENDER_STATE_DONE;
|
|
} else {
|
|
NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::PaintToContext");
|
|
}
|
|
}
|
|
|
|
void
|
|
gfxWindowsNativeDrawing::TransformToNativeRect(const gfxRect& r,
|
|
RECT& rout)
|
|
{
|
|
/* If we're doing native drawing, then we're still in the coordinate space
|
|
* of the context; otherwise, we're in our own little world,
|
|
* relative to the passed-in nativeRect.
|
|
*/
|
|
|
|
gfxRect roundedRect(r);
|
|
|
|
if (mRenderState == RENDER_STATE_NATIVE_DRAWING) {
|
|
if (mTransformType == TRANSLATION_ONLY) {
|
|
roundedRect.MoveBy(mTranslation);
|
|
}
|
|
} else {
|
|
roundedRect.MoveBy(-mNativeRect.TopLeft());
|
|
}
|
|
|
|
roundedRect.Round();
|
|
|
|
rout.left = LONG(roundedRect.X());
|
|
rout.right = LONG(roundedRect.XMost());
|
|
rout.top = LONG(roundedRect.Y());
|
|
rout.bottom = LONG(roundedRect.YMost());
|
|
}
|